From 31ada7d0152eb861afe151511490f15ccfb8845c Mon Sep 17 00:00:00 2001 From: stsypanov Date: Sat, 21 Jul 2018 13:35:29 +0300 Subject: [PATCH] SPR-17074 Replace iteration over Map::ketSet with Map::entrySet --- .../aspectj/annotation/AbstractAspectJAdvisorFactory.java | 5 +++-- .../beans/factory/support/DefaultListableBeanFactory.java | 5 +++-- .../org/springframework/core/annotation/AnnotationUtils.java | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java index 0fa9249ae4ca..564fb650202c 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java @@ -208,9 +208,10 @@ public AspectJAnnotation(A annotation) { } private AspectJAnnotationType determineAnnotationType(A annotation) { - for (Class type : annotationTypes.keySet()) { + for (Map.Entry, AspectJAnnotationType> typeEntry : annotationTypes.entrySet()) { + Class type = typeEntry.getKey(); if (type.isInstance(annotation)) { - return annotationTypes.get(type); + return typeEntry.getValue(); } } throw new IllegalStateException("Unknown annotation type: " + annotation.toString()); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java index e20bfbf3a83b..04409be3a2d6 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java @@ -1273,9 +1273,10 @@ protected Map findAutowireCandidates( String[] candidateNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors( this, requiredType, true, descriptor.isEager()); Map result = new LinkedHashMap<>(candidateNames.length); - for (Class autowiringType : this.resolvableDependencies.keySet()) { + for (Map.Entry, Object> classObjectEntry : this.resolvableDependencies.entrySet()) { + Class autowiringType = classObjectEntry.getKey(); if (autowiringType.isAssignableFrom(requiredType)) { - Object autowiringValue = this.resolvableDependencies.get(autowiringType); + Object autowiringValue = classObjectEntry.getValue(); autowiringValue = AutowireUtils.resolveAutowiringValue(autowiringValue, requiredType); if (requiredType.isInstance(autowiringValue)) { result.put(ObjectUtils.identityToString(autowiringValue), autowiringValue); diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java index 12693854498d..8d189586885f 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java @@ -1344,11 +1344,12 @@ else if (aliasPresent) { } // Replace any remaining placeholders with actual default values - for (String attributeName : attributes.keySet()) { + for (Map.Entry attributeEntry : attributes.entrySet()) { + String attributeName = attributeEntry.getKey(); if (valuesAlreadyReplaced.contains(attributeName)) { continue; } - Object value = attributes.get(attributeName); + Object value = attributeEntry.getValue(); if (value instanceof DefaultValueHolder) { value = ((DefaultValueHolder) value).defaultValue; attributes.put(attributeName,