diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMappings.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMappings.java index 7032c736050d..7bd535086ee5 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMappings.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMappings.java @@ -89,7 +89,7 @@ private void addMetaAnnotationsToQueue(Deque queue, Annot Annotation[] repeatedAnnotations = this.repeatableContainers.findRepeatedAnnotations(metaAnnotation); if (repeatedAnnotations != null) { for (Annotation repeatedAnnotation : repeatedAnnotations) { - if (!isMappable(source, metaAnnotation)) { + if (!isMappable(source, repeatedAnnotation)) { continue; } addIfPossible(queue, source, repeatedAnnotation); diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java index 571373234bce..220e2938240e 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java @@ -37,6 +37,7 @@ import org.springframework.core.annotation.AnnotationTypeMapping.MirrorSets; import org.springframework.core.annotation.AnnotationTypeMapping.MirrorSets.MirrorSet; import org.springframework.lang.UsesSunMisc; +import org.springframework.util.ObjectUtils; import org.springframework.util.ReflectionUtils; import static java.util.stream.Collectors.toList; @@ -476,6 +477,16 @@ private Method[] resolveMirrorSets(AnnotationTypeMapping mapping, Class eleme return result; } + @Test + void forAnnotationTypeWhenRepeatableMetaAnnotationFilterd() { + AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(WithRepeatedMetaAnnotations.class, + annotationType -> + ObjectUtils.nullSafeEquals(annotationType, Repeating.class.getName())); + assertThat(getAll(mappings)).flatExtracting( + AnnotationTypeMapping::getAnnotationType).containsExactly( + WithRepeatedMetaAnnotations.class); + } + @Nullable private Method getAliasMapping(AnnotationTypeMapping mapping, int attributeIndex) { int mapped = mapping.getAliasMapping(attributeIndex);