Skip to content

AdvisedSupport.MethodCacheKey should check for logical equality as well as identity #33915

@PleaseGiveMeTheCoke

Description

@PleaseGiveMeTheCoke

In the production environment, I discovered that AdvisedSupport#methodCache contains two "identical" keys, both corresponding to the same method object.

Experimentally, I found that the methodCache established during bean initialization is practically useless. During actual method invocation, the interceptor chain retrieved via methodCache.get(cacheKey) turns out to be empty. Thus, the interceptor chain is fetched again using advisorChainFactory and then placed into the methodCache. This means that the initialization logic related to getInterceptorsAndDynamicInterceptionAdvice will not only execute during bean initialization but also during the first method invocation.

Returning to the issue itself, since each call to getClass().getDeclaredMethods()[0] results in a Method object that, when compared using ==, returns false (even if it's the same method), I believe the equals method of MethodCacheKey is poorly designed.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions