8026301: DomainKeyStore doesn't cleanup correctly when storing to keystore
authorvinnie
Fri, 11 Oct 2013 20:35:00 +0100
changeset 20777 ad30bd042ffd
parent 20775 a7cd22051d8f
child 20778 26af21e74a8d
8026301: DomainKeyStore doesn't cleanup correctly when storing to keystore Reviewed-by: mullan
jdk/src/share/classes/sun/security/provider/DomainKeyStore.java
--- a/jdk/src/share/classes/sun/security/provider/DomainKeyStore.java	Fri Oct 11 09:17:18 2013 -0400
+++ b/jdk/src/share/classes/sun/security/provider/DomainKeyStore.java	Fri Oct 11 20:35:00 2013 +0100
@@ -652,9 +652,12 @@
 
                     // Store the keystores
                     KeyStore keystore = keystores.get(builder.name);
-                    keystore.store(new FileOutputStream(builder.file),
-                        password);
 
+                    try (FileOutputStream stream =
+                        new FileOutputStream(builder.file)) {
+
+                        keystore.store(stream, password);
+                    }
                 } catch (KeyStoreException e) {
                     throw new IOException(e);
                 }