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 ;
@@ -756,7 +757,9 @@ protected KeyManager[] configureKeyManagers() throws KeyStoreException, IOExcept
756
757
Resource resource = this .keyStoreResource != null ? this .keyStoreResource
757
758
: this .resolver .getResource (keyStoreName );
758
759
KeyStore ks = KeyStore .getInstance (storeType );
759
- ks .load (resource .getInputStream (), keyPassphrase );
760
+ try (InputStream inputStream = resource .getInputStream ()) {
761
+ ks .load (inputStream , keyPassphrase );
762
+ }
760
763
KeyManagerFactory kmf = KeyManagerFactory .getInstance (this .keyStoreAlgorithm );
761
764
kmf .init (ks , keyPassphrase );
762
765
keyManagers = kmf .getKeyManagers ();
@@ -779,7 +782,9 @@ protected TrustManager[] configureTrustManagers()
779
782
Resource resource = this .trustStoreResource != null ? this .trustStoreResource
780
783
: this .resolver .getResource (trustStoreName );
781
784
KeyStore tks = KeyStore .getInstance (storeType );
782
- tks .load (resource .getInputStream (), trustPassphrase );
785
+ try (InputStream inputStream = resource .getInputStream ()) {
786
+ tks .load (inputStream , trustPassphrase );
787
+ }
783
788
TrustManagerFactory tmf = TrustManagerFactory .getInstance (this .trustStoreAlgorithm );
784
789
tmf .init (tks );
785
790
trustManagers = tmf .getTrustManagers ();
0 commit comments