diff --git a/spring-cloud-config-client/src/main/java/org/springframework/cloud/config/client/ConfigServerConfigDataLoader.java b/spring-cloud-config-client/src/main/java/org/springframework/cloud/config/client/ConfigServerConfigDataLoader.java index 6f7f804310..2b173d3c72 100644 --- a/spring-cloud-config-client/src/main/java/org/springframework/cloud/config/client/ConfigServerConfigDataLoader.java +++ b/spring-cloud-config-client/src/main/java/org/springframework/cloud/config/client/ConfigServerConfigDataLoader.java @@ -132,14 +132,17 @@ public ConfigData doLoad(ConfigDataLoaderContext context, ConfigServerConfigData log(result); // result.getPropertySources() can be null if using xml + Map, String> propertySourceProfiles = new HashMap<>(); if (result.getPropertySources() != null) { for (org.springframework.cloud.config.environment.PropertySource source : result .getPropertySources()) { @SuppressWarnings("unchecked") Map map = translateOrigins(source.getName(), (Map) source.getSource()); - propertySources.add(0, - new OriginTrackedMapPropertySource("configserver:" + source.getName(), map, true)); + OriginTrackedMapPropertySource propertySource = new OriginTrackedMapPropertySource( + "configserver:" + source.getName(), map, true); + propertySources.add(0, propertySource); + propertySourceProfiles.put(propertySource, source.getProfile()); } } @@ -165,31 +168,37 @@ else if (ALL_OPTIONS.size() > 2) { // boot 2.4.5+ return new ConfigData(propertySources, propertySource -> { String propertySourceName = propertySource.getName(); + String profile = propertySourceProfiles.get(propertySource); List