used AnnotationUtils so that retryable name can come from interface annotation.

This commit is contained in:
Mark Amans
2020-09-22 16:50:17 -05:00
committed by Dave Syer
parent 62d7bfefb6
commit 6e3fce32b5
2 changed files with 14 additions and 5 deletions

View File

@@ -162,7 +162,7 @@ public class RecoverAnnotationRecoveryHandler<T> implements MethodInvocationReco
private void init(final Object target, Method method) {
final Map<Class<? extends Throwable>, Method> types = new HashMap<Class<? extends Throwable>, Method>();
final Method failingMethod = method;
Retryable retryable = method.getAnnotation(Retryable.class);
Retryable retryable = AnnotationUtils.findAnnotation(method, Retryable.class);
if (retryable != null) {
this.recoverMethodName = retryable.recover();
}

View File

@@ -403,23 +403,32 @@ public class RecoverAnnotationRecoveryHandlerTests {
}
protected static class RecoverByRetryableName {
protected static class RecoverByRetryableName implements RecoverByRetryableNameInterface{
@Retryable(recover = "barRecover")
public int foo(String name) {
return 0;
}
@Recover
public int fooRecover(Throwable throwable, String name) {
return 1;
}
@Recover
public int barRecover(Throwable throwable, String name) {
return 2;
}
}
protected interface RecoverByRetryableNameInterface {
@Retryable(recover = "barRecover")
public int foo(String name);
@Recover
public int fooRecover(Throwable throwable, String name);
@Recover
public int barRecover(Throwable throwable, String name);
}
}