Skip to content

Ordered list access for BeanFactory.getBeanProvider(), superseding ObjectProvider<List> [SPR-17272] #21805

Closed
@spring-projects-issues

Description

@spring-projects-issues

Sébastien Deleuze opened SPR-17272 and commented

Unlike DependencyObjectProvider which seems to support this use case, the ObjectProvider implementation returned by DefaultListableBeanFactory#getBeanProvider(ResolvableType) does not seems to support List<Foo> correctly.

This test is green:

@Test
public void registerBeanAndGetBeanProvider() {
     GenericApplicationContext context = new GenericApplicationContext();
     context.registerBean(ViewResolver.class, () -> new MustacheViewResolver());
     assertNotNull(context.getDefaultListableBeanFactory().getBeanProvider(ResolvableType.forClass(ViewResolver.class)).getIfAvailable());
}

This test is red:

@Test
public void registerBeanAndGetBeanProviderList() {
     GenericApplicationContext context = new GenericApplicationContext();
     context.registerBean(ViewResolver.class, () -> new MustacheViewResolver());
     assertNotNull(context.getDefaultListableBeanFactory().getBeanProvider(ResolvableType.forClassWithGenerics(List.class, ViewResolver.class)).getIfAvailable());
}

This difference of behavior prevents Kofu configuration and Dave Syer FuncApplication to instantiate WebFluxAutoConfiguration.WebFluxConfig in a functional way and get view resolution support.


Affects: 5.1 RC3

Issue Links:

Referenced from: commits 65c8fa4, 41d4cb5, 7562761

0 votes, 8 watchers

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions