changeset 22655:7de4fe0b8488

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
author dfuchs
date Wed, 05 Feb 2014 17:56:04 +0100
parents da81e0be094a
children b8ee81ac6fb3
files jdk/test/java/util/logging/SimpleLogManager.java
diffstat 1 files changed, 3 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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;
         }
     }
 }