Skip to content

Commit 8b589db

Browse files
committed
Avoid NoSuchMethodException for annotation attribute checks
Closes gh-32921 (cherry picked from commit b08883b)
1 parent aed1d5f commit 8b589db

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,16 +1049,16 @@ public static Object getValue(@Nullable Annotation annotation, @Nullable String
10491049
return null;
10501050
}
10511051
try {
1052-
Method method = annotation.annotationType().getDeclaredMethod(attributeName);
1053-
return invokeAnnotationMethod(method, annotation);
1054-
}
1055-
catch (NoSuchMethodException ex) {
1056-
return null;
1052+
for (Method method : annotation.annotationType().getDeclaredMethods()) {
1053+
if (method.getName().equals(attributeName) && method.getParameterCount() == 0) {
1054+
return invokeAnnotationMethod(method, annotation);
1055+
}
1056+
}
10571057
}
10581058
catch (Throwable ex) {
10591059
handleValueRetrievalFailure(annotation, ex);
1060-
return null;
10611060
}
1061+
return null;
10621062
}
10631063

10641064
/**

0 commit comments

Comments
 (0)