logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1226583 - /logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java
Date Tue, 03 Jan 2012 00:04:25 GMT
Author: rgoers
Date: Tue Jan  3 00:04:24 2012
New Revision: 1226583

URL: http://svn.apache.org/viewvc?rev=1226583&view=rev
Log:
Release semaphore if thread not created

Modified:
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java?rev=1226583&r1=1226582&r2=1226583&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java
Tue Jan  3 00:04:24 2012
@@ -123,14 +123,15 @@ public class RollingFileManager extends 
             return false;
         }
 
-        RolloverDescription descriptor = strategy.rollover(this);
+        boolean success = false;
+        Thread thread = null;
 
-        if (descriptor != null) {
+        try {
+            RolloverDescription descriptor = strategy.rollover(this);
 
-            close();
+            if (descriptor != null) {
 
-            boolean success = false;
-            try {
+                close();
 
                 if (descriptor.getSynchronous() != null) {
 
@@ -142,19 +143,18 @@ public class RollingFileManager extends 
                 }
 
                 if (success) {
-                    Action async = new AsyncAction(descriptor.getAsynchronous(), this);
-                    if (async != null) {
-                        new Thread(async).start();
-                    }
-                }
-            } finally {
-                if (!success && semaphore.availablePermits() == 0) {
-                    semaphore.release();
+                    thread = new Thread(new AsyncAction(descriptor.getAsynchronous(), this));
+                    thread.start();
                 }
+                return true;
+            }
+            return false;
+        } finally {
+            if (thread == null) {
+                semaphore.release();
             }
-            return true;
         }
-        return false;
+
     }
 
     /**



Mime
View raw message