From e98c2fe4880476020863c2ddd2bd2e0733c0caec Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 13 Feb 2026 13:55:24 +0100 Subject: [PATCH] Reuse AnnotatedMethod annotation cache in derived instances Closes gh-36322 --- .../org/springframework/core/annotation/AnnotatedMethod.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotatedMethod.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotatedMethod.java index 2fb34cf7f54..2efe4321aaf 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotatedMethod.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotatedMethod.java @@ -58,7 +58,7 @@ public class AnnotatedMethod { private final MethodParameter[] parameters; - private final Map, Object> annotations = new ConcurrentHashMap<>(4); + private final Map, Object> annotations; private volatile @Nullable List inheritedParameterAnnotations; @@ -73,6 +73,7 @@ public class AnnotatedMethod { this.bridgedMethod = BridgeMethodResolver.findBridgedMethod(method); ReflectionUtils.makeAccessible(this.bridgedMethod); this.parameters = initMethodParameters(); + this.annotations = new ConcurrentHashMap<>(4); } /** @@ -83,6 +84,7 @@ public class AnnotatedMethod { this.method = annotatedMethod.method; this.bridgedMethod = annotatedMethod.bridgedMethod; this.parameters = annotatedMethod.parameters; + this.annotations = annotatedMethod.annotations; this.inheritedParameterAnnotations = annotatedMethod.inheritedParameterAnnotations; }