test/java/util/logging/LoggingDeadlock4.java

Print this page

        

*** 21,35 **** * questions. */ /* * @test ! * @bug 6977677 * @summary Deadlock between LogManager.<clinit> and Logger.getLogger() * @author Daniel D. Daugherty ! * @build LoggingDeadlock4 ! * @run main/othervm/timeout=15 -Djava.awt.headless=true LoggingDeadlock4 */ import java.util.concurrent.CountDownLatch; import java.util.logging.LogManager; import java.util.logging.Logger; --- 21,35 ---- * questions. */ /* * @test ! * @bug 6977677 8004928 * @summary Deadlock between LogManager.<clinit> and Logger.getLogger() * @author Daniel D. Daugherty ! * @compile -XDignore.symbol.file LoggingDeadlock4.java ! * @run main/othervm/timeout=15 LoggingDeadlock4 */ import java.util.concurrent.CountDownLatch; import java.util.logging.LogManager; import java.util.logging.Logger;
*** 37,60 **** public class LoggingDeadlock4 { private static CountDownLatch barrier = new CountDownLatch(1); private static CountDownLatch lmIsRunning = new CountDownLatch(1); private static CountDownLatch logIsRunning = new CountDownLatch(1); ! public static void main(String[] args) { ! System.out.println("main: LoggingDeadlock4 is starting."); ! ! // Loading the java.awt.Container class will create a ! // sun.util.logging.PlatformLogger$JavaLogger object // that has to be redirected when the LogManager class // is initialized. This can cause a deadlock between // LogManager.<clinit> and Logger.getLogger(). ! try { ! Class.forName("java.awt.Container"); ! } catch (ClassNotFoundException cnfe) { ! throw new RuntimeException("Test failed: could not load" ! + " java.awt.Container." + cnfe); ! } Thread lmThread = new Thread("LogManagerThread") { public void run() { // let main know LogManagerThread is running lmIsRunning.countDown(); --- 37,55 ---- public class LoggingDeadlock4 { private static CountDownLatch barrier = new CountDownLatch(1); private static CountDownLatch lmIsRunning = new CountDownLatch(1); private static CountDownLatch logIsRunning = new CountDownLatch(1); ! // Create a sun.util.logging.PlatformLogger$JavaLogger object // that has to be redirected when the LogManager class // is initialized. This can cause a deadlock between // LogManager.<clinit> and Logger.getLogger(). ! private static final sun.util.logging.PlatformLogger log = ! sun.util.logging.PlatformLogger.getLogger("java.util.logging"); ! ! public static void main(String[] args) { ! System.out.println("main: LoggingDeadlock4 is starting."); Thread lmThread = new Thread("LogManagerThread") { public void run() { // let main know LogManagerThread is running lmIsRunning.countDown();