changeset 20777:ad30bd042ffd

8026301: DomainKeyStore doesn't cleanup correctly when storing to keystore Reviewed-by: mullan
author vinnie
date Fri, 11 Oct 2013 20:35:00 +0100
parents a7cd22051d8f
children 26af21e74a8d
files jdk/src/share/classes/sun/security/provider/DomainKeyStore.java
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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);
                 }