logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rpo...@apache.org
Subject svn commit: r1617298 - in /logging/log4j/log4j2/trunk: log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/FileRenameAction.java src/changes/changes.xml
Date Mon, 11 Aug 2014 14:38:02 GMT
Author: rpopma
Date: Mon Aug 11 14:38:02 2014
New Revision: 1617298

URL: http://svn.apache.org/r1617298
Log:
LOG4J2-679: ignore mkdirs() result, instead check if resulting directory exists to avoid race
condition.

Modified:
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/FileRenameAction.java
    logging/log4j/log4j2/trunk/src/changes/changes.xml

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/FileRenameAction.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/FileRenameAction.java?rev=1617298&r1=1617297&r2=1617298&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/FileRenameAction.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/FileRenameAction.java
Mon Aug 11 14:38:02 2014
@@ -77,7 +77,11 @@ public class FileRenameAction extends Ab
         if (renameEmptyFiles || source.length() > 0) {
             final File parent = destination.getParentFile();
             if (parent != null && !parent.exists()) {
-                if (!parent.mkdirs()) {
+                // LOG4J2-679: ignore mkdirs() result: in multithreaded scenarios,
+                // if one thread succeeds the other thread returns false
+                // even though directories have been created. Check if dir exists instead.
+                parent.mkdirs();
+                if (!parent.exists()) {
                     LOGGER.error("Unable to create directory {}", parent.getAbsolutePath());
                     return false;
                 }

Modified: logging/log4j/log4j2/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/changes/changes.xml?rev=1617298&r1=1617297&r2=1617298&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/changes/changes.xml (original)
+++ logging/log4j/log4j2/trunk/src/changes/changes.xml Mon Aug 11 14:38:02 2014
@@ -22,6 +22,9 @@
   </properties>
   <body>
     <release version="2.0.2" date="2014-0?-??" description="Bug fixes and enhancements">
+      <action issue="LOG4J2-679" dev="rpopma" type="fix">
+        Resolved race condition that caused log file rotation to fail with error: "Unable
to create directory ..."
+      </action>
       <action issue="LOG4J2-726" dev="rpopma" type="fix">
         Prevent application from hanging when PatternLayout configuration has opening '{'
but no closing '}'.
       </action>



Mime
View raw message