Browse Source

AbstractBeanFactory consistently guards add/remove operations against alreadyCreated Set

Issue: SPR-14269
pull/1069/merge
Juergen Hoeller 9 years ago
parent
commit
71463fb399
  1. 7
      spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java

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

@ -1504,10 +1504,11 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp @@ -1504,10 +1504,11 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
protected void markBeanAsCreated(String beanName) {
if (!this.alreadyCreated.contains(beanName)) {
synchronized (this.mergedBeanDefinitions) {
if (this.alreadyCreated.add(beanName)) {
if (!this.alreadyCreated.contains(beanName)) {
// Let the bean definition get re-merged now that we're actually creating
// the bean... just in case some of its metadata changed in the meantime.
clearMergedBeanDefinition(beanName);
this.alreadyCreated.add(beanName);
}
}
}
@ -1518,7 +1519,9 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp @@ -1518,7 +1519,9 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
* @param beanName the name of the bean
*/
protected void cleanupAfterBeanCreationFailure(String beanName) {
this.alreadyCreated.remove(beanName);
synchronized (this.mergedBeanDefinitions) {
this.alreadyCreated.remove(beanName);
}
}
/**

Loading…
Cancel
Save