You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When fallback and blockHandler with the same name and different parameter types are defined in the same business bean, the later called handler method will report a reflection call exception.
The fallback and blockHandler of different methods can be called to the corresponding handler correctly without reporting errors.
不同方法的 fallback 、 blockHandler 可以正确调用到对应的处理方法,不报错。
How to reproduce it (as minimally and precisely as possible)
While reading the source code and coming to the methods related with looking for blockHandler and fallback in class AbstractSentinelAspectSupport, I immediately realized that there is a problem here: looking for a method just by its name is likely to find the wrong method. After that I tried to create the bug scenario:
Example Project: https://github.com/dowenliu-xyz/sentinel-fallback-conflict-bug
In this project, I have introduced only two dependencies, spring-boot-starter and sentinel-aspect-aspect.
The SentinelResourceAspect bean is declared to enable AOP annotation support.
The Business class is defined and declared as a Bean.
Two business methods are defined in this class: one with an int parameter and the other with a String parameter.
The @SentinelResource annotation and the fallback method with the same name are specified for each of them. The parameter lists of these two fallback methods correspond to the business methods.
In the client-side RunBiz class, these two methods are called in turn (simulating a web request for two separate entry methods). The first call can fallback normally, while the second call must throw an exception when it tries to fallback.
在客户端 RunBiz 类中依次调用这两个方法(模拟 web 分别请求两个入口方法)。第一个调用可以正常 fallback ,第二个调用尝试 fallback 时必定反射调用失败抛出异常。
Tell us your environment
MacOS 14.3
Temurin 17.0.10
Maven 3.9.6
Anything else we need to know?
The map key for ResourceMetadataRegistry registration of fallback and blockHandler should contain parameter list information, and the lookupXXX method should also have a parameter type list section.
I am busy looking for a job and working odd jobs. I may try to fix this when I have time.
Run module sentinel-demo-annotation-spring-aop, and run following
requests (in curl format) to verify that fallbacks won't overlap
each other. Once the module started, you can call requests in any
sequence.
curl -XGET localhost:19966/bar?t=
curl -XGET localhost:19966/foo?t=-1
Issue Description
Type: bug report
Describe what happened
When
fallback
andblockHandler
with the same name and different parameter types are defined in the same business bean, the later called handler method will report a reflection call exception.同一业务 Bean 中定义同名不同参数类型的
fallback
、blockHandler
时,后被调用的处理方法会报反射调用异常。Describe what you expected to happen
The
fallback
andblockHandler
of different methods can be called to the corresponding handler correctly without reporting errors.不同方法的
fallback
、blockHandler
可以正确调用到对应的处理方法,不报错。How to reproduce it (as minimally and precisely as possible)
While reading the source code and coming to the methods related with looking for
blockHandler
andfallback
in classAbstractSentinelAspectSupport
, I immediately realized that there is a problem here: looking for a method just by its name is likely to find the wrong method. After that I tried to create the bug scenario:Example Project: https://github.com/dowenliu-xyz/sentinel-fallback-conflict-bug
spring-boot-starter
andsentinel-aspect-aspect
.SentinelResourceAspect
bean is declared to enable AOP annotation support.Business
class is defined and declared as a Bean.int
parameter and the other with aString
parameter.@SentinelResource
annotation and thefallback
method with the same name are specified for each of them. The parameter lists of these twofallback
methods correspond to the business methods.RunBiz
class, these two methods are called in turn (simulating a web request for two separate entry methods). The first call can fallback normally, while the second call must throw an exception when it tries to fallback.在读源码,读到
AbstractSentinelAspectSupport
类中查找blockHandler
和fallback
相关方法时,我立即意识到这里有问题:仅通过方法名查找方法很可能会找错方法。之后我尝试创建了bug场景:示例项目:https://github.com/dowenliu-xyz/sentinel-fallback-conflict-bug
spring-boot-starter
、sentinel-aspect-aspect
这两个依赖。SentinelResourceAspect
Bean 以启动 AOP 注解支持。Business
类并声明为 Bean。int
参数和一个String
参数@SentinelResource
注解并指定了相同名称的fallback
方法。这两个fallback
方法的参数列表与业务方法是分别对应的。RunBiz
类中依次调用这两个方法(模拟 web 分别请求两个入口方法)。第一个调用可以正常 fallback ,第二个调用尝试 fallback 时必定反射调用失败抛出异常。Tell us your environment
MacOS 14.3
Temurin 17.0.10
Maven 3.9.6
Anything else we need to know?
The map key for
ResourceMetadataRegistry
registration offallback
andblockHandler
should contain parameter list information, and thelookupXXX
method should also have a parameter type list section.I am busy looking for a job and working odd jobs. I may try to fix this when I have time.
ResourceMetadataRegistry
注册fallback
和blockHandler
时 map key 应该包含参数列表信息,同时lookupXXX
方法也应该加参数类型列表部分。我正在忙于找工作、打零工。有时间的话,我可能会尝试解决这个问题。
(待业程序猿讨饭 ing)
The text was updated successfully, but these errors were encountered: