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

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

Closed
spring-projects-issues opened this issue Jul 18, 2018 · 1 comment
Closed
Assignees
Labels
in: core type: enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues 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:

  • #21572 Consistent non-exposure of null beans in the BeanFactory API
  • #21601 Use available type information in functional bean definitions for resolving FactoryBean type

Referenced from: commits 28f7b26

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jul 18, 2018

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

No branches or pull requests

2 participants