Avoid eager instantiation of non-singleton FactoryBean in getBeanNamesForType

Closes gh-28616
This commit is contained in:
Fabian Gonzalez
2022-06-13 18:37:58 -03:00
committed by Sam Brannen
parent e47cc44947
commit 0ce9516aef

View File

@@ -585,7 +585,8 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
if (!matchFound) {
// In case of FactoryBean, try to match FactoryBean instance itself next.
beanName = FACTORY_BEAN_PREFIX + beanName;
matchFound = isTypeMatch(beanName, type, allowFactoryBeanInit);
matchFound = (includeNonSingletons || isSingleton(beanName, mbd, dbd)) && isTypeMatch(beanName, type, allowFactoryBeanInit);
}
}
if (matchFound) {