Support method injection when @Autowired(require=false) is used on mixed nullability args #24773
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When
@Autowired(require=false)
on mixed nullability args method, I think IOC container shoud call this method to inject partially non-null parameters, but in fact the current code logic will ignore this method injection, for example:
I liberated the
@Autowired(require=false)
annotation on thenullabilityInjection
method ofMixedNullableInjectionBean
, this method has two parameters,nullableBean
andnonNullBean
, as the name of the parameter means, I only registernonNullBean
toDefaultListableBeanFactory
, and then registerMixedNullableInjectionBean
.I think the IOC container should invoke
nullabilityInjection
method to injectnonNullBean
,but in fact the current code logic will ignore this method injection, I have expressed the nullability of the parameter
nullableBean
, so, I think this parameter is null should not affect the overall method injection. I slightly adjusted the logic of method injection in this pr, what do you think? Thank you for your reading and looking forward to your reply.