Browse Source

Avoid unnecessary Annotation array cloning in TypeDescriptor

Closes gh-32476

(cherry picked from commit 42a4f28962)
pull/32754/head
Sam Brannen 2 years ago
parent
commit
f6205d4207
  1. 4
      spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java

4
spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java

@ -751,7 +751,7 @@ public class TypeDescriptor implements Serializable { @@ -751,7 +751,7 @@ public class TypeDescriptor implements Serializable {
@Override
public boolean isAnnotationPresent(Class<? extends Annotation> 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 { @@ -763,7 +763,7 @@ public class TypeDescriptor implements Serializable {
@Nullable
@SuppressWarnings("unchecked")
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
for (Annotation annotation : getAnnotations()) {
for (Annotation annotation : this.annotations) {
if (annotation.annotationType() == annotationClass) {
return (T) annotation;
}

Loading…
Cancel
Save