--- old/src/java.logging/share/classes/java/util/logging/LogManager.java 2015-07-31 12:27:57.000000000 +0200 +++ new/src/java.logging/share/classes/java/util/logging/LogManager.java 2015-07-31 12:27:56.000000000 +0200 @@ -353,7 +353,8 @@ // see that initializationDone is still false, and perform the // initialization. // - synchronized(this) { + configurationLock.lock(); + try { // If initializedCalled is true it means that we're already in // the process of initializing the LogManager in this thread. // There has been a recursive call to ensureLogManagerInitialized(). @@ -378,6 +379,17 @@ // We use initializedCalled to break the recursion. initializedCalled = true; try { +// // TODO: remove this before pushing +// // Hacky sleep that makes it possible to reproduce 8132550 +// // consistently. see also reset(). +// if (!(Thread.currentThread() instanceof Cleaner)) { +// try { +// // System.err.println("Initializing thread sleeping 2000L"); +// Thread.sleep(2000L); +// } catch (InterruptedException ex) { +// ex.printStackTrace(); +// } +// } AccessController.doPrivileged(new PrivilegedAction() { @Override public Object run() { @@ -409,6 +421,8 @@ } finally { initializationDone = true; } + } finally { + configurationLock.unlock(); } } @@ -423,33 +437,22 @@ return manager; } - private void readPrimordialConfiguration() { + private void readPrimordialConfiguration() { // must be called while holding configurationLock if (!readPrimordialConfiguration) { - synchronized (this) { - if (!readPrimordialConfiguration) { - // If System.in/out/err are null, it's a good - // indication that we're still in the - // bootstrapping phase - if (System.out == null) { - return; - } - readPrimordialConfiguration = true; + // If System.in/out/err are null, it's a good + // indication that we're still in the + // bootstrapping phase + if (System.out == null) { + return; + } + readPrimordialConfiguration = true; + try { + readConfiguration(); - try { - AccessController.doPrivileged(new PrivilegedExceptionAction() { - @Override - public Void run() throws Exception { - readConfiguration(); - - // Platform loggers begin to delegate to java.util.logging.Logger - sun.util.logging.PlatformLogger.redirectPlatformLoggers(); - return null; - } - }); - } catch (Exception ex) { - assert false : "Exception raised while reading logging configuration: " + ex; - } - } + // Platform loggers begin to delegate to java.util.logging.Logger + sun.util.logging.PlatformLogger.redirectPlatformLoggers(); + } catch (Exception ex) { + assert false : "Exception raised while reading logging configuration: " + ex; } } } @@ -1328,6 +1331,19 @@ // to run in parallel configurationLock.lock(); try { + +// // TODO: remove this before pushing +// // Hacky sleep that makes it possible to reproduce 8132550 +// // consistently. see also ensureLogManagerInitialized(). +// if (Thread.currentThread() instanceof Cleaner) { +// try { +// // System.err.println("Cleaner Thread sleeping 5000L"); +// Thread.sleep(5000L); +// } catch (InterruptedException ex) { +// ex.printStackTrace(); +// } +// } + // install new empty properties props = new Properties(); // make sure we keep the loggers persistent until reset is done. --- old/test/java/util/logging/LoggingDeadlock2.java 2015-07-31 12:27:57.000000000 +0200 +++ new/test/java/util/logging/LoggingDeadlock2.java 2015-07-31 12:27:57.000000000 +0200 @@ -23,7 +23,7 @@ /* * @test - * @bug 6467152 6716076 6829503 + * @bug 6467152 6716076 6829503 8132550 * @summary deadlock occurs in LogManager initialization and JVM termination * @author Serguei Spitsyn / Hitachi / Martin Buchholz *