@@ -108,7 +108,7 @@ public MtlsHttpTransportFactory(MtlsProvider mtlsProvider)
108108 }
109109 }
110110
111- private static SSLSocketFactory buildSslSocketFactory (KeyStore keyStore )
111+ private static SSLSocketFactory buildSslSocketFactory (@ Nullable KeyStore keyStore )
112112 throws GeneralSecurityException {
113113 return new NetHttpTransport .Builder ()
114114 .trustCertificates (null , keyStore , "" )
@@ -124,8 +124,10 @@ private static SSLSocketFactory buildSslSocketFactory(KeyStore keyStore)
124124 public synchronized void rebuildContext () throws IOException {
125125 if (this .mtlsProvider != null ) {
126126 try {
127- this .mtlsKeyStore = this .mtlsProvider .getKeyStore ();
128- this .sslSocketFactory .setDelegate (buildSslSocketFactory (this .mtlsKeyStore ));
127+ KeyStore newKeyStore = this .mtlsProvider .getKeyStore ();
128+ SSLSocketFactory newSslSocketFactory = buildSslSocketFactory (newKeyStore );
129+ this .mtlsKeyStore = newKeyStore ;
130+ this .sslSocketFactory .setDelegate (newSslSocketFactory );
129131 } catch (CertificateSourceUnavailableException e ) {
130132 throw new IOException ("Failed to reload KeyStore from MtlsProvider." , e );
131133 } catch (GeneralSecurityException e ) {
@@ -135,7 +137,7 @@ public synchronized void rebuildContext() throws IOException {
135137 }
136138
137139 @ VisibleForTesting
138- KeyStore getKeyStore () {
140+ @ Nullable KeyStore getKeyStore () {
139141 return mtlsKeyStore ;
140142 }
141143
0 commit comments