-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Consistent non-exposure of null beans in the BeanFactory API [SPR-17034] #21572
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
Comments
Joe Grandja commented The Spring Security 5.1.0-BUILD-SNAPSHOT is currently failing as a result of this failing test. The main issue is that a NPE is happening because there are In 5.0.7, this was handled with Attached are 2 debug screenshots to show this.
|
Rob Winch commented To elaborate on what Joe reported. There are enough tests failing in Spring Security that it is impractical for us to ignore them. This is making it difficult for us to accept changes into master since we require Spring Framework 5.1.0.BUILD-SNAPSHOT+. If a solution cannot be found soon, can we revert this code until a long term solution can be made? This will allow other projects' tests to pass until the long term solution is found. |
Juergen Hoeller commented I've pushed a change that excludes null beans from |
Rob Winch commented Thanks Juergen Hoeller! This has fixed the Spring Security build |
Juergen Hoeller commented Multi-element injection points (i.e. injected However, such bean definitions do not disappear completely. They still show up on early type match checks (through For regular injection points that might not resolve uniquely due to an eventally-null bean definition, it is still recommended to use |
Uh oh!
There was an error while loading. Please reload this page.
Brian Clozel opened SPR-17034 and commented
Currently the core container allows to create null beans like this:
This can be quite useful to back off and consume resources if that bean is not required (or a no-op), given the application configuration.
A recent change in the Spring MVC infrastructure setup uncovered several issues, since in many places we're asking for those infrastructure beans without guarding against null values.
Given the previous
myHandlerMapping
bean declaration, askingBeanFactory
for beans can then returnnull
instances in several cases:Looking at the previous examples, we could improve the consistency of the behavior, or document a bit more the null case and what it means.
Affects: 5.0.7
Reference URL: a40d25a
Attachments:
Issue Links:
@Bean
methods@Bean
return null@Bean
Referenced from: commits 77d72f1, 680afa7, def6fbb
0 votes, 6 watchers
The text was updated successfully, but these errors were encountered: