AbstractBeanFactory removes alreadyCreated entry after bean creation failure
Issue: SPR-10896
This commit is contained in:
@@ -278,6 +278,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
|||||||
markBeanAsCreated(beanName);
|
markBeanAsCreated(beanName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
final RootBeanDefinition mbd = getMergedLocalBeanDefinition(beanName);
|
final RootBeanDefinition mbd = getMergedLocalBeanDefinition(beanName);
|
||||||
checkMergedBeanDefinition(mbd, beanName, args);
|
checkMergedBeanDefinition(mbd, beanName, args);
|
||||||
|
|
||||||
@@ -352,6 +353,11 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (BeansException ex) {
|
||||||
|
cleanupAfterBeanCreationFailure(beanName);
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check if required type matches the type of the actual bean instance.
|
// Check if required type matches the type of the actual bean instance.
|
||||||
if (requiredType != null && bean != null && !requiredType.isAssignableFrom(bean.getClass())) {
|
if (requiredType != null && bean != null && !requiredType.isAssignableFrom(bean.getClass())) {
|
||||||
@@ -1430,6 +1436,14 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
|||||||
this.alreadyCreated.add(beanName);
|
this.alreadyCreated.add(beanName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform appropriate cleanup of cached metadata after bean creation failed.
|
||||||
|
* @param beanName the name of the bean
|
||||||
|
*/
|
||||||
|
protected void cleanupAfterBeanCreationFailure(String beanName) {
|
||||||
|
this.alreadyCreated.remove(beanName);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether the specified bean is eligible for having
|
* Determine whether the specified bean is eligible for having
|
||||||
* its bean definition metadata cached.
|
* its bean definition metadata cached.
|
||||||
|
|||||||
Reference in New Issue
Block a user