Skip to content
Snippets Groups Projects
Commit 4ed3be33 authored by Tomasz Grabiec's avatar Tomasz Grabiec
Browse files

java: pass exceptions thrown from contexts to joiners

This helps the invoker to determine if isolate executed successfuly or not.
parent 29e4f3bb
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,7 @@ public final class Context {
private final Properties properties;
private Thread mainThread;
private Throwable exception;
public Context(ClassLoader systemClassLoader, Properties properties) {
this.systemClassLoader = systemClassLoader;
......@@ -53,8 +54,11 @@ public final class Context {
return properties;
}
public void join() throws InterruptedException {
public void join() throws InterruptedException, ContextFailedException {
mainThread.join();
if (exception != null) {
throw new ContextFailedException(exception);
}
}
public LogManagerWrapper getLogManagerWrapper() {
......@@ -64,4 +68,8 @@ public final class Context {
public void interrupt() {
mainThread.interrupt();
}
void setException(Throwable exception) {
this.exception = exception;
}
}
package io.osv;
/*
* Copyright (C) 2014 Cloudius Systems, Ltd.
*
* This work is open source software, licensed under the terms of the
* BSD license as described in the LICENSE file in the top-level directory.
*/
public class ContextFailedException extends Exception {
public ContextFailedException(Throwable cause) {
super(cause);
}
}
......@@ -111,6 +111,7 @@ public class ContextIsolator {
thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
context.setException(e);
e.printStackTrace();
}
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment