Skip to content

Commit

Permalink
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions core/src/main/java/org/jruby/RubyKernel.java
Original file line number Diff line number Diff line change
@@ -914,11 +914,15 @@ private static void maybeRaiseJavaException(final Ruby runtime,

if (maybeThrowable instanceof Throwable) {
final Throwable ex = (Throwable) maybeThrowable;
if (ex.getCause() == null && cause instanceof ConcreteJavaProxy) {
// allow raise java.lang.RuntimeException.new, cause: myCurrentException()
if (cause instanceof ConcreteJavaProxy) {
maybeThrowable = ((ConcreteJavaProxy) cause).getObject();
if (maybeThrowable instanceof Throwable && ex != maybeThrowable && ex.getCause() == null) {
ex.initCause((Throwable) maybeThrowable);
if (maybeThrowable instanceof Throwable && ex != maybeThrowable) {
// we have a Throwable we can set for cause, do it under lock
synchronized (ex) {
if (ex.getCause() == null) {
ex.initCause((Throwable) maybeThrowable);
}
}
}
}
Helpers.throwException(ex); return; // not reached

0 comments on commit 1f2e040

Please sign in to comment.