Skip to content

Commit 68d814e

Browse files
kse-musicjzheaux
authored andcommitted
Polish ExpressionTemplateSecurityAnnotationScanner
1 parent cd7f6e0 commit 68d814e

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

core/src/main/java/org/springframework/security/core/annotation/ExpressionTemplateSecurityAnnotationScanner.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import java.util.Map;
2626
import java.util.Set;
2727

28-
import org.springframework.core.MethodClassKey;
2928
import org.springframework.core.annotation.MergedAnnotation;
3029
import org.springframework.core.convert.TypeDescriptor;
3130
import org.springframework.core.convert.converter.GenericConverter;
@@ -80,10 +79,6 @@ final class ExpressionTemplateSecurityAnnotationScanner<A extends Annotation>
8079

8180
private final AnnotationTemplateExpressionDefaults templateDefaults;
8281

83-
private final Map<Parameter, MergedAnnotation<A>> uniqueParameterAnnotationCache = new HashMap<>();
84-
85-
private final Map<MethodClassKey, MergedAnnotation<A>> uniqueMethodAnnotationCache = new HashMap<>();
86-
8782
ExpressionTemplateSecurityAnnotationScanner(Class<A> type, AnnotationTemplateExpressionDefaults templateDefaults) {
8883
Assert.notNull(type, "type cannot be null");
8984
Assert.notNull(templateDefaults, "templateDefaults cannot be null");
@@ -95,17 +90,14 @@ final class ExpressionTemplateSecurityAnnotationScanner<A extends Annotation>
9590
@Override
9691
MergedAnnotation<A> merge(AnnotatedElement element, Class<?> targetClass) {
9792
if (element instanceof Parameter parameter) {
98-
MergedAnnotation<A> annotation = this.uniqueParameterAnnotationCache.computeIfAbsent(parameter,
99-
(p) -> this.unique.merge(p, targetClass));
93+
MergedAnnotation<A> annotation = this.unique.merge(parameter, targetClass);
10094
if (annotation == null) {
10195
return null;
10296
}
10397
return resolvePlaceholders(annotation);
10498
}
10599
if (element instanceof Method method) {
106-
MethodClassKey key = new MethodClassKey(method, targetClass);
107-
MergedAnnotation<A> annotation = this.uniqueMethodAnnotationCache.computeIfAbsent(key,
108-
(k) -> this.unique.merge(method, targetClass));
100+
MergedAnnotation<A> annotation = this.unique.merge(method, targetClass);
109101
if (annotation == null) {
110102
return null;
111103
}
@@ -135,10 +127,9 @@ private MergedAnnotation<A> resolvePlaceholders(MergedAnnotation<A> mergedAnnota
135127
}
136128
Map<String, Object> annotationProperties = mergedAnnotation.asMap();
137129
for (Map.Entry<String, Object> annotationProperty : annotationProperties.entrySet()) {
138-
if (!(annotationProperty.getValue() instanceof String)) {
130+
if (!(annotationProperty.getValue() instanceof String expression)) {
139131
continue;
140132
}
141-
String expression = (String) annotationProperty.getValue();
142133
String value = helper.replacePlaceholders(expression, stringProperties::get);
143134
properties.put(annotationProperty.getKey(), value);
144135
}

0 commit comments

Comments
 (0)