Skip to content

Commit

Permalink
Avoid NoSuchMethodException for annotation attribute checks
Browse files Browse the repository at this point in the history
Closes gh-32921
  • Loading branch information
jhoeller committed Jun 3, 2024
1 parent 542ba35 commit b08883b
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1052,16 +1052,16 @@ public static Object getValue(@Nullable Annotation annotation, @Nullable String
return null;
}
try {
Method method = annotation.annotationType().getDeclaredMethod(attributeName);
return invokeAnnotationMethod(method, annotation);
}
catch (NoSuchMethodException ex) {
return null;
for (Method method : annotation.annotationType().getDeclaredMethods()) {
if (method.getName().equals(attributeName) && method.getParameterCount() == 0) {
return invokeAnnotationMethod(method, annotation);
}
}
}
catch (Throwable ex) {
handleValueRetrievalFailure(annotation, ex);
return null;
}
return null;
}

/**
Expand Down

0 comments on commit b08883b

Please sign in to comment.