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