8146665: Test jdk/test/java/util/logging/LogManager/Configuration/updateConfiguration/UpdateConfigurationTest.java fails - missing expected output
authordfuchs
Mon, 11 Jan 2016 18:30:14 +0100
changeset 34946 33b5b6fa6f5a
parent 34945 177014e6bc13
child 34947 e937e10e46f7
8146665: Test jdk/test/java/util/logging/LogManager/Configuration/updateConfiguration/UpdateConfigurationTest.java fails - missing expected output Summary: increases numbers of gc loops and fix finally {} clause to get a better diagnostic Reviewed-by: mchung
jdk/test/java/util/logging/LogManager/Configuration/updateConfiguration/UpdateConfigurationTest.java
--- a/jdk/test/java/util/logging/LogManager/Configuration/updateConfiguration/UpdateConfigurationTest.java	Mon Jan 11 11:39:12 2016 -0500
+++ b/jdk/test/java/util/logging/LogManager/Configuration/updateConfiguration/UpdateConfigurationTest.java	Mon Jan 11 18:30:14 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -209,8 +209,9 @@
                     + barChild.getParent() +"\n\texpected: " + barRef.get());
         }
         Reference<? extends Logger> ref2;
-        int max = 3;
+        int max = 10;
         barChild = null;
+        System.gc();
         while ((ref2 = queue.poll()) == null) {
             System.gc();
             Thread.sleep(100);
@@ -276,24 +277,27 @@
                     }
                 });
 
-                // Now we need to forget the child, so that loggers are released,
-                // and so that we can run the test with the next configuration...
-
-                fooChild = null;
-                System.out.println("Setting fooChild to: " + fooChild);
-                while ((ref2 = queue.poll()) == null) {
-                    System.gc();
-                    Thread.sleep(1000);
+                if (suppressed == null) {
+                    // Now we need to forget the child, so that loggers are released,
+                    // and so that we can run the test with the next configuration...
+                    // No need to do that if failed!=null however, as the first
+                    // ref might not have been cleared yet and failing here would
+                    // hide the original failure.
+                    fooChild = null;
+                    System.out.println("Setting fooChild to: " + fooChild);
+                    while ((ref2 = queue.poll()) == null) {
+                        System.gc();
+                        Thread.sleep(1000);
+                    }
+                    if (ref2 != fooRef) {
+                        throw new RuntimeException("Unexpected reference: "
+                                + ref2 +"\n\texpected: " + fooRef);
+                    }
+                    if (ref2.get() != null) {
+                        throw new RuntimeException("Referent not cleared: " + ref2.get());
+                    }
+                    System.out.println("Got fooRef after reset(), fooChild is " + fooChild);
                 }
-                if (ref2 != fooRef) {
-                    throw new RuntimeException("Unexpected reference: "
-                            + ref2 +"\n\texpected: " + fooRef);
-                }
-                if (ref2.get() != null) {
-                    throw new RuntimeException("Referent not cleared: " + ref2.get());
-                }
-                System.out.println("Got fooRef after reset(), fooChild is " + fooChild);
-
             }
         }
         if (failed != null) {