Skip to content

Commit a0357f4

Browse files
committed
Fix merge
1 parent 80aa935 commit a0357f4

File tree

1 file changed

+35
-14
lines changed

1 file changed

+35
-14
lines changed

spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/AwsS3EnvironmentRepository.java

+35-14
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public Environment findOne(String specifiedApplication, String specifiedProfiles
8989

9090
String[] profileArray = parseProfiles(profiles);
9191
List<String> apps = Arrays.asList(StringUtils.commaDelimitedListToStringArray(application.replace(" ", "")));
92+
Collections.reverse(apps);
9293
if (!apps.contains(serverProperties.getDefaultApplicationName())) {
9394
apps = new ArrayList<>(apps);
9495
apps.add(serverProperties.getDefaultApplicationName());
@@ -97,7 +98,16 @@ public Environment findOne(String specifiedApplication, String specifiedProfiles
9798
final Environment environment = new Environment(application, profileArray);
9899
environment.setLabel(label);
99100

100-
addPropertySources(environment, apps, profileArray, label);
101+
List<String> labels;
102+
if (StringUtils.hasText(label) && label.contains(",")) {
103+
labels = Arrays.asList(StringUtils.commaDelimitedListToStringArray(label));
104+
Collections.reverse(labels);
105+
}
106+
else {
107+
labels = Collections.singletonList(label);
108+
}
109+
110+
addPropertySources(environment, apps, profileArray, labels);
101111

102112
if (LOG.isDebugEnabled()) {
103113
LOG.debug("Returning Environment: " + environment);
@@ -106,25 +116,36 @@ public Environment findOne(String specifiedApplication, String specifiedProfiles
106116
return environment;
107117
}
108118

109-
private void addPropertySources(Environment environment, List<String> apps, String[] profiles, String label) {
110-
// If we have profiles, add property sources with those profiles
111-
for (String profile : profiles) {
112-
addPropertySourcesForApps(apps, app -> addProfileSpecificPropertySource(environment, app, profile, label));
119+
private void addPropertySources(Environment environment, List<String> apps, String[] profiles,
120+
List<String> labels) {
121+
for (String label : labels) {
122+
// If we have profiles, add property sources with those profiles
123+
for (String profile : profiles) {
124+
addPropertySourcesForApps(apps,
125+
app -> addProfileSpecificPropertySource(environment, app, profile, label));
126+
}
113127
}
114128

115129
// If we have no profiles just add property sources for all apps
116130
if (profiles.length == 0) {
117-
addPropertySourcesForApps(apps, app -> addNonProfileSpecificPropertySource(environment, app, null, label));
131+
for (String label : labels) {
132+
addPropertySourcesForApps(apps,
133+
app -> addNonProfileSpecificPropertySource(environment, app, null, label));
134+
}
118135
}
119136
else {
120-
// If we have profiles, we still need to add property sources from files that
121-
// are not profile specific but we pass
122-
// along the profiles as well so we can check if any non-profile specific YAML
123-
// files have profile specific documents
124-
// within them
125-
for (String profile : profiles) {
126-
addPropertySourcesForApps(apps,
127-
app -> addNonProfileSpecificPropertySource(environment, app, profile, label));
137+
for (String label : labels) {
138+
// If we have profiles, we still need to add property sources from files
139+
// that
140+
// are not profile specific but we pass
141+
// along the profiles as well so we can check if any non-profile specific
142+
// YAML
143+
// files have profile specific documents
144+
// within them
145+
for (String profile : profiles) {
146+
addPropertySourcesForApps(apps,
147+
app -> addNonProfileSpecificPropertySource(environment, app, profile, label));
148+
}
128149
}
129150
}
130151
}

0 commit comments

Comments
 (0)