Skip to content

Commit 28f2b7a

Browse files
authored
Reverse app names when fetching s3 data (#2652)
This matches the behavior of other EnvironmentRepositories like Git. #Fixes #2642
1 parent 1018c39 commit 28f2b7a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public Environment findOne(String specifiedApplication, String specifiedProfiles
8686

8787
String[] profileArray = parseProfiles(profiles);
8888
List<String> apps = Arrays.asList(StringUtils.commaDelimitedListToStringArray(application.replace(" ", "")));
89+
Collections.reverse(apps);
8990
if (!apps.contains(serverProperties.getDefaultApplicationName())) {
9091
apps = new ArrayList<>(apps);
9192
apps.add(serverProperties.getDefaultApplicationName());

spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/AwsS3EnvironmentRepositoryTests.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,12 @@ public void findWithVersion() throws UnsupportedEncodingException {
257257

258258
@Test
259259
public void findWithMultipleApplicationAllFound() throws UnsupportedEncodingException {
260-
putFiles("foo-profile1.yml", jsonContent);
261-
String versionId = putFiles("bar-profile1.yml", jsonContent);
260+
String versionId = putFiles("foo-profile1.yml", jsonContent);
261+
putFiles("bar-profile1.yml", jsonContent);
262262

263263
final Environment env = envRepo.findOne("foo,bar", "profile1", null);
264+
assertThat(env.getPropertySources().get(0).getName()).isEqualTo("s3:bar-profile1");
265+
assertThat(env.getPropertySources().get(1).getName()).isEqualTo("s3:foo-profile1");
264266

265267
assertExpectedEnvironment(env, "foo,bar", null, versionId, 2, "profile1");
266268

0 commit comments

Comments
 (0)