From 433877e5cb6230e9c3a325d596c23281872c1c0f Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 11 Apr 2018 12:50:27 +0200 Subject: [PATCH] AnnotationUtils.getAnnotation non-null check for synthesizeAnnotation Issue: SPR-16708 (cherry picked from commit da80502) --- .../org/springframework/core/annotation/AnnotationUtils.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java index ea3facd7c9..54b64dbaac 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java @@ -126,6 +126,7 @@ public abstract class AnnotationUtils { private static final Map, Set> annotatedBaseTypeCache = new ConcurrentReferenceHashMap<>(256); + @SuppressWarnings("unused") @Deprecated // just here for older tool versions trying to reflectively clear the cache private static final Map, ?> annotatedInterfaceCache = annotatedBaseTypeCache; @@ -165,7 +166,8 @@ public abstract class AnnotationUtils { } Class annotatedElement = annotation.annotationType(); try { - return synthesizeAnnotation(annotatedElement.getAnnotation(annotationType), annotatedElement); + A metaAnn = annotatedElement.getAnnotation(annotationType); + return (metaAnn != null ? synthesizeAnnotation(metaAnn, annotatedElement) : null); } catch (Throwable ex) { handleIntrospectionFailure(annotatedElement, ex);