mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Don't warn about background exceptions unless one was thrown.
This commit is contained in:
@@ -4,11 +4,11 @@ import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
||||
import java.lang.Thread.UncaughtExceptionHandler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
|
||||
public abstract class BrambleTestCase {
|
||||
@@ -22,7 +22,7 @@ public abstract class BrambleTestCase {
|
||||
public BrambleTestCase() {
|
||||
// Ensure exceptions thrown on worker threads cause tests to fail
|
||||
UncaughtExceptionHandler fail = (thread, throwable) -> {
|
||||
LOG.log(Level.WARNING, "Caught unhandled exception", throwable);
|
||||
LOG.log(WARNING, "Caught unhandled exception", throwable);
|
||||
exceptionInBackgroundThread = throwable;
|
||||
};
|
||||
Thread.setDefaultUncaughtExceptionHandler(fail);
|
||||
@@ -36,7 +36,11 @@ public abstract class BrambleTestCase {
|
||||
@After
|
||||
public void afterBrambleTestCase() {
|
||||
Throwable thrown = exceptionInBackgroundThread;
|
||||
LOG.warning("background thread has thrown an exception unexpectedly");
|
||||
if (thrown != null) throw new AssertionError(thrown);
|
||||
if (thrown != null) {
|
||||
LOG.log(WARNING,
|
||||
"Background thread has thrown an exception unexpectedly",
|
||||
thrown);
|
||||
throw new AssertionError(thrown);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user