diff --git a/mailbox-core/src/test/java/org/briarproject/mailbox/core/server/IntegrationTest.kt b/mailbox-core/src/test/java/org/briarproject/mailbox/core/server/IntegrationTest.kt index a628a963de01f3e3064be432464ce2de401e5898..98c0115f563a1682a0412ff16309372565e0b580 100644 --- a/mailbox-core/src/test/java/org/briarproject/mailbox/core/server/IntegrationTest.kt +++ b/mailbox-core/src/test/java/org/briarproject/mailbox/core/server/IntegrationTest.kt @@ -63,13 +63,13 @@ abstract class IntegrationTest(private val installJsonFeature: Boolean = true) { protected val contact2 = getNewRandomContact() @Volatile - protected var exceptionInBackgroundThread = false + protected var exceptionInBackgroundThread: Throwable? = null init { // Ensure exceptions thrown on worker threads cause tests to fail val fail = Thread.UncaughtExceptionHandler { _: Thread?, throwable: Throwable -> LOG.warn("Caught unhandled exception", throwable) - exceptionInBackgroundThread = true + exceptionInBackgroundThread = throwable } Thread.setDefaultUncaughtExceptionHandler(fail) } @@ -91,7 +91,7 @@ abstract class IntegrationTest(private val installJsonFeature: Boolean = true) { @BeforeEach open fun beforeEach() { - exceptionInBackgroundThread = false + exceptionInBackgroundThread = null // need to reopen database here because we're closing it after each test db.open(null) db.read { txn -> @@ -112,8 +112,9 @@ abstract class IntegrationTest(private val installJsonFeature: Boolean = true) { assertFalse(setupManager.hasDb) } - if (exceptionInBackgroundThread) { - fail("background thread has thrown an exception unexpectedly") + if (exceptionInBackgroundThread != null) { + fail("background thread has thrown an exception unexpectedly", + exceptionInBackgroundThread) } } diff --git a/mailbox-core/src/test/java/org/briarproject/mailbox/core/setup/WipeTest1.kt b/mailbox-core/src/test/java/org/briarproject/mailbox/core/setup/WipeTest1.kt index 11b79b0fb254374d434b16f888b04d9258222fa0..e3c622e824e628d275c7211c3ef61964465652a0 100644 --- a/mailbox-core/src/test/java/org/briarproject/mailbox/core/setup/WipeTest1.kt +++ b/mailbox-core/src/test/java/org/briarproject/mailbox/core/setup/WipeTest1.kt @@ -20,9 +20,9 @@ class WipeTest1 : IntegrationTest() { t1.join() t2.join() - // reset flag for exceptions thrown on background threads as this can indeed happen here + // reset field for exceptions thrown on background threads as this can indeed happen here // and is OK - exceptionInBackgroundThread = false + exceptionInBackgroundThread = null } @AfterEach diff --git a/mailbox-core/src/test/java/org/briarproject/mailbox/core/setup/WipeTest2.kt b/mailbox-core/src/test/java/org/briarproject/mailbox/core/setup/WipeTest2.kt index 14de328da47b88123d7ce5b5d850e10342266fba..dd2256c157c42b63f4318f040f4652f36168b422 100644 --- a/mailbox-core/src/test/java/org/briarproject/mailbox/core/setup/WipeTest2.kt +++ b/mailbox-core/src/test/java/org/briarproject/mailbox/core/setup/WipeTest2.kt @@ -51,9 +51,9 @@ class WipeTest2 : IntegrationTest() { assertEquals(1, succeeded) assertEquals(1, failed) - // reset flag for exceptions thrown on background threads as this can indeed happen here + // reset field for exceptions thrown on background threads as this can indeed happen here // and is OK - exceptionInBackgroundThread = false + exceptionInBackgroundThread = null } @AfterEach