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

View File

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