Behavior of AopUtils#getMostSpecificMethod in some cases no longer returns the most specific method #32224
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: duplicate
A duplicate of another issue
type: regression
A bug that is also a regression
Affects: 6.1.3
After upgrading from spring version 6.1.2 to version 6.1.3, I can in some cases no longer use method parameter names in spel expressions specified in the
key
parameter of spring's@CachePut
annotation. The concrete situation where this no longer works is when using the annotation on spring data@Repository
-annotated interfaces, when overriding thesave
method of theMongoRepository
interface. The reason is that spring no longer injects the method parameter names into the spel context, because it no longer identifies the annotated method as the "most specific method" but instead the overridden method from theMongoRepository
.A concrete example:
When calling the
save
method, I get the following error since spring 6.1.3:org.springframework.expression.spel.SpelEvaluationException: EL1007E: Property or field 'id' cannot be found on null
.I only saw this issue when using spring data and spring caching as described above, but it looks to me as if the issue is not due to those spring libraries, but to a change in spring's
AopUtils
. I traced the problem down (to my best knowledge) to commit 419e34e, which changes the implementation ofAopUtils.getMostSpecificMethod
; before that commit, the method returned thesave
method fromMyPojoRepository
, after that commit, the method returned the overriddensave
method fromMongoRepository
. In consequence, with 6.1.2 the method parameter namepojo
from my own method can still be used in the spel expression, with 6.1.2 it can no longer be used.To be honest, I do not have knowledge in how
AopUtils.getMostSpecificMethod
works, but to me it looks as if 419e34e, while fixing some issue, also introduced the new issue I described above.If I am missing any relevant information in this issue, please give me a ping, and I will try to provide it.
The text was updated successfully, but these errors were encountered: