Browse Source

Avoid NoSuchMethodException for annotation attribute checks

Closes gh-32921
pull/33047/head
Juergen Hoeller 2 years ago
parent
commit
b08883b65c
  1. 12
      spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java

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

@ -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;
} }
/** /**

Loading…
Cancel
Save