changeset 36135:047c192e2671

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
author dfuchs
date Fri, 26 Feb 2016 12:11:28 +0100
parents 63514f38c74c
children 564116a434fa 046733577670 19c7bd1d11cd
files jdk/test/java/util/logging/LogManagerAppContextDeadlock.java
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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)");
             }
         };