Polish ActiveProfilesUtils

This commit is contained in:
Sam Brannen 2020-11-03 14:46:17 +01:00
parent 0f6038af70
commit 5628c8cd63
1 changed files with 4 additions and 5 deletions

View File

@ -17,7 +17,6 @@
package org.springframework.test.context.support;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@ -110,15 +109,15 @@ abstract class ActiveProfilesUtils {
String[] profiles = resolver.resolve(rootDeclaringClass);
if (!ObjectUtils.isEmpty(profiles)) {
profileArrays.add(profiles);
// Prepend to the list so that we can later traverse "down" the hierarchy
// to ensure that we retain the top-down profile registration order
// within a test class hierarchy.
profileArrays.add(0, profiles);
}
descriptor = (annotation.inheritProfiles() ? descriptor.next() : null);
}
// Reverse the list so that we can traverse "down" the hierarchy.
Collections.reverse(profileArrays);
Set<String> activeProfiles = new LinkedHashSet<>();
for (String[] profiles : profileArrays) {
for (String profile : profiles) {