8132550: java/util/logging/LoggingDeadlock2.java times out
Summary: LogManager must also use the configurationLock when reading its primordial configuration.
Reviewed-by: joehw
--- a/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java Thu Aug 06 13:59:10 2015 +0300
+++ b/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java Thu Aug 06 16:36:47 2015 +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().
@@ -409,6 +410,8 @@
} finally {
initializationDone = true;
}
+ } finally {
+ configurationLock.unlock();
}
}
@@ -423,33 +426,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<Void>() {
- @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;
}
}
}
--- a/jdk/test/java/util/logging/LoggingDeadlock2.java Thu Aug 06 13:59:10 2015 +0300
+++ b/jdk/test/java/util/logging/LoggingDeadlock2.java Thu Aug 06 16:36:47 2015 +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
*