sun/net/www/protocol/jar/B4957695.java

This test is to verify that no jar_cache tmpFile left in temp directory when IOException occurs.

Test do stream reading and trigger IOException and compare the jar_cache file number before and after this action (that triggered the IOException):

        String tmpdir = System.getProperty("java.io.tmpdir");
        String[] list1 = listTmpFiles(tmpdir);
        … // do stream reading, trigger IOException
        String[] list2 = listTmpFiles(tmpdir);
        if (!sameList (list1, list2)) {
throw new RuntimeException ("some jar_cache files left behind");
        }

This does not work well when tests run concurrently, the jar_cache file under tmpdir may from other tests.

Please review the patch to set "java.io.tmpdir" to current working dir to avoid test be affected by other tests.

bug: https://bugs.openjdk.java.net/browse/JDK-8146257
webrev: http://cr.openjdk.java.net/~amlu/8146257/webrev.00/

Thanks,
Amy

--- old/test/sun/net/www/protocol/jar/B4957695.java     2016-10-20 
17:04:00.000000000 +0800
+++ new/test/sun/net/www/protocol/jar/B4957695.java     2016-10-20 
17:04:00.000000000 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
 /**
  * @test
  * @bug 4957695
+ * @run main/othervm -Djava.io.tmpdir=. B4957695
  * @summary URLJarFile.retrieve does not delete tmpFile on IOException
  */

Reply via email to