Please review the fix. The comment said the test will try several times but when ts2.cert does not have the same size it is not regenerated at all, and a 2nd delete fails.
diff --git a/test/jdk/sun/security/tools/jarsigner/TimestampCheck.java b/test/jdk/sun/security/tools/jarsigner/TimestampCheck.java --- a/test/jdk/sun/security/tools/jarsigner/TimestampCheck.java +++ b/test/jdk/sun/security/tools/jarsigner/TimestampCheck.java @@ -694,11 +694,12 @@ gencert("ts", "-ext eku:critical=ts"); - // Issue another cert for "ts" with a different EKU. - // Length should be the same. Try several times. - keytool("-gencert -alias ca -infile ts.req -outfile ts2.cert " + - "-ext eku:critical=1.3.6.1.5.5.7.3.9"); for (int i = 0; i < 5; i++) { + // Issue another cert for "ts" with a different EKU. + // Length should be the same. Try several times. + // If cannot create one, related test will be ignored. + keytool("-gencert -alias ca -infile ts.req -outfile ts2.cert " + + "-ext eku:critical=1.3.6.1.5.5.7.3.9"); if (Files.size(Paths.get("ts.cert")) != Files.size(Paths.get("ts2.cert"))) { Files.delete(Paths.get("ts2.cert")); System.out.println("Warning: cannot create same length"); } else { break; } } Thanks Max