Skip to content

Commit a3d260b

Browse files
author
Dave Syer
committed
Close input stream carefully
1 parent faf554f commit a3d260b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/main/java/org/springframework/security/rsa/crypto/KeyStoreKeyFactory.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package org.springframework.security.rsa.crypto;
1717

18+
import java.io.InputStream;
1819
import java.security.KeyFactory;
1920
import java.security.KeyPair;
2021
import java.security.KeyStore;
@@ -62,7 +63,15 @@ public KeyPair getKeyPair(String alias, char[] password) {
6263
if (store == null) {
6364
synchronized (lock) {
6465
store = KeyStore.getInstance(type);
65-
store.load(resource.getInputStream(), this.password);
66+
InputStream stream = resource.getInputStream();
67+
try {
68+
store.load(stream, this.password);
69+
}
70+
finally {
71+
if (stream != null) {
72+
stream.close();
73+
}
74+
}
6675
}
6776
}
6877
}

0 commit comments

Comments
 (0)