From ed6c25fb6ecd8942a8b9e62f9db19aa52811038e Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Mon, 18 Mar 2024 15:17:04 +0100 Subject: [PATCH] Avoid unnecessary Annotation array cloning in TypeDescriptor Closes gh-32476 (cherry picked from commit 42a4f2896222959d85ba4642542cfe05aff91f2c) --- .../java/org/springframework/core/convert/TypeDescriptor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java b/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java index d146b9306e6..e541ba237bd 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java +++ b/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java @@ -750,7 +750,7 @@ public class TypeDescriptor implements Serializable { @Override public boolean isAnnotationPresent(Class annotationClass) { - for (Annotation annotation : getAnnotations()) { + for (Annotation annotation : this.annotations) { if (annotation.annotationType() == annotationClass) { return true; } @@ -762,7 +762,7 @@ public class TypeDescriptor implements Serializable { @Nullable @SuppressWarnings("unchecked") public T getAnnotation(Class annotationClass) { - for (Annotation annotation : getAnnotations()) { + for (Annotation annotation : this.annotations) { if (annotation.annotationType() == annotationClass) { return (T) annotation; }