mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 00:17:20 +02:00
Make JSch injection lazy
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=154958750
This commit is contained in:
parent
5e7834b00e
commit
93c2a1e4f0
4 changed files with 53 additions and 15 deletions
|
@ -32,6 +32,7 @@ import com.google.common.io.ByteStreams;
|
|||
import com.googlecode.objectify.VoidWork;
|
||||
import com.jcraft.jsch.JSch;
|
||||
import com.jcraft.jsch.JSchException;
|
||||
import dagger.Lazy;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.gcs.GcsUtils;
|
||||
import google.registry.keyring.api.KeyModule.Key;
|
||||
|
@ -87,7 +88,15 @@ public final class RdeUploadAction implements Runnable, EscrowTask {
|
|||
@Inject GcsUtils gcsUtils;
|
||||
@Inject Ghostryde ghostryde;
|
||||
@Inject EscrowTaskRunner runner;
|
||||
@Inject JSch jsch;
|
||||
|
||||
// Using Lazy<JSch> instead of JSch to prevent fetching of rdeSsh*Keys before we know we're
|
||||
// actually going to use them. See b/37868282
|
||||
//
|
||||
// This prevents making an unnecessary time-expensive (and potentially failing) API call to the
|
||||
// external KMS system when the RdeUploadAction ends up not being used (if the EscrowTaskRunner
|
||||
// determins this EscrowTask was already completed today).
|
||||
@Inject Lazy<JSch> lazyJsch;
|
||||
|
||||
@Inject JSchSshSessionFactory jschSshSessionFactory;
|
||||
@Inject Response response;
|
||||
@Inject RydePgpCompressionOutputStreamFactory pgpCompressionFactory;
|
||||
|
@ -193,7 +202,7 @@ public final class RdeUploadAction implements Runnable, EscrowTask {
|
|||
Ghostryde.Decryptor decryptor = ghostryde.openDecryptor(gcsInput, stagingDecryptionKey);
|
||||
Ghostryde.Decompressor decompressor = ghostryde.openDecompressor(decryptor);
|
||||
Ghostryde.Input xmlInput = ghostryde.openInput(decompressor)) {
|
||||
try (JSchSshSession session = jschSshSessionFactory.create(jsch, uploadUrl);
|
||||
try (JSchSshSession session = jschSshSessionFactory.create(lazyJsch.get(), uploadUrl);
|
||||
JSchSftpChannel ftpChan = session.openSftpChannel()) {
|
||||
byte[] signature;
|
||||
String rydeFilename = name + ".ryde";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue