Apply fallback for proxy with negative match or annotation pointcut

See gh-30534
This commit is contained in:
Juergen Hoeller 2023-11-23 16:14:33 +01:00
parent 3a6d0c1d5b
commit 0d8dee2878
1 changed files with 7 additions and 7 deletions

View File

@ -471,10 +471,12 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
fallbackExpression = null;
}
}
if (targetMethod != originalMethod && (shadowMatch == null || shouldFallback(targetMethod))) {
if (targetMethod != originalMethod && (shadowMatch == null ||
(Proxy.isProxyClass(targetMethod.getDeclaringClass()) &&
(shadowMatch.neverMatches() || containsAnnotationPointcut())))) {
// Fall back to the plain original method in case of no resolvable match or a
// negative match on a proxy class (which doesn't carry any annotations on its
// redeclared methods).
// redeclared methods), as well as for annotation pointcuts.
methodToMatch = originalMethod;
try {
shadowMatch = obtainPointcutExpression().matchesMethodExecution(methodToMatch);
@ -513,13 +515,11 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
return shadowMatch;
}
private boolean shouldFallback(Method targetMethod) {
if (!Proxy.isProxyClass(targetMethod.getDeclaringClass())) {
return false;
}
return this.resolveExpression().contains("@annotation");
private boolean containsAnnotationPointcut() {
return resolveExpression().contains("@annotation");
}
@Override
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof AspectJExpressionPointcut that &&