|
|
|
@ -89,17 +89,7 @@ public class MethodReference extends SpelNodeImpl { |
|
|
|
// may or may not be a root cause. If there is a root cause it is a user created exception.
|
|
|
|
// may or may not be a root cause. If there is a root cause it is a user created exception.
|
|
|
|
// If there is no root cause it was a reflective invocation problem.
|
|
|
|
// If there is no root cause it was a reflective invocation problem.
|
|
|
|
|
|
|
|
|
|
|
|
Throwable causeOfAccessException = ae.getCause(); |
|
|
|
throwSimpleExceptionIfPossible(state, ae); |
|
|
|
Throwable rootCause = (causeOfAccessException==null?null:causeOfAccessException.getCause()); |
|
|
|
|
|
|
|
if (rootCause!=null) { |
|
|
|
|
|
|
|
// User exception was the root cause - exit now
|
|
|
|
|
|
|
|
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
|
|
|
|
// at this point we know it wasn't a user problem so worth a retry if a better candidate can be found
|
|
|
|
this.cachedExecutor = null; |
|
|
|
this.cachedExecutor = null; |
|
|
|
@ -113,11 +103,32 @@ public class MethodReference extends SpelNodeImpl { |
|
|
|
return executorToUse.execute( |
|
|
|
return executorToUse.execute( |
|
|
|
state.getEvaluationContext(), state.getActiveContextObject().getValue(), arguments); |
|
|
|
state.getEvaluationContext(), state.getActiveContextObject().getValue(), arguments); |
|
|
|
} catch (AccessException ae) { |
|
|
|
} catch (AccessException ae) { |
|
|
|
|
|
|
|
// Same unwrapping exception handling as above in above catch block
|
|
|
|
|
|
|
|
throwSimpleExceptionIfPossible(state, ae); |
|
|
|
throw new SpelEvaluationException( getStartPosition(), ae, SpelMessage.EXCEPTION_DURING_METHOD_INVOCATION, |
|
|
|
throw new SpelEvaluationException( getStartPosition(), ae, SpelMessage.EXCEPTION_DURING_METHOD_INVOCATION, |
|
|
|
this.name, state.getActiveContextObject().getValue().getClass().getName(), ae.getMessage()); |
|
|
|
this.name, state.getActiveContextObject().getValue().getClass().getName(), ae.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Decode the AccessException, throwing a lightweight evaluation exception or, if the cause was a RuntimeException, |
|
|
|
|
|
|
|
* throw the RuntimeException directly. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void throwSimpleExceptionIfPossible(ExpressionState state, AccessException ae) { |
|
|
|
|
|
|
|
Throwable causeOfAccessException = ae.getCause(); |
|
|
|
|
|
|
|
Throwable rootCause = (causeOfAccessException==null?null:causeOfAccessException.getCause()); |
|
|
|
|
|
|
|
if (rootCause!=null) { |
|
|
|
|
|
|
|
// User exception was the root cause - exit now
|
|
|
|
|
|
|
|
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()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Class<?>[] getTypes(Object... arguments) { |
|
|
|
private Class<?>[] getTypes(Object... arguments) { |
|
|
|
Class<?>[] argumentTypes = new Class[arguments.length]; |
|
|
|
Class<?>[] argumentTypes = new Class[arguments.length]; |
|
|
|
for (int i = 0; i < arguments.length; i++) { |
|
|
|
for (int i = 0; i < arguments.length; i++) { |
|
|
|
|