Skip to content
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

NullPointerException thrown when ConfigurationClassEnhancer creates CGLIB proxy #34423

Closed
spencergibb opened this issue Feb 13, 2025 · 2 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: regression A bug that is also a regression
Milestone

Comments

@spencergibb
Copy link
Member

spencergibb commented Feb 13, 2025

Spring cloud uses boots dependency management of framework

[INFO] |     +- org.springframework:spring-context:jar:6.2.3-SNAPSHOT:compile

@sbrannen thinks it mightt be related to #34274

I can share links to CI builds if needed.

These are examples of failing tests https://github.com/spring-cloud/spring-cloud-stream/blob/fb3c889c9cbbbe0314824f401895118ae4b37a27/core/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/binding/BindingServiceTests.java#L542-L557

java.lang.NullPointerException: Cannot read field "generatedClass" because "data" is null
	at org.springframework.cglib.proxy.Enhancer.nextInstance(Enhancer.java:783)
	at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:321)
	at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:562)
	at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:407)
	at org.springframework.context.annotation.ConfigurationClassEnhancer.createClass(ConfigurationClassEnhancer.java:169)
	at org.springframework.context.annotation.ConfigurationClassEnhancer.enhance(ConfigurationClassEnhancer.java:121)
	at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:539)
	at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanFactory(ConfigurationClassPostProcessor.java:311)
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:363)
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:153)
	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:791)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:609)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:318)
	at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:149)
	at org.springframework.cloud.stream.binding.BindingServiceTests.bindingAutostartup(BindingServiceTests.java:544)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 13, 2025
@sbrannen sbrannen added the in: core Issues in core modules (aop, beans, core, context, expression) label Feb 13, 2025
@sbrannen sbrannen changed the title NPE while framework is creating proxies NullPointerException thrown when ConfigurationClassEnhancer creates CGLIB proxy Feb 13, 2025
@jhoeller jhoeller added type: regression A bug that is also a regression and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Feb 14, 2025
@jhoeller jhoeller self-assigned this Feb 14, 2025
@jhoeller jhoeller added this to the 6.2.4 milestone Feb 14, 2025
@jhoeller jhoeller added the for: backport-to-6.1.x Marks an issue as a candidate for backport to 6.1.x label Feb 14, 2025
@github-actions github-actions bot added status: backported An issue that has been backported to maintenance branches and removed for: backport-to-6.1.x Marks an issue as a candidate for backport to 6.1.x labels Feb 14, 2025
@wind57
Copy link
Contributor

wind57 commented Feb 17, 2025

wind57 referenced this issue in spring-cloud/spring-cloud-kubernetes Feb 17, 2025
jhoeller added a commit that referenced this issue Feb 18, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Closes gh-34423

(cherry picked from commit 93134fd)
jhoeller added a commit that referenced this issue Feb 18, 2025
jhoeller added a commit that referenced this issue Feb 18, 2025
See gh-34423

(cherry picked from commit 6786e1c)
@breun
Copy link

breun commented Feb 24, 2025

I found that for me changing @Configuration to @Configuration(proxyBeanMethods = false) worked as a workaround for this NullPointerException with Spring Framework 6.2.3 (Spring Boot 3.4.3).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

6 participants