Skip to content

Commit e98c2fe

Browse files
committed
Reuse AnnotatedMethod annotation cache in derived instances
Closes gh-36322
1 parent 75705bc commit e98c2fe

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

spring-core/src/main/java/org/springframework/core/annotation/AnnotatedMethod.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public class AnnotatedMethod {
5858

5959
private final MethodParameter[] parameters;
6060

61-
private final Map<Class<? extends Annotation>, Object> annotations = new ConcurrentHashMap<>(4);
61+
private final Map<Class<? extends Annotation>, Object> annotations;
6262

6363
private volatile @Nullable List<Annotation[][]> inheritedParameterAnnotations;
6464

@@ -73,6 +73,7 @@ public AnnotatedMethod(Method method) {
7373
this.bridgedMethod = BridgeMethodResolver.findBridgedMethod(method);
7474
ReflectionUtils.makeAccessible(this.bridgedMethod);
7575
this.parameters = initMethodParameters();
76+
this.annotations = new ConcurrentHashMap<>(4);
7677
}
7778

7879
/**
@@ -83,6 +84,7 @@ protected AnnotatedMethod(AnnotatedMethod annotatedMethod) {
8384
this.method = annotatedMethod.method;
8485
this.bridgedMethod = annotatedMethod.bridgedMethod;
8586
this.parameters = annotatedMethod.parameters;
87+
this.annotations = annotatedMethod.annotations;
8688
this.inheritedParameterAnnotations = annotatedMethod.inheritedParameterAnnotations;
8789
}
8890

0 commit comments

Comments
 (0)