Skip to content

Commit

Permalink
ongoing work on LOGBACK-1247, with test fail
Browse files Browse the repository at this point in the history
  • Loading branch information
ceki committed Feb 11, 2017
1 parent bdd3952 commit be08427
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
Expand Up @@ -121,7 +121,7 @@ public void stop() {
super.stop();

// interrupt the worker thread so that it can terminate. Note that the interruption can be consumed
// by sub-appenders
// by the sub-appender
worker.interrupt();
try {
worker.join(maxFlushTime);
Expand Down
Expand Up @@ -103,6 +103,7 @@ public void workerShouldStopEvenIfInterruptExceptionConsumedWithinSubappender()
asyncAppenderBase.stop();
verify(delayingListAppender, 1);
assertTrue(delayingListAppender.interrupted);
Thread.interrupted();
}

@Test(timeout = 2000)
Expand Down Expand Up @@ -239,10 +240,29 @@ public void verifyInterruptionIsNotSwallowed() {
Thread.currentThread().interrupt();
asyncAppenderBase.doAppend(new Integer(0));
assertTrue(Thread.currentThread().isInterrupted());
// clear flag for next test
// clear interrupt flag for subsequent tests
Thread.interrupted();
}

// Interruption of current thread should not prevent logging.
// See also http://jira.qos.ch/browse/LOGBACK-910
// and https://jira.qos.ch/browse/LOGBACK-1247
@Test
public void verifyInterruptionDoesNotPreventLogging() {
asyncAppenderBase.addAppender(listAppender);
asyncAppenderBase.start();
asyncAppenderBase.doAppend(new Integer(0));
Thread.currentThread().interrupt();
asyncAppenderBase.doAppend(new Integer(1));
asyncAppenderBase.doAppend(new Integer(1));
assertTrue(Thread.currentThread().isInterrupted());
asyncAppenderBase.stop();
verify(listAppender, 3);
// clear interrupt flag for subsequent tests
Thread.interrupted();
}


@Test
public void verifyInterruptionOfWorkerIsSwallowed() {
asyncAppenderBase.addAppender(delayingListAppender);
Expand Down
Expand Up @@ -29,6 +29,7 @@ public void append(E e) {
try {
Thread.sleep(delay);
} catch (InterruptedException ie) {
// consume InterruptedException
interrupted = true;
}
super.append(e);
Expand Down

0 comments on commit be08427

Please sign in to comment.