Skip to content

Commit 794580f

Browse files
committed
TypeDescriptor efficiently matches equal annotations as well
Issue: SPR-15060 (cherry picked from commit e38c020)
1 parent d44bc27 commit 794580f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,14 +483,19 @@ private boolean annotationsMatch(TypeDescriptor otherDesc) {
483483
}
484484
if (anns.length > 0) {
485485
for (int i = 0; i < anns.length; i++) {
486-
if (anns[i] != otherAnns[i]) {
486+
if (!annotationEquals(anns[i], otherAnns[i])) {
487487
return false;
488488
}
489489
}
490490
}
491491
return true;
492492
}
493493

494+
private boolean annotationEquals(Annotation ann, Annotation otherAnn) {
495+
// Annotation.equals is reflective and pretty slow, so let's check identity and proxy type first.
496+
return (ann == otherAnn || (ann.getClass() == otherAnn.getClass() && ann.equals(otherAnn)));
497+
}
498+
494499
@Override
495500
public int hashCode() {
496501
return getType().hashCode();

0 commit comments

Comments
 (0)