static void execute(Runnable job) {
try {
pythonExecutor.submit(job).get();
- } catch (InterruptedException | ExecutionException e) {
+ } catch (InterruptedException e) {
throw new RuntimeException(e);
+ } catch (ExecutionException e) {
+ Throwable cause = e.getCause();
+ if (cause instanceof RuntimeException)
+ throw (RuntimeException) cause;
+ else
+ throw new RuntimeException(cause);
}
}
static <V> V execute(Callable<V> job) {
try {
return pythonExecutor.submit(job).get();
- } catch (InterruptedException | ExecutionException e) {
+ } catch (InterruptedException e) {
throw new RuntimeException(e);
+ } catch (ExecutionException e) {
+ Throwable cause = e.getCause();
+ if (cause instanceof RuntimeException)
+ throw (RuntimeException) cause;
+ else
+ throw new RuntimeException(cause);
}
}