# HG changeset patch # User sgroeger # Date 1554721668 -3600 # Mon Apr 08 12:07:48 2019 +0100 # Node ID 32121aba8be6467d4e5f1f9953d4977e67227a3c # Parent 0d7fb7f07134a84cdf482038fbcf8298ae180607 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 Contributed-by: Steve Groeger diff --git a/test/jdk/java/util/logging/LogManager/TestLoggerNames.java b/test/jdk/java/util/logging/LogManager/TestLoggerNames.java --- a/test/jdk/java/util/logging/LogManager/TestLoggerNames.java +++ b/test/jdk/java/util/logging/LogManager/TestLoggerNames.java @@ -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);