While upgrading to Spring Boot 3.4.3, I ran into this Spring Framework 6.2.3 issue while running tests: NullPointerException thrown when ConfigurationClassEnhancer creates CGLIB proxy.
As a temporary workaround, I tried overriding spring-framework.version
to 6.2.2, but that results in 'method not found' errors, so it seems that Spring Boot 3.4.3 is not compatible with the previous Spring Framework patch release.
The same issue also seems to be present in Spring Framework 6.1.17, affecting Spring Boot 3.3.9.
I don't know if this affects a significant number of users, but it seems that this Spring Framework bug is currently a blocker for upgrading to the latest versions of Spring Boot.
Comment From: bclozel
As a temporary workaround, I tried overriding spring-framework.version to 6.2.2, but that results in 'method not found' errors, so it seems that Spring Boot 3.4.3 is not compatible with the previous Spring Framework patch release.
Can you provide a stacktrace for that?
Comment From: k-seth
I decided to give downgrading Spring Framework (as the issue opener discussed) a try in a project with similar issues, and the stack trace regarding a missing method includes:
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.autoconfigure.metrics.cache.CacheMetricsRegistrarConfiguration]: Constructor threw exception
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:222)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:145)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:318)
... 120 more
Caused by: java.lang.NoSuchMethodError: 'java.util.Map org.springframework.beans.factory.support.SimpleAutowireCandidateResolver.resolveAutowireCandidates(org.springframework.beans.factory.config.ConfigurableListableBeanFactory, java.lang.Class)'
at org.springframework.boot.actuate.autoconfigure.metrics.cache.CacheMetricsRegistrarConfiguration.<init>(CacheMetricsRegistrarConfiguration.java:57)
at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:209)
... 122 more
The use of the resolveAutowireCandidates
seems to be sprinkled through a handful of actuator configurations, introduced in 4cb9d81
Comment From: bclozel
Thanks for the information @k-seth ; unfortunately I don't see how we can reinstate compatibility with the previous Framework version without breaking #43481. Out of curiosity @breun @k-seth could you check whether Spring Framework 6.2.4-SNAPSHOT really fixes the problem for you?
Comment From: bclozel
In the meantime, I don't see anything actionable here, as we don't support Framework downgrades from a Boot perspective (it might work, but we don't guarantee this). In the meantime, you can downgrade to the latest Spring Boot maintenance version that works for you. Please follow up on the Framework issue if you get a chance to test SNAPSHOTs. This would help us refine the fix if needed, as this one is tricky to reproduce in the first place as far as I understand.
Comment From: snicoll
You can also consider putting @Configuration(proxyBeanMethods=false)
on the offended configuration class in the meantime. If you can provide a reproducer, please raise a Spring Framework issue as we're having issues to get to the bottom of this.
Comment From: k-seth
@bclozel Bumping to 6.2.4-SNAPSHOT resolves the issue within our test suite without further changes, which is a great sign.
@snicoll I'll see if I can convert one of our failing tests to something shareable as a reproduction. I've narrowed it down to our two configuration classes causing it. The suggestion of @Configuration(proxyBeanMethods=false)
works in our case - appreciate it!
Comment From: bclozel
@k-seth Thanks for checking the SNAPSHOTs! If the fix is good for your case, no need for an additional sample on our side. We've had reports of other cases where this fix would not work entirely, that's why we're asking.
Comment From: breun
Changing all occurrences of @Configuration
in our tests to @Configuration(proxyBeanMethods = false)
results in a successful build with Spring Boot 3.4.3.
We have downstream users of our code that will also have @Configuration
classes that don't disable proxyBeanMethods
and pushing this update with Spring Framework 6.2.3/6.1.17 would be a breaking change for them, so I guess we'll have to pass on Spring Boot 3.4.3/3.3.9 and wait for the next Spring Boot releases with Spring Framework versions that contain the fix for this NullPointerException bug.
Comment From: bclozel
@breun If you want to be sure that the next Framework version will fix the issue, testing the SNAPSHOTs is the best way to go.
Comment From: breun
@bclozel I just verified that Spring Framework 6.2.4-SNAPSHOT indeed also fixes the issue without changing @Configuration
to @Configuration(proxyBeanMethods = false)
.