-
Notifications
You must be signed in to change notification settings - Fork 7.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Same name fallback/blockHandler with different parameter types cause reflect exception #3386
Comments
dowenliu-xyz
added a commit
to dowenliu-xyz/Sentinel
that referenced
this issue
May 12, 2024
Merged
Idea 插件 Alibaba Sentinel Annotation Support 对该 bug 的检查/Quickfix 已更新上线 bug-3386-support.mp4 |
dowenliu-xyz
added a commit
to dowenliu-xyz/Sentinel
that referenced
this issue
May 24, 2024
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: