8033542: test/java/util/logging/SimpleLogManager might let Loggers be gc'ed too early.
authordfuchs
Wed, 05 Feb 2014 17:56:04 +0100
changeset 22655 7de4fe0b8488
parent 22654 da81e0be094a
child 22656 b8ee81ac6fb3
8033542: test/java/util/logging/SimpleLogManager might let Loggers be gc'ed too early. Summary: fix another case of potentially premature Logger garbage collection in tests. Reviewed-by: mchung
jdk/test/java/util/logging/SimpleLogManager.java
--- a/jdk/test/java/util/logging/SimpleLogManager.java	Wed Feb 05 10:59:55 2014 -0500
+++ b/jdk/test/java/util/logging/SimpleLogManager.java	Wed Feb 05 17:56:04 2014 +0100
@@ -98,16 +98,14 @@
             return false;
         }
         CustomLogger newLogger = new CustomLogger(logger);
-        super.addLogger(newLogger);
-        return true;
+        return super.addLogger(newLogger);
     }
 
     public class CustomLogger extends Logger {
+        final Logger keepRef; // keep a strong reference to avoid GC.
         CustomLogger(Logger logger) {
             super(logger.getName(), logger.getResourceBundleName());
-        }
-        CustomLogger(String name) {
-            super(name, null);
+            keepRef = logger;
         }
     }
 }