You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rg...@apache.org on 2012/08/31 05:26:05 UTC

svn commit: r1379273 - in /logging/log4j/log4j2/trunk: core/src/main/java/org/apache/logging/log4j/core/appender/rolling/ core/src/test/java/org/apache/logging/log4j/core/appender/rolling/ core/src/test/resources/ src/changes/

Author: rgoers
Date: Fri Aug 31 03:26:04 2012
New Revision: 1379273

URL: http://svn.apache.org/viewvc?rev=1379273&view=rev
Log:
Fix LOG4J-72 - NullPointerException when the filePattern does not end with .gz or .zip

Added:
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderUncompressedTest.java
      - copied, changed from r1374809, logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java
    logging/log4j/log4j2/trunk/core/src/test/resources/log4j-rolling4.xml
      - copied, changed from r1374809, logging/log4j/log4j2/trunk/core/src/test/resources/log4j-rolling1.xml
Modified:
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java
    logging/log4j/log4j2/trunk/src/changes/changes.xml

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java?rev=1379273&r1=1379272&r2=1379273&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java (original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java Fri Aug 31 03:26:04 2012
@@ -142,7 +142,7 @@ public class RollingFileManager extends 
                     }
                 }
 
-                if (success) {
+                if (success && descriptor.getAsynchronous() != null) {
                     thread = new Thread(new AsyncAction(descriptor.getAsynchronous(), this));
                     thread.start();
                 }

Copied: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderUncompressedTest.java (from r1374809, logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java)
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderUncompressedTest.java?p2=logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderUncompressedTest.java&p1=logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java&r1=1374809&r2=1379273&rev=1379273&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java (original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderUncompressedTest.java Fri Aug 31 03:26:04 2012
@@ -21,25 +21,23 @@ import org.apache.logging.log4j.core.Log
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
 import org.apache.logging.log4j.status.StatusLogger;
-import org.junit.Test;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
+import org.junit.Test;
 
 import java.io.File;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 /**
  *
  */
-public class RollingAppenderSizeTest {
+public class RollingAppenderUncompressedTest {
 
-    private static final String CONFIG = "log4j-rolling1.xml";
-    private static final String DIR = "target/rolling1";
+    private static final String CONFIG = "log4j-rolling4.xml";
+    private static final String DIR = "target/rolling4";
 
-    org.apache.logging.log4j.Logger logger = LogManager.getLogger(RollingAppenderSizeTest.class.getName());
+    org.apache.logging.log4j.Logger logger = LogManager.getLogger(RollingAppenderUncompressedTest.class.getName());
 
     @BeforeClass
     public static void setupClass() {
@@ -51,7 +49,7 @@ public class RollingAppenderSizeTest {
 
     @AfterClass
     public static void cleanupClass() {
-        deleteDir();
+        //deleteDir();
         System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
         LoggerContext ctx = (LoggerContext) LogManager.getContext();
         ctx.reconfigure();
@@ -69,11 +67,12 @@ public class RollingAppenderSizeTest {
         assertTrue("No files created", files.length > 0);
         boolean found = false;
         for (File file : files) {
-            if (file.getName().endsWith(".gz")) {
+            String name = file.getName();
+            if (name.startsWith("test1") && name.endsWith(".log")) {
                 found = true;
             }
         }
-        assertTrue("No compressed files found", found);
+        assertTrue("No archived files found", found);
     }
 
     private static void deleteDir() {

Copied: logging/log4j/log4j2/trunk/core/src/test/resources/log4j-rolling4.xml (from r1374809, logging/log4j/log4j2/trunk/core/src/test/resources/log4j-rolling1.xml)
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/resources/log4j-rolling4.xml?p2=logging/log4j/log4j2/trunk/core/src/test/resources/log4j-rolling4.xml&p1=logging/log4j/log4j2/trunk/core/src/test/resources/log4j-rolling1.xml&r1=1374809&r2=1379273&rev=1379273&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/resources/log4j-rolling1.xml (original)
+++ logging/log4j/log4j2/trunk/core/src/test/resources/log4j-rolling4.xml Fri Aug 31 03:26:04 2012
@@ -18,7 +18,7 @@
 -->
 <configuration status="warn" name="XMLConfigTest" packages="org.apache.logging.log4j.test">
   <properties>
-    <property name="filename">target/rolling1/rollingtest.log</property>
+    <property name="filename">target/rolling4/rollingtest.log</property>
   </properties>
   <ThresholdFilter level="debug"/>
 
@@ -27,7 +27,7 @@
       <PatternLayout pattern="%m%n"/>
     </Console>
     <RollingFile name="RollingFile" fileName="${filename}"
-                 filePattern="target/rolling1/test1-$${date:MM-dd-yyyy}-%i.log.gz">
+                 filePattern="target/rolling4/test1-$${date:MM-dd-yyyy}-%i.log">
       <PatternLayout>
         <pattern>%d %p %C{1.} [%t] %m%n</pattern>
       </PatternLayout>

Modified: logging/log4j/log4j2/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/changes/changes.xml?rev=1379273&r1=1379272&r2=1379273&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/changes/changes.xml (original)
+++ logging/log4j/log4j2/trunk/src/changes/changes.xml Fri Aug 31 03:26:04 2012
@@ -23,12 +23,15 @@
 
   <body>
     <release version="2.0-alpha3" date="TBD" description="">
-      <action dev="rgoers" type="update">
-        Update the versions of SLF4J and Logback.
+      <action issue="LOG4J2-72" dev="rgoers" type="fix">
+        NullPointerException in RollingFileManager when filePattern does not cause the file to be compressed.
       </action>
       <action issue="LOG4J2-71" dev="rgoers" type="fix">
         FileRenameAction did not create the parent directories of the archive files causing the rollover to fail.
       </action>
+      <action dev="rgoers" type="update">
+        Update the versions of SLF4J and Logback.
+      </action>
     </release>
     <release version="2.0-alpha2" date="2012-08-24" description="Bug fixes and minor enhancements">
       <action issue="LOG4J2-70" dev="rgoers" type="add">