From 0f1beaf3f812f6316dbc81f70aa321bd75d0c936 Mon Sep 17 00:00:00 2001 From: daguimu Date: Wed, 25 Mar 2026 23:40:41 +0800 Subject: [PATCH] fix: restrict SentinelResourceAspect pointcut to execution join points only The @annotation pointcut without an explicit join point kind matches both call and execution join points in native AspectJ (compile-time or load-time weaving). This causes the around advice to fire twice for the same method invocation on the same thread, doubling the thread count tracked by Sentinel and leading to incorrect thread-based flow control. Add explicit execution(* *(..)) to the pointcut expression to restrict matching to execution join points only. This has no effect on Spring AOP (which already only supports execution join points) but fixes the double-counting issue in native AspectJ environments. Fixes #3597 --- .../csp/sentinel/annotation/aspectj/SentinelResourceAspect.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sentinel-extension/sentinel-annotation-aspectj/src/main/java/com/alibaba/csp/sentinel/annotation/aspectj/SentinelResourceAspect.java b/sentinel-extension/sentinel-annotation-aspectj/src/main/java/com/alibaba/csp/sentinel/annotation/aspectj/SentinelResourceAspect.java index 3e1a9d680c..f07962dd38 100644 --- a/sentinel-extension/sentinel-annotation-aspectj/src/main/java/com/alibaba/csp/sentinel/annotation/aspectj/SentinelResourceAspect.java +++ b/sentinel-extension/sentinel-annotation-aspectj/src/main/java/com/alibaba/csp/sentinel/annotation/aspectj/SentinelResourceAspect.java @@ -35,7 +35,7 @@ @Aspect public class SentinelResourceAspect extends AbstractSentinelAspectSupport { - @Pointcut("@annotation(com.alibaba.csp.sentinel.annotation.SentinelResource)") + @Pointcut("execution(* *(..)) && @annotation(com.alibaba.csp.sentinel.annotation.SentinelResource)") public void sentinelResourceAnnotationPointcut() { }