Skip to content

Cannot downgrade to Spring Framework for CGLIB NullPointerException issue #44395

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

Closed
breun opened this issue Feb 21, 2025 · 10 comments
Closed

Cannot downgrade to Spring Framework for CGLIB NullPointerException issue #44395

breun opened this issue Feb 21, 2025 · 10 comments
Labels
for: external-project For an external project and not something we can fix status: invalid An issue that we don't feel is valid

Comments

@breun
Copy link
Contributor

breun commented Feb 21, 2025

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 21, 2025
@bclozel
Copy link
Member

bclozel commented Feb 21, 2025

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?

@bclozel bclozel added the status: waiting-for-feedback We need additional information before we can continue label Feb 21, 2025
@k-seth
Copy link

k-seth commented Feb 21, 2025

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

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Feb 21, 2025
@bclozel
Copy link
Member

bclozel commented Feb 21, 2025

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?

@bclozel
Copy link
Member

bclozel commented Feb 21, 2025

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.

@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Feb 21, 2025
@snicoll snicoll added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged labels Feb 21, 2025
@bclozel bclozel added status: invalid An issue that we don't feel is valid for: external-project For an external project and not something we can fix labels Feb 21, 2025
@snicoll
Copy link
Member

snicoll commented Feb 21, 2025

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.

@k-seth
Copy link

k-seth commented Feb 21, 2025

@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!

@bclozel
Copy link
Member

bclozel commented Feb 21, 2025

@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.

@breun
Copy link
Contributor Author

breun commented Feb 21, 2025

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.

@bclozel
Copy link
Member

bclozel commented Feb 21, 2025

@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.

@breun
Copy link
Contributor Author

breun commented Feb 21, 2025

@bclozel I just verified that Spring Framework 6.2.4-SNAPSHOT indeed also fixes the issue without changing @Configuration to @Configuration(proxyBeanMethods = false).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

5 participants