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
--- 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);