Skip to content

Commit d410485

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

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -1052,16 +1052,16 @@ public static Object getValue(@Nullable Annotation annotation, @Nullable String
10521052
return null;
10531053
}
10541054
try {
1055-
Method method = annotation.annotationType().getDeclaredMethod(attributeName);
1056-
return invokeAnnotationMethod(method, annotation);
1057-
}
1058-
catch (NoSuchMethodException ex) {
1059-
return null;
1055+
for (Method method : annotation.annotationType().getDeclaredMethods()) {
1056+
if (method.getName().equals(attributeName) && method.getParameterCount() == 0) {
1057+
return invokeAnnotationMethod(method, annotation);
1058+
}
1059+
}
10601060
}
10611061
catch (Throwable ex) {
10621062
handleValueRetrievalFailure(annotation, ex);
1063-
return null;
10641063
}
1064+
return null;
10651065
}
10661066

10671067
/**

0 commit comments

Comments
 (0)