Browse Source

AbstractBeanFactory.markBeanAsCreated() reliably clears merged bean definition only once

Issue: SPR-14269
(cherry picked from commit 9064d38)
pull/1086/head
Juergen Hoeller 10 years ago
parent
commit
933bbf2de9
  1. 19
      spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -1498,11 +1498,14 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp @@ -1498,11 +1498,14 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
*/
protected void markBeanAsCreated(String beanName) {
if (!this.alreadyCreated.contains(beanName)) {
this.alreadyCreated.add(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);
synchronized (this.mergedBeanDefinitions) {
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);
}
}
}
}
@ -1511,7 +1514,9 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp @@ -1511,7 +1514,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