Always fall back to original method if annotation pointcut used
Prior to this commit, AspectJExpressionPointcut doesn't fall back to original method if `!@annotation()` is used, it can cause false positive result. Fix GH-27119
This commit is contained in:
committed by
Juergen Hoeller
parent
16c6376b3f
commit
3a6d0c1d5b
@@ -78,6 +78,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Juergen Hoeller
|
||||
* @author Ramnivas Laddad
|
||||
* @author Dave Syer
|
||||
* @author Yanming Zhou
|
||||
* @since 2.0
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
@@ -470,8 +471,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
|
||||
fallbackExpression = null;
|
||||
}
|
||||
}
|
||||
if (targetMethod != originalMethod && (shadowMatch == null ||
|
||||
(shadowMatch.neverMatches() && Proxy.isProxyClass(targetMethod.getDeclaringClass())))) {
|
||||
if (targetMethod != originalMethod && (shadowMatch == null || shouldFallback(targetMethod))) {
|
||||
// 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).
|
||||
@@ -513,6 +513,12 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
|
||||
return shadowMatch;
|
||||
}
|
||||
|
||||
private boolean shouldFallback(Method targetMethod) {
|
||||
if (!Proxy.isProxyClass(targetMethod.getDeclaringClass())) {
|
||||
return false;
|
||||
}
|
||||
return this.resolveExpression().contains("@annotation");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object other) {
|
||||
|
||||
Reference in New Issue
Block a user