From 2c726b2c4bc1c3c4d2b4364b328e04d469d485bd Mon Sep 17 00:00:00 2001 From: Spencer Gibb Date: Thu, 25 Aug 2016 11:29:32 -0600 Subject: [PATCH] Guard for when result.getPropertySources() is null. fixes gh-488 --- .../client/ConfigServicePropertySourceLocator.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/spring-cloud-config-client/src/main/java/org/springframework/cloud/config/client/ConfigServicePropertySourceLocator.java b/spring-cloud-config-client/src/main/java/org/springframework/cloud/config/client/ConfigServicePropertySourceLocator.java index b00d55e4..f0559ede 100644 --- a/spring-cloud-config-client/src/main/java/org/springframework/cloud/config/client/ConfigServicePropertySourceLocator.java +++ b/spring-cloud-config-client/src/main/java/org/springframework/cloud/config/client/ConfigServicePropertySourceLocator.java @@ -85,12 +85,14 @@ public class ConfigServicePropertySourceLocator implements PropertySourceLocator result.getProfiles() == null ? "" : Arrays.asList(result.getProfiles()), result.getLabel(), result.getVersion())); - for (PropertySource source : result.getPropertySources()) { - @SuppressWarnings("unchecked") - Map map = (Map) source - .getSource(); - composite.addPropertySource(new MapPropertySource(source - .getName(), map)); + if (result.getPropertySources() != null) { // result.getPropertySources() can be null if using xml + for (PropertySource source : result.getPropertySources()) { + @SuppressWarnings("unchecked") + Map map = (Map) source + .getSource(); + composite.addPropertySource(new MapPropertySource(source + .getName(), map)); + } } return composite; }