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 2013/01/17 04:03:06 UTC

svn commit: r1434543 - in /logging/log4j/log4j2/trunk: core/src/main/java/org/apache/logging/log4j/core/filter/ThreadContextMapFilter.java core/src/test/java/org/apache/logging/log4j/core/filter/ThreadContextMapFilterTest.java src/changes/changes.xml

Author: rgoers
Date: Thu Jan 17 03:03:05 2013
New Revision: 1434543

URL: http://svn.apache.org/viewvc?rev=1434543&view=rev
Log:
LOG4J2-147 - ThreadContextMapFilter was matching on the key instead of the value of the key.

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

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/filter/ThreadContextMapFilter.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/filter/ThreadContextMapFilter.java?rev=1434543&r1=1434542&r2=1434543&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/filter/ThreadContextMapFilter.java (original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/filter/ThreadContextMapFilter.java Thu Jan 17 03:03:05 2013
@@ -96,7 +96,7 @@ public class ThreadContextMapFilter exte
                 }
             }
         } else {
-            match = key.equals(ThreadContext.get(key));
+            match = value.equals(ThreadContext.get(key));
         }
         return match ? onMatch : onMismatch;
     }

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/filter/ThreadContextMapFilterTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/filter/ThreadContextMapFilterTest.java?rev=1434543&r1=1434542&r2=1434543&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/filter/ThreadContextMapFilterTest.java (original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/filter/ThreadContextMapFilterTest.java Thu Jan 17 03:03:05 2013
@@ -57,6 +57,11 @@ public class ThreadContextMapFilterTest 
         assertTrue(filter.filter(null, Level.DEBUG, null, null, (Throwable)null) == Filter.Result.DENY);
         ThreadContext.remove("organization");
         assertTrue(filter.filter(null, Level.DEBUG, null, null, (Throwable)null) == Filter.Result.DENY);
+        final KeyValuePair[] single = new KeyValuePair[] {new KeyValuePair("userid", "testuser")};
+        filter = ThreadContextMapFilter.createFilter(single, null, null, null);
+        filter.start();
+        assertTrue(filter.isStarted());
+        assertTrue(filter.filter(null, Level.DEBUG, null, null, (Throwable)null) == Filter.Result.NEUTRAL);
         ThreadContext.clear();
     }
 }

Modified: logging/log4j/log4j2/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/changes/changes.xml?rev=1434543&r1=1434542&r2=1434543&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/changes/changes.xml (original)
+++ logging/log4j/log4j2/trunk/src/changes/changes.xml Thu Jan 17 03:03:05 2013
@@ -23,6 +23,9 @@
 
   <body>
     <release version="2.0-beta4" date="TBD" description="Bug fixes and enhancements">
+      <action issue="LOG4J2-147" dev="rgoers" type="fix" due-to="William Burns">
+        ThreadContextMapFilter was matching on the key instead of the value of the key.
+      </action>
       <action dev="rgoers" type="fix">
         Allow FlumeAvroManager to initialize even if it cannot connect to an agent.
       </action>