Open
Description
Hello,
If you use more than exceptions to catch it by divided recover methods , you should change the method. Because, i have debugged the code, the "recover" method's cause always gives us "Throwable.class". Thus, I changed the code by using commons lib,
Throwable rootCause = ExceptionUtils.getRootCause(cause);
to get cause..
You should change the code by doing this if you want.
public T recover(Object[] args, Throwable cause) {
Method method = findClosestMatch(args, ExceptionUtils.getRootCause(cause).getClass());
if (method == null) {
throw new ExhaustedRetryException("Cannot locate recovery method", cause);
}
SimpleMetadata meta = (SimpleMetadata) this.methods.get(method);
Object[] argsToUse = meta.getArgs(cause, args);
boolean methodAccessible = method.isAccessible();
try {
ReflectionUtils.makeAccessible(method);
T result = (T) ReflectionUtils.invokeMethod(method, this.target, argsToUse);
return result;
} finally {
if (methodAccessible != method.isAccessible()) {
method.setAccessible(methodAccessible);
}
}
}
Metadata
Metadata
Assignees
Labels
No labels