# HG changeset patch # User juh # Date 1382036420 25200 # Node ID 05811931e2662fffb0f93a5a3f3eff20b0b52f85 # Parent ee92cf5c888842673b9c8e7653ae8a915243e869 8026233: test/sun/security/tools/keytool/StorePasswords.java needs to clean up files Reviewed-by: vinnie diff -r ee92cf5c8888 -r 05811931e266 jdk/test/sun/security/tools/keytool/StorePasswords.java --- a/jdk/test/sun/security/tools/keytool/StorePasswords.java Thu Oct 17 11:43:44 2013 -0700 +++ b/jdk/test/sun/security/tools/keytool/StorePasswords.java Thu Oct 17 12:00:20 2013 -0700 @@ -77,6 +77,8 @@ } System.out.println("\nStored " + storeCount + " user passwords, " + "recovered " + recoverCount + " user passwords"); + + new File(KEYSTORE).delete(); } private static int store() throws Exception { @@ -144,7 +146,9 @@ // Store the PKCS#12 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; } @@ -154,7 +158,9 @@ // Load the PKCS#12 keystore KeyStore keystore = KeyStore.getInstance("PKCS12"); 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; SecretKeyFactory factory;