1616
1717package org .springframework .amqp .rabbit .connection ;
1818
19+ import java .io .InputStream ;
1920import java .lang .reflect .Method ;
2021import java .net .URI ;
2122import java .net .URISyntaxException ;
7273 *
7374 * @author Gary Russell
7475 * @author Heath Abelson
75- * @author Arnaud Cogoluègnes
76+ * @author Arnaud Cogoluegnes
7677 * @author Hareendran
7778 * @author Artem Bilan
7879 * @author Zachary DeLuca
@@ -731,7 +732,13 @@ protected void setUpSSL() throws Exception {
731732 Resource keyStoreResource = this .keyStoreResource != null ? this .keyStoreResource
732733 : resolver .getResource (keyStoreName );
733734 KeyStore ks = KeyStore .getInstance (keyStoreType );
734- ks .load (keyStoreResource .getInputStream (), keyPassphrase );
735+ InputStream inputStream = keyStoreResource .getInputStream ();
736+ try {
737+ ks .load (inputStream , keyPassphrase );
738+ }
739+ finally {
740+ inputStream .close ();
741+ }
735742 KeyManagerFactory kmf = KeyManagerFactory .getInstance ("SunX509" );
736743 kmf .init (ks , keyPassphrase );
737744 keyManagers = kmf .getKeyManagers ();
@@ -740,7 +747,13 @@ protected void setUpSSL() throws Exception {
740747 Resource trustStoreResource = this .trustStoreResource != null ? this .trustStoreResource
741748 : resolver .getResource (trustStoreName );
742749 KeyStore tks = KeyStore .getInstance (trustStoreType );
743- tks .load (trustStoreResource .getInputStream (), trustPassphrase );
750+ InputStream inputStream = trustStoreResource .getInputStream ();
751+ try {
752+ tks .load (inputStream , trustPassphrase );
753+ }
754+ finally {
755+ inputStream .close ();
756+ }
744757 TrustManagerFactory tmf = TrustManagerFactory .getInstance ("SunX509" );
745758 tmf .init (tks );
746759 trustManagers = tmf .getTrustManagers ();
0 commit comments