Avoid NoSuchMethodException for annotation attribute checks

Closes gh-32921
This commit is contained in:
Juergen Hoeller
2024-06-03 12:45:11 +02:00
parent 542ba3517f
commit b08883b65c

View File

@@ -1052,16 +1052,16 @@ public abstract class AnnotationUtils {
return null; return null;
} }
try { try {
Method method = annotation.annotationType().getDeclaredMethod(attributeName); for (Method method : annotation.annotationType().getDeclaredMethods()) {
return invokeAnnotationMethod(method, annotation); if (method.getName().equals(attributeName) && method.getParameterCount() == 0) {
} return invokeAnnotationMethod(method, annotation);
catch (NoSuchMethodException ex) { }
return null; }
} }
catch (Throwable ex) { catch (Throwable ex) {
handleValueRetrievalFailure(annotation, ex); handleValueRetrievalFailure(annotation, ex);
return null;
} }
return null;
} }
/** /**