Skip to content

Commit

Permalink
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions core/src/main/java/org/jruby/RubyKernel.java
Original file line number Diff line number Diff line change
@@ -899,18 +899,12 @@ private static void maybeRaiseJavaException(final Ruby runtime,
// looks like someone's trying to raise a Java exception. Let them.
Object maybeThrowable = exception.getObject();

if (maybeThrowable instanceof Throwable) {
final Throwable ex = (Throwable) maybeThrowable;
if (ex.getCause() == null && cause instanceof ConcreteJavaProxy) {
// allow raise java.lang.RuntimeException.new, cause: myCurrentException()
maybeThrowable = ((ConcreteJavaProxy) cause).getObject();
if (maybeThrowable instanceof Throwable && ex != maybeThrowable && ex.getCause() == null) {
ex.initCause((Throwable) maybeThrowable);
}
}
Helpers.throwException(ex); return; // not reached
if (!(maybeThrowable instanceof Throwable)) {
throw runtime.newTypeError("can't raise a non-Throwable Java object");
}
throw runtime.newTypeError("can't raise a non-Throwable Java object");

final Throwable ex = (Throwable) maybeThrowable;
Helpers.throwException(ex); return; // not reached
}
}

0 comments on commit fc7b383

Please sign in to comment.