Avoid ConcurrentModificationException in getBeansWithAnnotation
Issue: SPR-12688
This commit is contained in:
parent
13ccc8ede8
commit
918bc3b103
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2014 the original author or authors.
|
* Copyright 2002-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -562,18 +562,11 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getBeansWithAnnotation(Class<? extends Annotation> annotationType) {
|
public Map<String, Object> getBeansWithAnnotation(Class<? extends Annotation> annotationType) {
|
||||||
Map<String, Object> results = new LinkedHashMap<String, Object>();
|
String[] beanNames = getBeanNamesForAnnotation(annotationType);
|
||||||
for (String beanName : this.beanDefinitionNames) {
|
Map<String, Object> results = new LinkedHashMap<String, Object>(beanNames.length);
|
||||||
BeanDefinition beanDefinition = getBeanDefinition(beanName);
|
for (String beanName : beanNames) {
|
||||||
if (!beanDefinition.isAbstract() && findAnnotationOnBean(beanName, annotationType) != null) {
|
|
||||||
results.put(beanName, getBean(beanName));
|
results.put(beanName, getBean(beanName));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
for (String beanName : this.manualSingletonNames) {
|
|
||||||
if (!results.containsKey(beanName) && findAnnotationOnBean(beanName, annotationType) != null) {
|
|
||||||
results.put(beanName, getBean(beanName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue