|
30 | 30 | import java.util.Iterator;
|
31 | 31 | import java.util.LinkedHashMap;
|
32 | 32 | import java.util.LinkedHashSet;
|
| 33 | +import java.util.LinkedList; |
33 | 34 | import java.util.List;
|
34 | 35 | import java.util.Map;
|
35 | 36 | import java.util.Set;
|
36 | 37 | import java.util.concurrent.ConcurrentHashMap;
|
37 |
| -import java.util.concurrent.CopyOnWriteArrayList; |
38 | 38 |
|
39 | 39 | import org.springframework.beans.BeanUtils;
|
40 | 40 | import org.springframework.beans.BeanWrapper;
|
@@ -142,16 +142,16 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
142 | 142 | private TypeConverter typeConverter;
|
143 | 143 |
|
144 | 144 | /** String resolvers to apply e.g. to annotation attribute values */
|
145 |
| - private final List<StringValueResolver> embeddedValueResolvers = new CopyOnWriteArrayList<StringValueResolver>(); |
| 145 | + private final List<StringValueResolver> embeddedValueResolvers = new LinkedList<StringValueResolver>(); |
146 | 146 |
|
147 | 147 | /** BeanPostProcessors to apply in createBean */
|
148 |
| - private volatile List<BeanPostProcessor> beanPostProcessors = new ArrayList<BeanPostProcessor>(); |
| 148 | + private final List<BeanPostProcessor> beanPostProcessors = new ArrayList<BeanPostProcessor>(); |
149 | 149 |
|
150 | 150 | /** Indicates whether any InstantiationAwareBeanPostProcessors have been registered */
|
151 |
| - private volatile boolean hasInstantiationAwareBeanPostProcessors; |
| 151 | + private boolean hasInstantiationAwareBeanPostProcessors; |
152 | 152 |
|
153 | 153 | /** Indicates whether any DestructionAwareBeanPostProcessors have been registered */
|
154 |
| - private volatile boolean hasDestructionAwareBeanPostProcessors; |
| 154 | + private boolean hasDestructionAwareBeanPostProcessors; |
155 | 155 |
|
156 | 156 | /** Map from scope identifier String to corresponding Scope */
|
157 | 157 | private final Map<String, Scope> scopes = new LinkedHashMap<String, Scope>(8);
|
@@ -845,22 +845,14 @@ public String resolveEmbeddedValue(String value) {
|
845 | 845 | @Override
|
846 | 846 | public void addBeanPostProcessor(BeanPostProcessor beanPostProcessor) {
|
847 | 847 | Assert.notNull(beanPostProcessor, "BeanPostProcessor must not be null");
|
848 |
| - // Local copy set into volatile field, as an alternative to CopyOnWriteArrayList |
849 |
| - // (which doesn't support Iterator.remove for our getBeanPostProcessors result List) |
850 |
| - List<BeanPostProcessor> beanPostProcessors = new ArrayList<BeanPostProcessor>(); |
851 |
| - beanPostProcessors.addAll(this.beanPostProcessors); |
852 |
| - // Remove from old position, if any |
853 |
| - beanPostProcessors.remove(beanPostProcessor); |
854 |
| - // Track whether it is instantiation/destruction aware |
| 848 | + this.beanPostProcessors.remove(beanPostProcessor); |
| 849 | + this.beanPostProcessors.add(beanPostProcessor); |
855 | 850 | if (beanPostProcessor instanceof InstantiationAwareBeanPostProcessor) {
|
856 | 851 | this.hasInstantiationAwareBeanPostProcessors = true;
|
857 | 852 | }
|
858 | 853 | if (beanPostProcessor instanceof DestructionAwareBeanPostProcessor) {
|
859 | 854 | this.hasDestructionAwareBeanPostProcessors = true;
|
860 | 855 | }
|
861 |
| - // Add to end of list |
862 |
| - beanPostProcessors.add(beanPostProcessor); |
863 |
| - this.beanPostProcessors = beanPostProcessors; |
864 | 856 | }
|
865 | 857 |
|
866 | 858 | @Override
|
|
0 commit comments