CORDA-3309: Install UncaughtExceptionHandler for DJVM tasks. (#88)

This commit is contained in:
Chris Rankin 2019-10-08 14:57:46 +01:00 committed by GitHub
parent ecc5ace4c7
commit 90c2f7f129

View File

@ -91,7 +91,7 @@ abstract class TestBase(type: SandboxType) {
action: SandboxRuntimeContext.() -> Unit action: SandboxRuntimeContext.() -> Unit
) { ) {
var thrownException: Throwable? = null var thrownException: Throwable? = null
thread { thread(start = false) {
try { try {
UserPathSource(classPaths).use { userSource -> UserPathSource(classPaths).use { userSource ->
SandboxRuntimeContext(parentConfiguration.createChild(userSource, Consumer { SandboxRuntimeContext(parentConfiguration.createChild(userSource, Consumer {
@ -105,7 +105,13 @@ abstract class TestBase(type: SandboxType) {
} catch (exception: Throwable) { } catch (exception: Throwable) {
thrownException = exception thrownException = exception
} }
}.join() }.apply {
uncaughtExceptionHandler = Thread.UncaughtExceptionHandler { _, ex ->
thrownException = ex
}
start()
join()
}
throw thrownException ?: return throw thrownException ?: return
} }
} }