Defensive handling of manually registered singleton names (based on Spring Integration test failure)

Issue: SPR-12404
This commit is contained in:
Juergen Hoeller
2014-11-01 23:03:02 +01:00
parent bba38b8862
commit 3c3e07e324
2 changed files with 23 additions and 10 deletions

View File

@@ -469,8 +469,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
// Check manually registered singletons too.
for (String beanName : this.manualSingletonNames) {
// Only check if manually registered.
if (!containsBeanDefinition(beanName)) {
try {
// In case of FactoryBean, match object created by FactoryBean.
if (isFactoryBean(beanName)) {
if ((includeNonSingletons || isSingleton(beanName)) && isTypeMatch(beanName, type)) {
@@ -486,6 +485,12 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
result.add(beanName);
}
}
catch (NoSuchBeanDefinitionException ex) {
// Shouldn't happen - probably a result of circular reference resolution...
if (logger.isDebugEnabled()) {
logger.debug("Failed to check manually registered singleton with name '" + beanName + "'", ex);
}
}
}
return StringUtils.toStringArray(result);