diff --git a/spring-cloud-context/src/main/java/org/springframework/cloud/context/refresh/ContextRefresher.java b/spring-cloud-context/src/main/java/org/springframework/cloud/context/refresh/ContextRefresher.java index 981493929..45f90637f 100644 --- a/spring-cloud-context/src/main/java/org/springframework/cloud/context/refresh/ContextRefresher.java +++ b/spring-cloud-context/src/main/java/org/springframework/cloud/context/refresh/ContextRefresher.java @@ -163,11 +163,12 @@ private boolean equal(Object one, Object two) { private Map extract(MutablePropertySources propertySources) { Map result = new HashMap<>(); - List> sources = new ArrayList<>(); + List> sources = new ArrayList<>(propertySources.size()); for (PropertySource source : propertySources) { - sources.add(0, source); + sources.add(source); } - for (PropertySource source : sources) { + for (int i = sources.size() - 1; i >= 0; i--) { + PropertySource source = sources.get(i); if (!this.standardSources.contains(source.getName())) { extract(source, result); } @@ -180,10 +181,10 @@ private void extract(PropertySource parent, Map result) { try { List> sources = new ArrayList<>(); for (PropertySource source : ((CompositePropertySource) parent).getPropertySources()) { - sources.add(0, source); + sources.add(source); } - for (PropertySource source : sources) { - extract(source, result); + for (int i = sources.size() - 1; i >= 0; i--) { + extract(sources.get(i), result); } } catch (Exception e) {