From 42a4f2896222959d85ba4642542cfe05aff91f2c 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 --- .../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 3b7b73866b3..e5202fc472a 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 @@ -759,7 +759,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; } @@ -771,7 +771,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; }