Skip to content

Commit 7cc7004

Browse files
committed
HandlerMethod skips interface parameter introspection for return value
Fixes spring-projects#22303
1 parent 493e9c1 commit 7cc7004

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

spring-web/src/main/java/org/springframework/web/method/HandlerMethod.java

+19-17
Original file line numberDiff line numberDiff line change
@@ -480,26 +480,28 @@ public Annotation[] getParameterAnnotations() {
480480
Annotation[] anns = this.combinedAnnotations;
481481
if (anns == null) {
482482
anns = super.getParameterAnnotations();
483-
for (Annotation[][] ifcAnns : getInterfaceParameterAnnotations()) {
484-
int index = getParameterIndex();
485-
if (index < ifcAnns.length) {
486-
Annotation[] paramAnns = ifcAnns[index];
487-
if (paramAnns.length > 0) {
488-
List<Annotation> merged = new ArrayList<>(anns.length + paramAnns.length);
489-
merged.addAll(Arrays.asList(anns));
490-
for (Annotation paramAnn : paramAnns) {
491-
boolean existingType = false;
492-
for (Annotation ann : anns) {
493-
if (ann.annotationType() == paramAnn.annotationType()) {
494-
existingType = true;
495-
break;
483+
int index = getParameterIndex();
484+
if (index >= 0) {
485+
for (Annotation[][] ifcAnns : getInterfaceParameterAnnotations()) {
486+
if (index < ifcAnns.length) {
487+
Annotation[] paramAnns = ifcAnns[index];
488+
if (paramAnns.length > 0) {
489+
List<Annotation> merged = new ArrayList<>(anns.length + paramAnns.length);
490+
merged.addAll(Arrays.asList(anns));
491+
for (Annotation paramAnn : paramAnns) {
492+
boolean existingType = false;
493+
for (Annotation ann : anns) {
494+
if (ann.annotationType() == paramAnn.annotationType()) {
495+
existingType = true;
496+
break;
497+
}
498+
}
499+
if (!existingType) {
500+
merged.add(adaptAnnotation(paramAnn));
496501
}
497502
}
498-
if (!existingType) {
499-
merged.add(adaptAnnotation(paramAnn));
500-
}
503+
anns = merged.toArray(new Annotation[0]);
501504
}
502-
anns = merged.toArray(new Annotation[0]);
503505
}
504506
}
505507
}

0 commit comments

Comments
 (0)