You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
appender can't be added to AsyncAppender after being detached.
2. reproduce and test case
add following test in AsyncAppenderBaseTest
@Test
@Timeout(value=2, unit = TimeUnit.SECONDS)
public void appenderShouldBeAddedSuccessfullyAfterDetachedByReference() {
asyncAppenderBase.addAppender(listAppender);
asyncAppenderBase.start();
asyncAppenderBase.doAppend(0);
asyncAppenderBase.detachAppender(listAppender);
asyncAppenderBase.addAppender(listAppender);
asyncAppenderBase.doAppend(0);
asyncAppenderBase.stop();
verify(listAppender, 2);
}
3. cause
the value of property "appenderCount" does't decrease in method "detachAppender", the value is 1 after first addAppender, and still 1 after detachAppender, so when addAppender again, it goes into "else".
public void addAppender(Appender<E> newAppender) {
if (appenderCount == 0) {
appenderCount++;
addInfo("Attaching appender named [" + newAppender.getName() + "] to AsyncAppender.");
aai.addAppender(newAppender);
} else {
addWarn("One and only one appender may be attached to AsyncAppender.");
addWarn("Ignoring additional appender named [" + newAppender.getName() + "]");
}
}
The text was updated successfully, but these errors were encountered:
wsliliang
added a commit
to wsliliang/logback
that referenced
this issue
Nov 2, 2023
1. behavior
appender can't be added to AsyncAppender after being detached.
2. reproduce and test case
add following test in AsyncAppenderBaseTest
3. cause
the value of property "appenderCount" does't decrease in method "detachAppender", the value is 1 after first addAppender, and still 1 after detachAppender, so when addAppender again, it goes into "else".
The text was updated successfully, but these errors were encountered: