I need some help to get that fixed. It seems that there are a lot of
subtleties in that part of the code. Can you help?

Thank you,
Gary

On Thu, Sep 1, 2016 at 2:32 PM, Ralph Goers <[email protected]>
wrote:

> Yeah, that looks wrong.
>
> Ralph
>
> On Sep 1, 2016, at 2:18 PM, Gary Gregory <[email protected]> wrote:
>
> Hi,
>
> I think we have some kind of discrepancy in org.apache.logging.log4j.core.
> Logger between:
>
>     /**
>      * This method is not exposed through the public API and is used
> primarily for unit testing.
>      *
>      * @param appender The Appender to add to the Logger.
>      */
>     public void addAppender(final Appender appender) {
>         privateConfig.config.addLoggerAppender(this, appender);
>     }
>
> and:
>
>     /**
>      * This method is not exposed through the public API and is used
> primarily for unit testing.
>      *
>      * @param appender The Appender to remove from the Logger.
>      */
>     public void removeAppender(final Appender appender) {
>         privateConfig.loggerConfig.removeAppender(appender.getName());
>     }
>
> Because, when in individual test methods in
>
> org.apache.logging.log4j.core.appender.SocketAppenderTest
>
> We do calls like
>
> root.addAppender(newAppender)
>
> and in the @After teardown method we do:
>
> root.removeAppender(appender);
>
> But that does not remove the appender from the 'appenders' map
> in org.apache.logging.log4j.core.config.AbstractConfiguration. So the
> next time you try to add a fresh appender in the next test, the code in
> addLoggerAppender calls putIfAbsent and since it is still there, the old
> closed appender is used and tests fail.
>
> I have some new tests locally that are not committed that show this
> problem.
>
> To see it you can simply duplicate the method testTcpAppender() as
> testTcpAppender2() and boom!
>
> Gary
>
>
> --
> E-Mail: [email protected] | [email protected]
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>
>
>


-- 
E-Mail: [email protected] | [email protected]
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Reply via email to