AnnotationAttributesReadingVisitor defensively handles meta-annotation retrieval failure
Issue: SPR-12493
This commit is contained in:
parent
1aad4da6b6
commit
5018889d78
|
@ -131,7 +131,8 @@ public abstract class AnnotationUtils {
|
|||
/**
|
||||
* Get all {@link Annotation Annotations} from the supplied Method, Constructor or Field.
|
||||
* @param annotatedElement the Method, Constructor or Field to retrieve annotations from
|
||||
* @return the annotations found
|
||||
* @return the annotations found, or {@code null} if not resolvable (e.g. because nested
|
||||
* Class values in annotation attributes failed to resolve at runtime)
|
||||
* @since 4.0.8
|
||||
*/
|
||||
public static Annotation[] getAnnotations(AnnotatedElement annotatedElement) {
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.util.Set;
|
|||
import org.springframework.core.annotation.AnnotationAttributes;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* ASM visitor which looks for the annotations defined on a class or method, including
|
||||
|
@ -72,11 +73,14 @@ final class AnnotationAttributesReadingVisitor extends RecursiveAnnotationAttrib
|
|||
attributes.add(0, this.attributes);
|
||||
}
|
||||
Set<String> metaAnnotationTypeNames = new LinkedHashSet<String>();
|
||||
for (Annotation metaAnnotation : AnnotationUtils.getAnnotations(annotationClass)) {
|
||||
Annotation[] metaAnnotations = AnnotationUtils.getAnnotations(annotationClass);
|
||||
if (!ObjectUtils.isEmpty(metaAnnotations)) {
|
||||
for (Annotation metaAnnotation : metaAnnotations) {
|
||||
if (!AnnotationUtils.isInJavaLangAnnotationPackage(metaAnnotation)) {
|
||||
recursivelyCollectMetaAnnotations(metaAnnotationTypeNames, metaAnnotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.metaAnnotationMap != null) {
|
||||
this.metaAnnotationMap.put(annotationClass.getName(), metaAnnotationTypeNames);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue