Skip to content

Commit 0ce9516

Browse files
fsgonzsbrannen
authored andcommitted
Avoid eager instantiation of non-singleton FactoryBean in getBeanNamesForType
Closes gh-28616
1 parent e47cc44 commit 0ce9516

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,8 @@ private String[] doGetBeanNamesForType(ResolvableType type, boolean includeNonSi
585585
if (!matchFound) {
586586
// In case of FactoryBean, try to match FactoryBean instance itself next.
587587
beanName = FACTORY_BEAN_PREFIX + beanName;
588-
matchFound = isTypeMatch(beanName, type, allowFactoryBeanInit);
588+
matchFound = (includeNonSingletons || isSingleton(beanName, mbd, dbd)) && isTypeMatch(beanName, type, allowFactoryBeanInit);
589+
589590
}
590591
}
591592
if (matchFound) {

0 commit comments

Comments
 (0)