Perform type check before singleton check for early FactoryBean matching
Closes gh-34710
This commit is contained in:
@@ -639,10 +639,15 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (includeNonSingletons || isNonLazyDecorated ||
|
||||
(allowFactoryBeanInit && isSingleton(beanName, mbd, dbd))) {
|
||||
if (includeNonSingletons || isNonLazyDecorated) {
|
||||
matchFound = isTypeMatch(beanName, type, allowFactoryBeanInit);
|
||||
}
|
||||
else if (allowFactoryBeanInit) {
|
||||
// Type check before singleton check, avoiding FactoryBean instantiation
|
||||
// for early FactoryBean.isSingleton() calls on non-matching beans.
|
||||
matchFound = isTypeMatch(beanName, type, allowFactoryBeanInit) &&
|
||||
isSingleton(beanName, mbd, dbd);
|
||||
}
|
||||
if (!matchFound) {
|
||||
// In case of FactoryBean, try to match FactoryBean instance itself next.
|
||||
beanName = FACTORY_BEAN_PREFIX + beanName;
|
||||
|
||||
Reference in New Issue
Block a user