Defensive error reporting when StandardAnnotationMetadata introspects declared methods

Issue: SPR-13791
This commit is contained in:
Juergen Hoeller 2015-12-14 15:13:29 +01:00
parent 21329df7e1
commit a36c0a50e6
1 changed files with 23 additions and 13 deletions

View File

@ -131,6 +131,7 @@ public class StandardAnnotationMetadata extends StandardClassMetadata implements
@Override
public boolean hasAnnotatedMethods(String annotationName) {
try {
Method[] methods = getIntrospectedClass().getDeclaredMethods();
for (Method method : methods) {
if (!method.isBridge() && method.getAnnotations().length > 0 &&
@ -140,9 +141,14 @@ public class StandardAnnotationMetadata extends StandardClassMetadata implements
}
return false;
}
catch (Throwable ex) {
throw new IllegalStateException("Failed to introspect annotated methods on " + getIntrospectedClass(), ex);
}
}
@Override
public Set<MethodMetadata> getAnnotatedMethods(String annotationName) {
try {
Method[] methods = getIntrospectedClass().getDeclaredMethods();
Set<MethodMetadata> annotatedMethods = new LinkedHashSet<MethodMetadata>();
for (Method method : methods) {
@ -153,5 +159,9 @@ public class StandardAnnotationMetadata extends StandardClassMetadata implements
}
return annotatedMethods;
}
catch (Throwable ex) {
throw new IllegalStateException("Failed to introspect annotated methods on " + getIntrospectedClass(), ex);
}
}
}