[ 
https://issues.apache.org/jira/browse/LOG4J2-997?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14510482#comment-14510482
 ] 

Gary Gregory commented on LOG4J2-997:
-------------------------------------

I'm note quite sure what to make of this proposed change. Yes, there are 
problems in filters now.

If you just apply the patch for the new test class only and run it, we do have 
at least this problem:

{noformat}
java.lang.ClassCastException: 
org.apache.logging.log4j.core.filter.ThresholdFilter cannot be cast to 
org.apache.logging.log4j.core.filter.CompositeFilter
        at 
org.apache.logging.log4j.core.filter.AbstractFilterable.addFilter(AbstractFilterable.java:62)
        at 
org.apache.logging.log4j.core.filter.AbstractFilterableTest.testAddSimpleFilterAndCompositeFilter(AbstractFilterableTest.java:161)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at 
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
        at 
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at 
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
        at 
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at 
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
        at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
        at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
        at 
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
        at 
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
{noformat}

Which is obvious if you look at:

{code:java}
    public synchronized void addFilter(final Filter filter) {
        if (this.filter == null) {
            this.filter = filter;
        } else if (filter instanceof CompositeFilter) {
            this.filter = ((CompositeFilter) this.filter).addFilter(filter);
        } else {
            final Filter[] filters = new Filter[] {this.filter, filter};
            this.filter = CompositeFilter.createFilters(filters);
        }
    }
{code}

and walk through adding a plain filter followed by a composite filter. So that 
needs to be fixed by adding the missing {{this.}}

When I look at all the new tests, I wonder what the original goal was for 
composite filters beyond a list.

Would it be simpler for AbstractFilterable to hold on to a CompositeFilter?

Anyway, I probably should not have looked at this now, late at night... ;-)

> removeFilter() in AbstractFilterable does not remove filter
> -----------------------------------------------------------
>
>                 Key: LOG4J2-997
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-997
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.2
>            Reporter: Maytee Chinavanichkit
>
> Add two filters to a class that implements AbstractFilterable. Try to remove 
> one of the two filters; nothing is removed.



--
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

Reply via email to