Skip to content

Support for null bean in functional bean registration [SPR-17057] #21595

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 Jul 18, 2018 · 1 comment
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jul 18, 2018

Dave Syer opened SPR-17057 and commented

You can return null from a @Bean method and it does some clever stuff internally using a final package private class (which is therefore inaccessible to users) called NullBean. The result is just a bean that cannot satisfy any dependencies. It would make sense if the functional form of the same bean could do the same trick, either returning null from the Supplier or some other contract that allows the BeanFactory to behave the same way.


Affects: 5.0.7

Issue Links:

Referenced from: commits 28f7b26

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Indeed, in particular with 5.1's refined null bean semantics, a null-returning instance supplier should simply resolve to NullBean as well (instead of rejecting the null return value there).

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: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants