< prev index next >

test/jdk/java/util/logging/LogManager/Configuration/updateConfiguration/HandlersOnComplexResetUpdate.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2019, 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
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -78,10 +78,18 @@
             Configure.setUp(this, properties.get(0));
             test(this.name(), properties);
         }
     }
 
+    public static final double TIMEOUT_FACTOR;
+    static {
+        String toFactor = System.getProperty("test.timeout.factor", "1.0");
+        TIMEOUT_FACTOR = Double.parseDouble(toFactor);
+    }
+    static int adjustCount(int count) {
+        return (int) Math.ceil(TIMEOUT_FACTOR * count);
+    }
 
     private static final String PREFIX =
             "FileHandler-" + UUID.randomUUID() + ".log";
     private static final String userDir = System.getProperty("user.dir", ".");
     private static final boolean userDirWritable = Files.isWritable(Paths.get(userDir));

@@ -211,15 +219,15 @@
         if (barRef.get() != barChild.getParent()) {
             throw new RuntimeException("Unexpected parent logger: "
                     + barChild.getParent() +"\n\texpected: " + barRef.get());
         }
         Reference<? extends Logger> ref2;
-        int max = 3;
+        int max = adjustCount(3);
         barChild = null;
         while ((ref2 = queue.poll()) == null) {
             System.gc();
-            Thread.sleep(100);
+            Thread.sleep(1000);
             if (--max == 0) break;
         }
 
         Throwable failed = null;
         try {

@@ -326,10 +334,11 @@
                 } catch(Exception x) {
                     if (suppressed != null) x.addSuppressed(suppressed);
                     throw new RuntimeException(x);
                 }
             });
+            try {
             fooChild = null;
             System.out.println("Setting fooChild to: " + fooChild);
             while ((ref2 = queue.poll()) == null) {
                 System.gc();
                 Thread.sleep(1000);

@@ -340,11 +349,14 @@
             }
             if (ref2.get() != null) {
                 throw new RuntimeException("Referent not cleared: " + ref2.get());
             }
             System.out.println("Got fooRef after reset(), fooChild is " + fooChild);
-
+             } catch(Throwable t) {
+                if (failed != null) t.addSuppressed(failed);
+                throw t;
+             }
         }
         if (failed != null) {
             // should rarely happen...
             throw new RuntimeException(failed);
         }
< prev index next >