changeset 9247:5c5c0a24b34b

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 dc0edff71f1c
children b134e98b4943
files test/java/util/logging/SimpleLogManager.java
diffstat 1 files changed, 3 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/test/java/util/logging/SimpleLogManager.java	Wed Feb 05 10:59:55 2014 -0500
+++ b/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;
         }
     }
 }