[jira] [Closed] (LOG4J2-1511) DynamicThresholdFilter filters incorrectly when params are passed as individual arguments instead of varargs

2016-09-18 Thread Remko Popma (JIRA)

 [ 
https://issues.apache.org/jira/browse/LOG4J2-1511?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Remko Popma closed LOG4J2-1511.
---
Resolution: Fixed

> DynamicThresholdFilter filters incorrectly when params are passed as 
> individual arguments instead of varargs
> 
>
> Key: LOG4J2-1511
> URL: https://issues.apache.org/jira/browse/LOG4J2-1511
> Project: Log4j 2
>  Issue Type: Bug
>Affects Versions: 2.6.2
>Reporter: srikanth surukuntu
> Fix For: 2.7
>
>
> The below test should summarize the issue.
> {code}
> package org.apache.logging.log4j.core.filter;
> import static org.junit.Assert.assertSame;
> import static org.junit.Assert.assertTrue;
> import org.apache.logging.log4j.Level;
> import org.apache.logging.log4j.ThreadContext;
> import org.apache.logging.log4j.core.Filter;
> import org.apache.logging.log4j.core.LoggerContext;
> import org.apache.logging.log4j.core.util.KeyValuePair;
> import org.apache.logging.log4j.status.StatusLogger;
> import org.junit.After;
> import org.junit.Test;
> /**
>  *
>  */
> public class DynamicThresholdFilterTest {
> @After
> public void cleanup() {
> final LoggerContext ctx = LoggerContext.getContext(false);
> ctx.reconfigure();
> StatusLogger.getLogger().reset();
> }
> @Test
> public void testFilter() {
> ThreadContext.put("userid", "testuser");
> ThreadContext.put("organization", "apache");
> final KeyValuePair[] pairs = new KeyValuePair[] {
> new KeyValuePair("testuser", "DEBUG"),
> new KeyValuePair("JohnDoe", "warn") };
> final DynamicThresholdFilter filter = 
> DynamicThresholdFilter.createFilter("userid", pairs, Level.ERROR, 
> Filter.Result.ACCEPT, Filter.Result.NEUTRAL);
> filter.start();
> assertTrue(filter.isStarted());
> Object [] replacements = {"one", "two", "three"};
> assertSame(Filter.Result.ACCEPT, filter.filter(null, Level.DEBUG, 
> null, "some test message", replacements)); // Works
> assertSame(Filter.Result.ACCEPT, filter.filter(null, Level.DEBUG, 
> null, "some test message", "one", "two", "three")); // Doesn't work but it 
> should
> ThreadContext.clearMap();
> }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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



[jira] [Closed] (LOG4J2-1511) DynamicThresholdFilter filters incorrectly when params are passed as individual arguments instead of varargs

2016-08-26 Thread srikanth surukuntu (JIRA)

 [ 
https://issues.apache.org/jira/browse/LOG4J2-1511?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

srikanth surukuntu closed LOG4J2-1511.
--

fixed 

> DynamicThresholdFilter filters incorrectly when params are passed as 
> individual arguments instead of varargs
> 
>
> Key: LOG4J2-1511
> URL: https://issues.apache.org/jira/browse/LOG4J2-1511
> Project: Log4j 2
>  Issue Type: Bug
>Affects Versions: 2.6.2
>Reporter: srikanth surukuntu
> Fix For: 2.7
>
>
> The below test should summarize the issue.
> {code}
> package org.apache.logging.log4j.core.filter;
> import static org.junit.Assert.assertSame;
> import static org.junit.Assert.assertTrue;
> import org.apache.logging.log4j.Level;
> import org.apache.logging.log4j.ThreadContext;
> import org.apache.logging.log4j.core.Filter;
> import org.apache.logging.log4j.core.LoggerContext;
> import org.apache.logging.log4j.core.util.KeyValuePair;
> import org.apache.logging.log4j.status.StatusLogger;
> import org.junit.After;
> import org.junit.Test;
> /**
>  *
>  */
> public class DynamicThresholdFilterTest {
> @After
> public void cleanup() {
> final LoggerContext ctx = LoggerContext.getContext(false);
> ctx.reconfigure();
> StatusLogger.getLogger().reset();
> }
> @Test
> public void testFilter() {
> ThreadContext.put("userid", "testuser");
> ThreadContext.put("organization", "apache");
> final KeyValuePair[] pairs = new KeyValuePair[] {
> new KeyValuePair("testuser", "DEBUG"),
> new KeyValuePair("JohnDoe", "warn") };
> final DynamicThresholdFilter filter = 
> DynamicThresholdFilter.createFilter("userid", pairs, Level.ERROR, 
> Filter.Result.ACCEPT, Filter.Result.NEUTRAL);
> filter.start();
> assertTrue(filter.isStarted());
> Object [] replacements = {"one", "two", "three"};
> assertSame(Filter.Result.ACCEPT, filter.filter(null, Level.DEBUG, 
> null, "some test message", replacements)); // Works
> assertSame(Filter.Result.ACCEPT, filter.filter(null, Level.DEBUG, 
> null, "some test message", "one", "two", "three")); // Doesn't work but it 
> should
> ThreadContext.clearMap();
> }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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