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

DefaultListableBeanFactory#getBeanNamesForType does not take target type into account for FactoryBean resolution #30987

Closed
snicoll opened this issue Aug 3, 2023 · 0 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@snicoll
Copy link
Member

snicoll commented Aug 3, 2023

Given a RootBeanDefinition for a FactoryBean that exposes a generic for the bean that it produces (typically Spring Data repositories infrastructure):

RootBeanDefinition beanDefinition = new RootBeanDefinition(JpaRepositoryFactoryBean.class);
beanDefinition.setTargetType(ResolvableType.forClassWithGenerics(JpaRepositoryFactoryBean.class,
		CityRepository.class, Object.class, Object.class));

A call to getBeanNamesForType with CityRepository.class does not return the bean definition. It looks like the target type is not taken into account to resolve the FactoryBean's generic type, if available.

Failing test case at: snicoll@edb8a05

@snicoll snicoll added type: bug A general bug in: core Issues in core modules (aop, beans, core, context, expression) labels Aug 3, 2023
@jhoeller jhoeller changed the title ListableBeanFactory#getBeanNamesForType does not use ResolvableType into account ListableBeanFactory#getBeanNamesForType does not take target type into account for FactoryBean resolution Aug 3, 2023
snicoll added a commit to snicoll/spring-framework that referenced this issue Aug 3, 2023
@sbrannen sbrannen changed the title ListableBeanFactory#getBeanNamesForType does not take target type into account for FactoryBean resolution ListableBeanFactory#getBeanNamesForType does not take target type into account for FactoryBean resolution Aug 3, 2023
@jhoeller jhoeller added this to the 6.1.0-M4 milestone Aug 3, 2023
@jhoeller jhoeller modified the milestones: 6.1.0-M4, 6.0.12 Aug 3, 2023
@jhoeller jhoeller added type: enhancement A general enhancement and removed type: bug A general bug labels Aug 3, 2023
@jhoeller jhoeller changed the title ListableBeanFactory#getBeanNamesForType does not take target type into account for FactoryBean resolution DefaultListableBeanFactory#getBeanNamesForType does not take target type into account for FactoryBean resolution Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants