25
25
import java .util .Map ;
26
26
import java .util .Set ;
27
27
28
- import org .springframework .core .MethodClassKey ;
29
28
import org .springframework .core .annotation .MergedAnnotation ;
30
29
import org .springframework .core .convert .TypeDescriptor ;
31
30
import org .springframework .core .convert .converter .GenericConverter ;
@@ -80,10 +79,6 @@ final class ExpressionTemplateSecurityAnnotationScanner<A extends Annotation>
80
79
81
80
private final AnnotationTemplateExpressionDefaults templateDefaults ;
82
81
83
- private final Map <Parameter , MergedAnnotation <A >> uniqueParameterAnnotationCache = new HashMap <>();
84
-
85
- private final Map <MethodClassKey , MergedAnnotation <A >> uniqueMethodAnnotationCache = new HashMap <>();
86
-
87
82
ExpressionTemplateSecurityAnnotationScanner (Class <A > type , AnnotationTemplateExpressionDefaults templateDefaults ) {
88
83
Assert .notNull (type , "type cannot be null" );
89
84
Assert .notNull (templateDefaults , "templateDefaults cannot be null" );
@@ -95,17 +90,14 @@ final class ExpressionTemplateSecurityAnnotationScanner<A extends Annotation>
95
90
@ Override
96
91
MergedAnnotation <A > merge (AnnotatedElement element , Class <?> targetClass ) {
97
92
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 );
100
94
if (annotation == null ) {
101
95
return null ;
102
96
}
103
97
return resolvePlaceholders (annotation );
104
98
}
105
99
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 );
109
101
if (annotation == null ) {
110
102
return null ;
111
103
}
@@ -135,10 +127,9 @@ private MergedAnnotation<A> resolvePlaceholders(MergedAnnotation<A> mergedAnnota
135
127
}
136
128
Map <String , Object > annotationProperties = mergedAnnotation .asMap ();
137
129
for (Map .Entry <String , Object > annotationProperty : annotationProperties .entrySet ()) {
138
- if (!(annotationProperty .getValue () instanceof String )) {
130
+ if (!(annotationProperty .getValue () instanceof String expression )) {
139
131
continue ;
140
132
}
141
- String expression = (String ) annotationProperty .getValue ();
142
133
String value = helper .replacePlaceholders (expression , stringProperties ::get );
143
134
properties .put (annotationProperty .getKey (), value );
144
135
}
0 commit comments