Browse Source

Better use of key iterator

This commit uses an EntrySet instead of looping over the keys and
retrieving the value in a separate call.

Issue: SPR-12356
pull/667/merge
Min Ho Pak 10 years ago committed by Stephane Nicoll
parent
commit
2e5d752e15
  1. 5
      spring-beans/src/main/java/org/springframework/beans/factory/annotation/BeanFactoryAnnotationUtils.java

5
spring-beans/src/main/java/org/springframework/beans/factory/annotation/BeanFactoryAnnotationUtils.java

@ -79,13 +79,14 @@ public class BeanFactoryAnnotationUtils { @@ -79,13 +79,14 @@ public class BeanFactoryAnnotationUtils {
private static <T> T qualifiedBeanOfType(ConfigurableListableBeanFactory bf, Class<T> beanType, String qualifier) {
Map<String, T> candidateBeans = BeanFactoryUtils.beansOfTypeIncludingAncestors(bf, beanType);
T matchingBean = null;
for (String beanName : candidateBeans.keySet()) {
for (Map.Entry<String, T> entry : candidateBeans.entrySet()) {
String beanName = entry.getKey();
if (isQualifierMatch(qualifier, beanName, bf)) {
if (matchingBean != null) {
throw new NoSuchBeanDefinitionException(qualifier, "No unique " + beanType.getSimpleName() +
" bean found for qualifier '" + qualifier + "'");
}
matchingBean = candidateBeans.get(beanName);
matchingBean = entry.getValue();
}
}
if (matchingBean != null) {

Loading…
Cancel
Save