From b077e4cd85830efdd5679795e1baba13c903abe8 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 4 Nov 2020 14:42:19 +0100 Subject: [PATCH] Use MergedAnnotationCollectors again in TestContextAnnotationUtils See gh-26031 --- .../test/context/TestContextAnnotationUtils.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/context/TestContextAnnotationUtils.java b/spring-test/src/main/java/org/springframework/test/context/TestContextAnnotationUtils.java index be74ddf721..62300498b6 100644 --- a/spring-test/src/main/java/org/springframework/test/context/TestContextAnnotationUtils.java +++ b/spring-test/src/main/java/org/springframework/test/context/TestContextAnnotationUtils.java @@ -19,15 +19,14 @@ package org.springframework.test.context; import java.lang.annotation.Annotation; import java.util.Collections; import java.util.HashSet; -import java.util.LinkedHashSet; import java.util.Set; import java.util.function.Predicate; -import java.util.stream.Collectors; import org.springframework.core.SpringProperties; import org.springframework.core.annotation.AnnotatedElementUtils; import org.springframework.core.annotation.AnnotationUtils; import org.springframework.core.annotation.MergedAnnotation; +import org.springframework.core.annotation.MergedAnnotationCollectors; import org.springframework.core.annotation.MergedAnnotationPredicates; import org.springframework.core.annotation.MergedAnnotations; import org.springframework.core.annotation.MergedAnnotations.SearchStrategy; @@ -147,8 +146,7 @@ public abstract class TestContextAnnotationUtils { // Present (via @Inherited semantics), directly present, or meta-present? Set mergedAnnotations = MergedAnnotations.from(clazz, SearchStrategy.INHERITED_ANNOTATIONS) .stream(annotationType) - .map(MergedAnnotation::synthesize) - .collect(Collectors.toCollection(LinkedHashSet::new)); + .collect(MergedAnnotationCollectors.toAnnotationSet()); if (!mergedAnnotations.isEmpty()) { return mergedAnnotations; @@ -557,8 +555,7 @@ public abstract class TestContextAnnotationUtils { return MergedAnnotations.from(getRootDeclaringClass(), searchStrategy, RepeatableContainers.none()) .stream(getAnnotationType()) .filter(MergedAnnotationPredicates.firstRunOf(MergedAnnotation::getAggregateIndex)) - .map(MergedAnnotation::synthesize) - .collect(Collectors.toCollection(LinkedHashSet::new)); + .collect(MergedAnnotationCollectors.toAnnotationSet()); } /**