Skip to content

Commit 2b6639e

Browse files
kilinksdeleuze
authored andcommitted
Avoid storing duplicate empty array in MethodParameter field
Avoid storing duplicate empty arrays in the parameterAnnotations field of MethodParameter. Closes gh-33496
1 parent e9b0a19 commit 2b6639e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

spring-core/src/main/java/org/springframework/core/MethodParameter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ public Annotation[] getParameterAnnotations() {
647647
// for inner classes, so access it with the actual parameter index lowered by 1
648648
index = this.parameterIndex - 1;
649649
}
650-
paramAnns = (index >= 0 && index < annotationArray.length ?
650+
paramAnns = (index >= 0 && index < annotationArray.length && annotationArray[index].length > 0 ?
651651
adaptAnnotationArray(annotationArray[index]) : EMPTY_ANNOTATION_ARRAY);
652652
this.parameterAnnotations = paramAnns;
653653
}
@@ -916,7 +916,7 @@ public Annotation[] getParameterAnnotations() {
916916
merged.add(fieldAnn);
917917
}
918918
}
919-
anns = merged.toArray(new Annotation[0]);
919+
anns = merged.toArray(EMPTY_ANNOTATION_ARRAY);
920920
}
921921
}
922922
catch (NoSuchFieldException | SecurityException ex) {

0 commit comments

Comments
 (0)