Skip to content

@Recover methods not intercepted by Spring AOP advice #244

@kriegaex

Description

@kriegaex

I just answered a question on StackOverflow, please read for more details and my analysis:
https://stackoverflow.com/a/67831919/1082681

The original poster of the question also published this reproducer which helped me find the root cause:
https://github.com/Nikhilgupta1891/RetryRecover

In a nutshell, Spring AOP cannot intercept the execution of a @Recover method because of invocation.getThis() instead of invocation.getProxy() here:

@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
MethodInterceptor delegate = getDelegate(invocation.getThis(), invocation.getMethod());
if (delegate != null) {
return delegate.invoke(invocation);
}
else {
return invocation.proceed();
}
}

If there is no compelling reason to use the target object instead of its corresponding proxy (if any exists), please change it accordingly.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions