logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1479050 - in /logging/log4j/log4j2/trunk: core/src/main/java/org/apache/logging/log4j/core/filter/RegexFilter.java core/src/test/java/org/apache/logging/log4j/core/filter/RegexFilterTest.java src/changes/changes.xml
Date Sat, 04 May 2013 06:58:30 GMT
Author: rgoers
Date: Sat May  4 06:58:30 2013
New Revision: 1479050

URL: http://svn.apache.org/r1479050
Log:
LOG4J2-234 - RegexFilter threw a NullPointerException when used as a context-wide filter.

Modified:
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/filter/RegexFilter.java
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/filter/RegexFilterTest.java
    logging/log4j/log4j2/trunk/src/changes/changes.xml

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/filter/RegexFilter.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/filter/RegexFilter.java?rev=1479050&r1=1479049&r2=1479050&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/filter/RegexFilter.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/filter/RegexFilter.java
Sat May  4 06:58:30 2013
@@ -57,12 +57,18 @@ public final class RegexFilter extends A
     @Override
     public Result filter(final Logger logger, final Level level, final Marker marker, final
Object msg,
                          final Throwable t) {
+        if (msg == null) {
+            return onMismatch;
+        }
         return filter(msg.toString());
     }
 
     @Override
     public Result filter(final Logger logger, final Level level, final Marker marker, final
Message msg,
                          final Throwable t) {
+        if (msg == null) {
+            return onMismatch;
+        }
         final String text = useRawMessage ? msg.getFormat() : msg.getFormattedMessage();
         return filter(text);
     }

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/filter/RegexFilterTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/filter/RegexFilterTest.java?rev=1479050&r1=1479049&r2=1479050&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/filter/RegexFilterTest.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/filter/RegexFilterTest.java
Sat May  4 06:58:30 2013
@@ -20,6 +20,7 @@ import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.core.Filter;
 import org.apache.logging.log4j.core.impl.Log4jLogEvent;
 import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.message.Message;
 import org.apache.logging.log4j.message.SimpleMessage;
 import org.apache.logging.log4j.status.StatusLogger;
 import org.junit.BeforeClass;
@@ -51,4 +52,15 @@ public class RegexFilterTest {
         filter = RegexFilter.createFilter("* test *", null, null, null);
         assertNull(filter);
     }
+
+    @Test
+    public void TestNoMsg() {
+        RegexFilter filter = RegexFilter.createFilter(".* test .*", null, null, null);
+        filter.start();
+        assertTrue(filter.isStarted());
+        assertTrue(filter.filter(null, Level.DEBUG, null, (String)null, (Throwable)null)
== Filter.Result.DENY);
+        assertTrue(filter.filter(null, Level.DEBUG, null, (Message)null, (Throwable)null)
== Filter.Result.DENY);
+        assertTrue(filter.filter(null, Level.DEBUG, null, null, (Object[])null) == Filter.Result.DENY);
+
+    }
 }

Modified: logging/log4j/log4j2/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/changes/changes.xml?rev=1479050&r1=1479049&r2=1479050&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/changes/changes.xml (original)
+++ logging/log4j/log4j2/trunk/src/changes/changes.xml Sat May  4 06:58:30 2013
@@ -23,6 +23,9 @@
 
   <body>
     <release version="2.0-beta6" date="@TBD@" description="Bug fixes and enhancements">
+      <action issue="LOG4J2-234" dev="rgoers" type="fix">
+        RegexFilter threw a NullPointerException when used as a context-wide filter.
+      </action>
       <action issue="LOG4J2-192" dev="rgoers" type="fix">
         Add support for interpolating Environment variables when processing the configuration.
       </action>



Mime
View raw message