Skip to content

Commit

Permalink
Avoid storing duplicate empty array in MethodParameter field
Browse files Browse the repository at this point in the history
Avoid storing duplicate empty arrays in the parameterAnnotations field of MethodParameter.

Closes spring-projectsgh-33496
  • Loading branch information
kilink authored and sdeleuze committed Sep 6, 2024
1 parent e9b0a19 commit 2b6639e
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ public Annotation[] getParameterAnnotations() {
// for inner classes, so access it with the actual parameter index lowered by 1
index = this.parameterIndex - 1;
}
paramAnns = (index >= 0 && index < annotationArray.length ?
paramAnns = (index >= 0 && index < annotationArray.length && annotationArray[index].length > 0 ?
adaptAnnotationArray(annotationArray[index]) : EMPTY_ANNOTATION_ARRAY);
this.parameterAnnotations = paramAnns;
}
Expand Down Expand Up @@ -916,7 +916,7 @@ public Annotation[] getParameterAnnotations() {
merged.add(fieldAnn);
}
}
anns = merged.toArray(new Annotation[0]);
anns = merged.toArray(EMPTY_ANNOTATION_ARRAY);
}
}
catch (NoSuchFieldException | SecurityException ex) {
Expand Down

0 comments on commit 2b6639e

Please sign in to comment.