8222027: java/util/logging/LogManager/TestLoggerNames.java generates intermittent ClassCastException
authorsgroeger
Mon, 08 Apr 2019 15:01:39 +0100
changeset 54459 e5713cefcf41
parent 54458 0608ef3a7740
child 54460 6733a9176cce
8222027: java/util/logging/LogManager/TestLoggerNames.java generates intermittent ClassCastException Summary: Make a strong reference to TestLogger and dont fetch it from LogManager Reviewed-by: dfuchs
test/jdk/java/util/logging/LogManager/TestLoggerNames.java
--- a/test/jdk/java/util/logging/LogManager/TestLoggerNames.java	Mon Apr 08 18:42:29 2019 +0200
+++ b/test/jdk/java/util/logging/LogManager/TestLoggerNames.java	Mon Apr 08 15:01:39 2019 +0100
@@ -133,7 +133,8 @@
 
 
     public static void main(String[] args) throws InterruptedException {
-        LogManager.getLogManager().addLogger(new TestLogger("com.foo.bar.zzz", null));
+        TestLogger test = new TestLogger("com.foo.bar.zzz", null);
+        LogManager.getLogManager().addLogger(test);
         try {
             Logger.getLogger(null);
             throw new RuntimeException("Logger.getLogger(null) didn't throw expected NPE");
@@ -144,7 +145,9 @@
         loggers.add(Logger.getLogger("one.two.addMeAChild"));
         loggers.add(Logger.getLogger("aaa.bbb.replaceMe"));
         loggers.add(Logger.getLogger("bbb.aaa.addMeAChild"));
-        TestLogger test = (TestLogger)Logger.getLogger("com.foo.bar.zzz");
+        if (test != Logger.getLogger("com.foo.bar.zzz")) {
+            throw new AssertionError("wrong logger returned");
+        }
         loggers.add(Logger.getLogger("ddd.aaa.addMeAChild"));
 
         checkLoggerNames(loggers);