8026233: test/sun/security/tools/keytool/StorePasswords.java needs to clean up files

Reviewed-by: vinnie
This commit is contained in:
Jason Uh 2013-10-17 12:00:20 -07:00
parent 70991c8052
commit 9419bb4f59

View File

@ -77,6 +77,8 @@ public class StorePasswords {
} }
System.out.println("\nStored " + storeCount + " user passwords, " + System.out.println("\nStored " + storeCount + " user passwords, " +
"recovered " + recoverCount + " user passwords"); "recovered " + recoverCount + " user passwords");
new File(KEYSTORE).delete();
} }
private static int store() throws Exception { private static int store() throws Exception {
@ -144,7 +146,9 @@ public class StorePasswords {
// Store the PKCS#12 keystore // Store the PKCS#12 keystore
System.out.println("Storing PKCS#12 keystore to: " + KEYSTORE); System.out.println("Storing PKCS#12 keystore to: " + KEYSTORE);
keystore.store(new FileOutputStream(KEYSTORE), KEYSTORE_PWD); try (FileOutputStream out = new FileOutputStream(KEYSTORE)) {
keystore.store(out, KEYSTORE_PWD);
}
return count; return count;
} }
@ -154,7 +158,9 @@ public class StorePasswords {
// Load the PKCS#12 keystore // Load the PKCS#12 keystore
KeyStore keystore = KeyStore.getInstance("PKCS12"); KeyStore keystore = KeyStore.getInstance("PKCS12");
System.out.println("\nLoading PKCS#12 keystore from: " + KEYSTORE); System.out.println("\nLoading PKCS#12 keystore from: " + KEYSTORE);
keystore.load(new FileInputStream(KEYSTORE), KEYSTORE_PWD); try (FileInputStream in = new FileInputStream(KEYSTORE)) {
keystore.load(in, KEYSTORE_PWD);
}
SecretKey key; SecretKey key;
SecretKeyFactory factory; SecretKeyFactory factory;