spring-retry
spring-retry copied to clipboard
About RecoverAnnotationRecoveryHandler's recover method
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);
}
}
}
Sorry, I'm not sure what code you are talking about. Would you like to propose a change in a pull request? Or be a bit more specific about where the snippets above come from or apply to?