From 37a135447cf58c69ea836a264390e55f1e17bbdc Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Sat, 15 Mar 2025 16:56:48 +0100 Subject: [PATCH] Rely on standard @Repeatable support in AnnotationJmxAttributeSource MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit removes the use of RepeatableContainers.of() in AnnotationJmxAttributeSource since that is unnecessary when using the MergedAnnotations API with @⁠Repeatable annotations such as @⁠ManagedOperationParameter and @⁠ManagedNotification. Closes gh-34606 --- .../annotation/AnnotationJmxAttributeSource.java | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/jmx/export/annotation/AnnotationJmxAttributeSource.java b/spring-context/src/main/java/org/springframework/jmx/export/annotation/AnnotationJmxAttributeSource.java index 7afd0c3c6af..076b652fb9a 100644 --- a/spring-context/src/main/java/org/springframework/jmx/export/annotation/AnnotationJmxAttributeSource.java +++ b/spring-context/src/main/java/org/springframework/jmx/export/annotation/AnnotationJmxAttributeSource.java @@ -41,7 +41,6 @@ import org.springframework.core.annotation.MergedAnnotation; import org.springframework.core.annotation.MergedAnnotationPredicates; import org.springframework.core.annotation.MergedAnnotations; import org.springframework.core.annotation.MergedAnnotations.SearchStrategy; -import org.springframework.core.annotation.RepeatableContainers; import org.springframework.jmx.export.metadata.InvalidMetadataException; import org.springframework.jmx.export.metadata.JmxAttributeSource; import org.springframework.util.StringUtils; @@ -152,9 +151,7 @@ public class AnnotationJmxAttributeSource implements JmxAttributeSource, BeanFac public org.springframework.jmx.export.metadata.@Nullable ManagedOperationParameter[] getManagedOperationParameters( Method method) throws InvalidMetadataException { - List> anns = getRepeatableAnnotations( - method, ManagedOperationParameter.class, ManagedOperationParameters.class); - + List> anns = getRepeatableAnnotations(method, ManagedOperationParameter.class); return copyPropertiesToBeanArray(anns, org.springframework.jmx.export.metadata.ManagedOperationParameter.class); } @@ -162,19 +159,15 @@ public class AnnotationJmxAttributeSource implements JmxAttributeSource, BeanFac public org.springframework.jmx.export.metadata.@Nullable ManagedNotification[] getManagedNotifications(Class clazz) throws InvalidMetadataException { - List> anns = getRepeatableAnnotations( - clazz, ManagedNotification.class, ManagedNotifications.class); - + List> anns = getRepeatableAnnotations(clazz, ManagedNotification.class); return copyPropertiesToBeanArray(anns, org.springframework.jmx.export.metadata.ManagedNotification.class); } private static List> getRepeatableAnnotations( - AnnotatedElement annotatedElement, Class annotationType, - Class containerAnnotationType) { + AnnotatedElement annotatedElement, Class annotationType) { - return MergedAnnotations.from(annotatedElement, SearchStrategy.TYPE_HIERARCHY, - RepeatableContainers.of(annotationType, containerAnnotationType)) + return MergedAnnotations.from(annotatedElement, SearchStrategy.TYPE_HIERARCHY) .stream(annotationType) .filter(MergedAnnotationPredicates.firstRunOf(MergedAnnotation::getAggregateIndex)) .map(MergedAnnotation::withNonMergedAttributes)