logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattsic...@apache.org
Subject svn commit: r1608344 - /logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java
Date Mon, 07 Jul 2014 06:20:45 GMT
Author: mattsicker
Date: Mon Jul  7 06:20:45 2014
New Revision: 1608344

URL: http://svn.apache.org/r1608344
Log:
Increase scope of shutdown lock to address thread safety concern in LOG4J2-702.

Modified:
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java?rev=1608344&r1=1608343&r2=1608344&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java
Mon Jul  7 06:20:45 2014
@@ -370,20 +370,22 @@ public class LoggerConfig extends Abstra
      * loggerConfig.
      */
     private void waitForCompletion() {
-        if (shutdown.compareAndSet(false, true)) {
-            int retries = 0;
-            while (counter.get() > 0) {
-                shutdownLock.lock();
-                try {
-                    noLogEvents.await(retries + 1, TimeUnit.SECONDS);
-                } catch (final InterruptedException ie) {
-                    if (++retries > MAX_RETRIES) {
-                        break;
+        shutdownLock.lock();
+        try {
+            if (shutdown.compareAndSet(false, true)) {
+                int retries = 0;
+                while (counter.get() > 0) {
+                    try {
+                        noLogEvents.await(retries + 1, TimeUnit.SECONDS);
+                    } catch (final InterruptedException ie) {
+                        if (++retries > MAX_RETRIES) {
+                            break;
+                        }
                     }
-                } finally {
-                    shutdownLock.unlock();
                 }
             }
+        } finally {
+            shutdownLock.unlock();
         }
     }
 



Mime
View raw message