< prev index next >

test/jdk/java/util/zip/ZipFile/FinalizeZipFile.java

Print this page

        

@@ -29,10 +29,11 @@
 
 import java.io.*;
 import java.util.Random;
 import java.util.zip.*;
 import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 
 public class FinalizeZipFile {
 
     private static final CountDownLatch finalizersDone = new CountDownLatch(3);
 

@@ -41,11 +42,11 @@
         public InstrumentedZipFile(File f) throws Exception {
             super(f);
             System.out.printf("Using %s%n", f.getPath());
         }
         @Override
-        protected void finalize() throws IOException {
+        protected void finalize() throws Throwable {
             System.out.printf("Killing %s%n", getName());
             super.finalize();
             finalizersDone.countDown();
         }
     }

@@ -76,14 +77,13 @@
         }
     }
 
     public static void realMain(String[] args) throws Throwable {
         makeGarbage();
-
+        while (!finalizersDone.await(10, TimeUnit.MILLISECONDS)) {
         System.gc();
-        finalizersDone.await();
-
+        }
         // Not all ZipFiles were collected?
         equal(finalizersDone.getCount(), 0L);
     }
 
     //--------------------- Infrastructure ---------------------------
< prev index next >