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 ;
@@ -773,7 +774,9 @@ protected KeyManager[] configureKeyManagers() throws KeyStoreException, IOExcept
773
774
Resource resource = this .keyStoreResource != null ? this .keyStoreResource
774
775
: this .resolver .getResource (keyStoreName );
775
776
KeyStore ks = KeyStore .getInstance (storeType );
776
- ks .load (resource .getInputStream (), keyPassphrase );
777
+ try (InputStream inputStream = resource .getInputStream ()) {
778
+ ks .load (inputStream , keyPassphrase );
779
+ }
777
780
KeyManagerFactory kmf = KeyManagerFactory .getInstance (this .keyStoreAlgorithm );
778
781
kmf .init (ks , keyPassphrase );
779
782
keyManagers = kmf .getKeyManagers ();
@@ -796,7 +799,9 @@ protected TrustManager[] configureTrustManagers()
796
799
Resource resource = this .trustStoreResource != null ? this .trustStoreResource
797
800
: this .resolver .getResource (trustStoreName );
798
801
KeyStore tks = KeyStore .getInstance (storeType );
799
- tks .load (resource .getInputStream (), trustPassphrase );
802
+ try (InputStream inputStream = resource .getInputStream ()) {
803
+ tks .load (inputStream , trustPassphrase );
804
+ }
800
805
TrustManagerFactory tmf = TrustManagerFactory .getInstance (this .trustStoreAlgorithm );
801
806
tmf .init (tks );
802
807
trustManagers = tmf .getTrustManagers ();
0 commit comments