From 5ac687f4aa30d66423a52746bbb623b8b04e168a Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 11 Oct 2022 20:49:19 +0200 Subject: [PATCH] Add warning to AnnotatedElementUtils.getMergedRepeatableAnnotations() See gh-20279 --- .../core/annotation/AnnotatedElementUtils.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotatedElementUtils.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotatedElementUtils.java index 3302aaca947..40c006b5e9d 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotatedElementUtils.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotatedElementUtils.java @@ -433,6 +433,16 @@ public abstract class AnnotatedElementUtils { * single annotation and within annotation hierarchies. *

This method follows get semantics as described in the * {@linkplain AnnotatedElementUtils class-level javadoc}. + *

WARNING: if the supplied {@code containerType} is not + * {@code null}, the search will be restricted to supporting only repeatable + * annotations whose container is the supplied {@code containerType}. This + * prevents the search from finding repeatable annotations declared as + * meta-annotations on other types of repeatable annotations. If you need to + * support such a use case, favor {@link #getMergedRepeatableAnnotations(AnnotatedElement, Class)} + * over this method or alternatively use the {@link MergedAnnotations} API + * directly in conjunction with {@link RepeatableContainers} that are + * {@linkplain RepeatableContainers#and(Class, Class) composed} to support + * multiple repeatable annotation types. * @param element the annotated element (never {@code null}) * @param annotationType the annotation type to find (never {@code null}) * @param containerType the type of the container that holds the annotations;