提交 918bc3b1 编写于 作者: J Juergen Hoeller

Avoid ConcurrentModificationException in getBeansWithAnnotation

Issue: SPR-12688
上级 13ccc8ed
/* /*
* 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,17 +562,10 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto ...@@ -562,17 +562,10 @@ 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;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册