From f6205d4207c6728fb4293d394639f953986d9895 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 9d3fa0dcf54..7a2ce5752cb 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 @@ -751,7 +751,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; } @@ -763,7 +763,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; }