Skip to content

Commit

Permalink
Avoid ConcurrentModificationException in getBeansWithAnnotation
Browse files Browse the repository at this point in the history
Issue: SPR-12688
  • Loading branch information
jhoeller committed Feb 10, 2015
1 parent 13ccc8e commit 918bc3b
Showing 1 changed file with 5 additions and 12 deletions.
@@ -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");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -562,17 +562,10 @@ public String[] getBeanNamesForAnnotation(Class<? extends Annotation> annotation

@Override
public Map<String, Object> getBeansWithAnnotation(Class<? extends Annotation> annotationType) {
Map<String, Object> results = new LinkedHashMap<String, Object>();
for (String beanName : this.beanDefinitionNames) {
BeanDefinition beanDefinition = getBeanDefinition(beanName);
if (!beanDefinition.isAbstract() && findAnnotationOnBean(beanName, annotationType) != null) {
results.put(beanName, getBean(beanName));
}
}
for (String beanName : this.manualSingletonNames) {
if (!results.containsKey(beanName) && findAnnotationOnBean(beanName, annotationType) != null) {
results.put(beanName, getBean(beanName));
}
String[] beanNames = getBeanNamesForAnnotation(annotationType);
Map<String, Object> results = new LinkedHashMap<String, Object>(beanNames.length);
for (String beanName : beanNames) {
results.put(beanName, getBean(beanName));
}
return results;
}
Expand Down

0 comments on commit 918bc3b

Please sign in to comment.