8150533: Test java/util/logging/LogManagerAppContextDeadlock.java times out intermittently.
authordfuchs
Fri, 26 Feb 2016 12:11:28 +0100
changeset 36135 047c192e2671
parent 36134 63514f38c74c
child 36136 564116a434fa
child 36416 046733577670
child 36422 19c7bd1d11cd
8150533: Test java/util/logging/LogManagerAppContextDeadlock.java times out intermittently. Summary: This is a test bug caused by a Logger being garbage collected too early. Reviewed-by: darcy
jdk/test/java/util/logging/LogManagerAppContextDeadlock.java
--- a/jdk/test/java/util/logging/LogManagerAppContextDeadlock.java	Fri Feb 26 06:03:12 2016 +0100
+++ b/jdk/test/java/util/logging/LogManagerAppContextDeadlock.java	Fri Feb 26 12:11:28 2016 +0100
@@ -141,6 +141,7 @@
         t1.setDaemon(true);
         t1.start();
         Thread t2 = new Thread() {
+            public Object logger;
             public void run() {
                 sem3.release();
                 try {
@@ -151,7 +152,10 @@
                     Thread.interrupted();
                 }
                 System.out.println("Logger.getLogger(name).info(name)");
-                Logger.getLogger(test.name());//.info(name);
+                // stick the logger in an instance variable to prevent it
+                // from being garbage collected before the main thread
+                // calls LogManager.getLogger() below.
+                logger = Logger.getLogger(test.name());//.info(name);
                 System.out.println("Done: Logger.getLogger(name).info(name)");
             }
         };