17
17
package org .springframework .amqp .rabbit .connection ;
18
18
19
19
import java .io .IOException ;
20
+ import java .io .InputStream ;
20
21
import java .net .URI ;
21
22
import java .net .URISyntaxException ;
22
23
import java .security .KeyManagementException ;
@@ -816,7 +817,9 @@ protected KeyManager[] configureKeyManagers() throws KeyStoreException, IOExcept
816
817
Resource resource = this .keyStoreResource != null ? this .keyStoreResource
817
818
: this .resourceLoader .getResource (keyStoreName );
818
819
KeyStore ks = KeyStore .getInstance (storeType );
819
- ks .load (resource .getInputStream (), keyPassphrase );
820
+ try (InputStream inputStream = resource .getInputStream ()) {
821
+ ks .load (inputStream , keyPassphrase );
822
+ }
820
823
KeyManagerFactory kmf = KeyManagerFactory .getInstance (this .keyStoreAlgorithm );
821
824
kmf .init (ks , keyPassphrase );
822
825
keyManagers = kmf .getKeyManagers ();
@@ -839,7 +842,9 @@ protected TrustManager[] configureTrustManagers()
839
842
Resource resource = this .trustStoreResource != null ? this .trustStoreResource
840
843
: this .resourceLoader .getResource (trustStoreName );
841
844
KeyStore tks = KeyStore .getInstance (storeType );
842
- tks .load (resource .getInputStream (), trustPassphrase );
845
+ try (InputStream inputStream = resource .getInputStream ()) {
846
+ tks .load (inputStream , trustPassphrase );
847
+ }
843
848
TrustManagerFactory tmf = TrustManagerFactory .getInstance (this .trustStoreAlgorithm );
844
849
tmf .init (tks );
845
850
trustManagers = tmf .getTrustManagers ();
0 commit comments