When upgrading to Spring Boot 3.2.0 (spring-framework 6.1.1), we have the following error evaluating cache key and the key is not null:
java.lang.IllegalArgumentException: Null key returned for cache operation (maybe you are using named params on classes without debug info?) Builder[public java.lang.String com.itc.iris.workflows.tests.base.TestRedisCacheService.getRandomString(java.lang.String)] caches=[rndString] | key='#key' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='' | unless='' | sync='false'
at org.springframework.cache.interceptor.CacheAspectSupport.generateKey(CacheAspectSupport.java:673)
at org.springframework.cache.interceptor.CacheAspectSupport.findCachedValue(CacheAspectSupport.java:456)
at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:407)
at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:371)
at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:74)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:765)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:717)
at com.itc.iris.workflows.tests.base.TestRedisCacheService$$SpringCGLIB$$0.getRandomString(<generated>)
at com.itc.iris.workflows.tests.TestRedisCacheManager.testTypesCanBeSerializedAndDeserialized(TestRedisCacheManager.java:33)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
changed the title
java.lang.IllegalArgumentException: Null key returned for cache operation
IllegalArgumentException: Null key returned for cache operation
Nov 30, 2023
@Taha-Di-Nero, are you compiling your code with -parameters
?
Since Spring Framework 6.1 / Spring Boot 3.2, you must compile your code with -parameters
.
See this section of the upgrade notes for details.
In addition, you should have seen a warning in the logs stating this with 6.0.x
.
Hi @Taha-Di-Nero,
The configuration you've shown affects main
code in your Gradle build, so that is a good indication.
However, you may also need to do the same for test code or manually within your IDE.
Thus, in order to assist you further, please provide us a minimal example that reproduces the issue -- preferably as a public Git repository or ZIP file that we can download and run.
Thanks
@sbrannen yes you are right changing to:
tasks.withType(JavaCompile) {
configure(options) {
options.compilerArgs << '-parameters'
Has resolved the problem
Thanks a lot for the support.
Null key returned for cache operation and Parameter name information not available via reflection. Ensure that the compiler uses the '-parameters' flag.
#32715