Use lazy injection in SendEscrow command (#1086)

* Use lazy injection in SendEscrow command

The injected object in SendEscrowReportToIcannCommand creates Ofy keys
in its static initialization routine. This happens before the RemoteApi
setup. Use lazy injection to prevent failure.
This commit is contained in:
Weimin Yu 2021-04-15 16:15:01 -04:00 committed by GitHub
parent 1cc8af4acd
commit 98d259449b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,6 +16,7 @@ package google.registry.tools;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import dagger.Lazy;
import google.registry.rde.RdeReporter;
import google.registry.tools.params.PathParameter;
import java.nio.file.Files;
@ -33,13 +34,12 @@ final class SendEscrowReportToIcannCommand implements CommandWithRemoteApi {
required = true)
private List<Path> files;
@Inject
RdeReporter rdeReporter;
@Inject Lazy<RdeReporter> rdeReporter;
@Override
public void run() throws Exception {
for (Path file : files) {
rdeReporter.send(Files.readAllBytes(file));
rdeReporter.get().send(Files.readAllBytes(file));
System.out.printf("Uploaded: %s\n", file);
}
}