diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java index 0a0a4f0939..f74a0693a0 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java @@ -34,6 +34,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.springframework.core.Ordered; @@ -964,6 +965,25 @@ class AnnotationUtilsTests { TestRepeatableContainer.class)).isNotNull(); } + @Test // gh-23856 + void findAnnotationFindsRepeatableContainerOnComposedAnnotationMetaAnnotatedWithRepeatableAnnotations() { + MyRepeatableContainer annotation = AnnotationUtils.findAnnotation(MyRepeatableMeta1And2.class, MyRepeatableContainer.class); + + assertThat(annotation).isNotNull(); + assertThat(annotation.value()).extracting(MyRepeatable::value).containsExactly("meta1", "meta2"); + } + + @Test // gh-23856 + @Disabled("disabled until gh-23856 is resolved") + void findAnnotationFindsRepeatableContainerOnComposedAnnotationMetaAnnotatedWithRepeatableAnnotationsOnMethod() throws NoSuchMethodException { + Method method = getClass().getDeclaredMethod("methodWithComposedAnnotationMetaAnnotatedWithRepeatableAnnotations"); + MyRepeatableContainer annotation = AnnotationUtils.findAnnotation(method, MyRepeatableContainer.class); + + assertThat(annotation).isNotNull(); + assertThat(annotation.value()).extracting(MyRepeatable::value).containsExactly("meta1", "meta2"); + } + + @SafeVarargs static T[] asArray(T... arr) { return arr; @@ -1262,6 +1282,17 @@ class AnnotationUtilsTests { @interface MyRepeatableMeta2 { } + @Retention(RetentionPolicy.RUNTIME) + @Inherited + @MyRepeatable("meta1") + @MyRepeatable("meta2") + @interface MyRepeatableMeta1And2 { + } + + @MyRepeatableMeta1And2 + void methodWithComposedAnnotationMetaAnnotatedWithRepeatableAnnotations() { + } + interface InterfaceWithRepeated { @MyRepeatable("A")