Skip to content

Commit 37a1354

Browse files
committed
Rely on standard @repeatable support in AnnotationJmxAttributeSource
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
1 parent 13efc22 commit 37a1354

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

spring-context/src/main/java/org/springframework/jmx/export/annotation/AnnotationJmxAttributeSource.java

+4-11
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import org.springframework.core.annotation.MergedAnnotationPredicates;
4242
import org.springframework.core.annotation.MergedAnnotations;
4343
import org.springframework.core.annotation.MergedAnnotations.SearchStrategy;
44-
import org.springframework.core.annotation.RepeatableContainers;
4544
import org.springframework.jmx.export.metadata.InvalidMetadataException;
4645
import org.springframework.jmx.export.metadata.JmxAttributeSource;
4746
import org.springframework.util.StringUtils;
@@ -152,29 +151,23 @@ public void setBeanFactory(BeanFactory beanFactory) {
152151
public org.springframework.jmx.export.metadata.@Nullable ManagedOperationParameter[] getManagedOperationParameters(
153152
Method method) throws InvalidMetadataException {
154153

155-
List<MergedAnnotation<? extends Annotation>> anns = getRepeatableAnnotations(
156-
method, ManagedOperationParameter.class, ManagedOperationParameters.class);
157-
154+
List<MergedAnnotation<? extends Annotation>> anns = getRepeatableAnnotations(method, ManagedOperationParameter.class);
158155
return copyPropertiesToBeanArray(anns, org.springframework.jmx.export.metadata.ManagedOperationParameter.class);
159156
}
160157

161158
@Override
162159
public org.springframework.jmx.export.metadata.@Nullable ManagedNotification[] getManagedNotifications(Class<?> clazz)
163160
throws InvalidMetadataException {
164161

165-
List<MergedAnnotation<? extends Annotation>> anns = getRepeatableAnnotations(
166-
clazz, ManagedNotification.class, ManagedNotifications.class);
167-
162+
List<MergedAnnotation<? extends Annotation>> anns = getRepeatableAnnotations(clazz, ManagedNotification.class);
168163
return copyPropertiesToBeanArray(anns, org.springframework.jmx.export.metadata.ManagedNotification.class);
169164
}
170165

171166

172167
private static List<MergedAnnotation<? extends Annotation>> getRepeatableAnnotations(
173-
AnnotatedElement annotatedElement, Class<? extends Annotation> annotationType,
174-
Class<? extends Annotation> containerAnnotationType) {
168+
AnnotatedElement annotatedElement, Class<? extends Annotation> annotationType) {
175169

176-
return MergedAnnotations.from(annotatedElement, SearchStrategy.TYPE_HIERARCHY,
177-
RepeatableContainers.of(annotationType, containerAnnotationType))
170+
return MergedAnnotations.from(annotatedElement, SearchStrategy.TYPE_HIERARCHY)
178171
.stream(annotationType)
179172
.filter(MergedAnnotationPredicates.firstRunOf(MergedAnnotation::getAggregateIndex))
180173
.map(MergedAnnotation::withNonMergedAttributes)

0 commit comments

Comments
 (0)