Skip to content

Commit

Permalink
Apply fallback for proxy with negative match or annotation pointcut
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller committed Nov 23, 2023
1 parent 3a6d0c1 commit 0d8dee2
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,12 @@ private ShadowMatch getShadowMatch(Method targetMethod, Method originalMethod) {
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);
Expand Down Expand Up @@ -513,13 +515,11 @@ else if (shadowMatch.maybeMatches() && fallbackExpression != null) {
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 &&
Expand Down

0 comments on commit 0d8dee2

Please sign in to comment.