SPR-6610: don't wrap runtime exceptions thrown from methods invoked via an expression

This commit is contained in:
Andy Clement
2010-02-01 20:13:08 +00:00
parent 45f79530db
commit 644f3065b6
5 changed files with 66 additions and 11 deletions

View File

@@ -106,9 +106,13 @@ public class ConstructorReference extends SpelNodeImpl {
Throwable rootCause = (causeOfAccessException==null?null:causeOfAccessException.getCause());
if (rootCause!=null) {
// User exception was the root cause - exit now
String typename = (String) children[0].getValueInternal(state).getValue();
throw new SpelEvaluationException(getStartPosition(), rootCause, SpelMessage.CONSTRUCTOR_INVOCATION_PROBLEM,
typename,FormatHelper.formatMethodForMessage("", argumentTypes));
if (rootCause instanceof RuntimeException) {
throw (RuntimeException)rootCause;
} else {
String typename = (String) children[0].getValueInternal(state).getValue();
throw new SpelEvaluationException(getStartPosition(), rootCause, SpelMessage.CONSTRUCTOR_INVOCATION_PROBLEM,
typename,FormatHelper.formatMethodForMessage("", argumentTypes));
}
}
// at this point we know it wasn't a user problem so worth a retry if a better candidate can be found

View File

@@ -93,8 +93,12 @@ public class MethodReference extends SpelNodeImpl {
Throwable rootCause = (causeOfAccessException==null?null:causeOfAccessException.getCause());
if (rootCause!=null) {
// User exception was the root cause - exit now
throw new SpelEvaluationException( getStartPosition(), rootCause, SpelMessage.EXCEPTION_DURING_METHOD_INVOCATION,
if (rootCause instanceof RuntimeException) {
throw (RuntimeException)rootCause;
} else {
throw new SpelEvaluationException( getStartPosition(), rootCause, SpelMessage.EXCEPTION_DURING_METHOD_INVOCATION,
this.name, state.getActiveContextObject().getValue().getClass().getName(), rootCause.getMessage());
}
}
// at this point we know it wasn't a user problem so worth a retry if a better candidate can be found