diff --git a/spring-test/src/main/java/org/springframework/test/context/support/TestPropertySourceUtils.java b/spring-test/src/main/java/org/springframework/test/context/support/TestPropertySourceUtils.java index ff2f28c4b7b..40f6c709342 100644 --- a/spring-test/src/main/java/org/springframework/test/context/support/TestPropertySourceUtils.java +++ b/spring-test/src/main/java/org/springframework/test/context/support/TestPropertySourceUtils.java @@ -79,6 +79,9 @@ public abstract class TestPropertySourceUtils { private static final PropertySourceFactory defaultPropertySourceFactory = new DefaultPropertySourceFactory(); + private static Comparator> reversedMetaDistance = + Comparator.> comparingInt(MergedAnnotation::getDistance).reversed(); + private static final Log logger = LogFactory.getLog(TestPropertySourceUtils.class); @@ -426,7 +429,7 @@ public abstract class TestPropertySourceUtils { MergedAnnotations.from(clazz, SearchStrategy.DIRECT) .stream(annotationType) - .sorted(highMetaDistancesFirst()) + .sorted(reversedMetaDistance) .forEach(annotation -> listOfLists.get(aggregateIndex[0]).add(0, annotation)); aggregateIndex[0]++; @@ -448,10 +451,6 @@ public abstract class TestPropertySourceUtils { } } - private static Comparator> highMetaDistancesFirst() { - return Comparator.> comparingInt(MergedAnnotation::getDistance).reversed(); - } - /** * Extension of {@link Properties} that mimics a {@code SequencedMap} by * tracking all added properties in the supplied {@link LinkedHashMap}.