You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "William Burns (JIRA)" <ji...@apache.org> on 2013/01/11 21:14:15 UTC

[jira] [Created] (LOG4J2-147) ThreadContextMapFilter doesn't match properly when a single keyvalue is provided

William Burns created LOG4J2-147:
------------------------------------

             Summary: ThreadContextMapFilter doesn't match properly when a single keyvalue is provided
                 Key: LOG4J2-147
                 URL: https://issues.apache.org/jira/browse/LOG4J2-147
             Project: Log4j 2
          Issue Type: Bug
          Components: Filters
    Affects Versions: 2.0-beta3
            Reporter: William Burns


I was testing out a global ThreadContextMapFilter and noticed it wasn't matching properly.  I took a closer look at the code and found because it wasn't matching the value to the value on the context but rather the key.

I changed it to use the value as the argument to equals and this fixed it.  Here is the diff of what I am running with.


diff --git a/core/src/main/java/org/apache/logging/log4j/core/filter/ThreadContextMapFilter.java b/core/src/main/java/org/apache/logging/log4j/core/filter/ThreadContextMapFilter.java
index 9ad6cab..b3f3838 100644
--- a/core/src/main/java/org/apache/logging/log4j/core/filter/ThreadContextMapFi
+++ b/core/src/main/java/org/apache/logging/log4j/core/filter/ThreadContextMapFilter.java
@@ -96,7 +96,7 @@ public class ThreadContextMapFilter extends MapFilter {
                 }
             }
         } else {
-            match = key.equals(ThreadContext.get(key));
+            match = value.equals(ThreadContext.get(key));
         }
         return match ? onMatch : onMismatch;
     }



--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org