# HG changeset patch # User weijun # Date 1448953630 -28800 # Node ID 5390ced223f027b5966d843823e6551b1582f83c # Parent 3e63290b299a2555ec44b067509b388ac98126ff 8144294: jdk/security/jarsigner/Function.java failed to clean up files after test on Windows Reviewed-by: xuelei diff -r 3e63290b299a -r 5390ced223f0 jdk/test/jdk/security/jarsigner/Function.java --- a/jdk/test/jdk/security/jarsigner/Function.java Tue Dec 01 10:02:06 2015 +0800 +++ b/jdk/test/jdk/security/jarsigner/Function.java Tue Dec 01 15:07:10 2015 +0800 @@ -71,13 +71,17 @@ " -keypass changeit -dname" + " CN=RSA -alias r -genkeypair -keyalg rsa").split(" ")); - KeyStore ks = KeyStore.getInstance("JKS"); - ks.load(new FileInputStream("ks"), "changeit".toCharArray()); - PrivateKey key = (PrivateKey)ks.getKey("r", "changeit".toCharArray()); - Certificate cert = ks.getCertificate("r"); - JarSigner.Builder jsb = new JarSigner.Builder(key, - CertificateFactory.getInstance("X.509").generateCertPath( - Collections.singletonList(cert))); + JarSigner.Builder jsb; + + try (FileInputStream fis = new FileInputStream("ks")) { + KeyStore ks = KeyStore.getInstance("JKS"); + ks.load(fis, "changeit".toCharArray()); + PrivateKey key = (PrivateKey)ks.getKey("r", "changeit".toCharArray()); + Certificate cert = ks.getCertificate("r"); + jsb = new JarSigner.Builder(key, + CertificateFactory.getInstance("X.509").generateCertPath( + Collections.singletonList(cert))); + } jsb.digestAlgorithm("SHA1"); jsb.signatureAlgorithm("SHA1withRSA");