-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancementA general enhancement
Milestone
Description
When a @Bean factory returns null, a NullBean is registered in the context that's not meant to be considered when looking for a candidate by type (only a lookup by name would return it).
Unfortunately, that does not work in at least two cases:
org.springframework.beans.factory.config.AutowireCapableBeanFactory#resolveNamedBeanwill return suchNullBeanfor the type it has been defined againstorg.springframework.beans.factory.ListableBeanFactory#getBeanNamesForType(org.springframework.core.ResolvableType, boolean, boolean)will do that (used by Spring Boot's@ConditionalOnMissingBean.
This was original raised in spring-projects/spring-boot#24448 that contains a sample project.
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancementA general enhancement