Skip to content

Commit 5ac687f

Browse files
committed
Add warning to AnnotatedElementUtils.getMergedRepeatableAnnotations()
See gh-20279
1 parent 332b25b commit 5ac687f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

spring-core/src/main/java/org/springframework/core/annotation/AnnotatedElementUtils.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,16 @@ public static <A extends Annotation> Set<A> getMergedRepeatableAnnotations(
433433
* single annotation and within annotation hierarchies.
434434
* <p>This method follows <em>get semantics</em> as described in the
435435
* {@linkplain AnnotatedElementUtils class-level javadoc}.
436+
* <p><strong>WARNING</strong>: if the supplied {@code containerType} is not
437+
* {@code null}, the search will be restricted to supporting only repeatable
438+
* annotations whose container is the supplied {@code containerType}. This
439+
* prevents the search from finding repeatable annotations declared as
440+
* meta-annotations on other types of repeatable annotations. If you need to
441+
* support such a use case, favor {@link #getMergedRepeatableAnnotations(AnnotatedElement, Class)}
442+
* over this method or alternatively use the {@link MergedAnnotations} API
443+
* directly in conjunction with {@link RepeatableContainers} that are
444+
* {@linkplain RepeatableContainers#and(Class, Class) composed} to support
445+
* multiple repeatable annotation types.
436446
* @param element the annotated element (never {@code null})
437447
* @param annotationType the annotation type to find (never {@code null})
438448
* @param containerType the type of the container that holds the annotations;

0 commit comments

Comments
 (0)