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

(cherry picked from commit b08883b)
  • Loading branch information
jhoeller committed Jun 3, 2024
1 parent 2384474 commit d410485
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 d410485

Please sign in to comment.