Skip to content

DefaultLifecycleProcessor throws BeanNotOfRequiredType for null beans (cause of NullBean instance cannot be converted) [SPR-16343] #20890

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
spring-projects-issues opened this issue Jan 3, 2018 · 1 comment
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jan 3, 2018

Stefan Mueller opened SPR-16343 and commented

When initializing applications with null-beans of type Lifecycle, DefaultLifecycleProcessor.getLifecycleBeans throws a BeanNotOfRequiredType exception rather then ignoring null-beans like in previous spring versions.

DefaultLifecycleProcessor should be fixed to not call the ctx.getBean(name, type) method but rather getBean(name) and check for type explicitely.

Reason/Background: In earlier versions of Spring the ctx.getBean(name, type) method returned null for null-beans. Since Spring 5, Spring returns the NullBean instance but that cannot be converted to required type.

See as well #20582, #20711 and #20889.


Affects: 5.0.2

Issue Links:

Referenced from: commits 977550f

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

We can indeed do a manual instanceof Lifecycle check there in the subsequent if condition. Fixed for 5.0.3 now.

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) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants