From a28447d5f871f2908462fe449ad319759eb28d9a Mon Sep 17 00:00:00 2001 From: Ioannis Canellos Date: Sat, 23 Apr 2016 11:35:17 +0300 Subject: [PATCH] Fix IllegalState issue when using the core module outside of kubernetes. --- .../kubernetes/config/ConfigMapPropertySourceLocator.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-cloud-kubernetes-core/src/main/java/io/fabric8/spring/cloud/kubernetes/config/ConfigMapPropertySourceLocator.java b/spring-cloud-kubernetes-core/src/main/java/io/fabric8/spring/cloud/kubernetes/config/ConfigMapPropertySourceLocator.java index ecedbf0d..6644463f 100644 --- a/spring-cloud-kubernetes-core/src/main/java/io/fabric8/spring/cloud/kubernetes/config/ConfigMapPropertySourceLocator.java +++ b/spring-cloud-kubernetes-core/src/main/java/io/fabric8/spring/cloud/kubernetes/config/ConfigMapPropertySourceLocator.java @@ -28,6 +28,7 @@ import org.springframework.core.env.PropertySource; public class ConfigMapPropertySourceLocator implements PropertySourceLocator { private static final String SPRING_APPLICATION_NAME = "spring.application.name"; + private static final String FALLBACK_APPLICATION_NAME = "application"; private final KubernetesClient client; private final ConfigMapConfigProperties properties; @@ -41,7 +42,7 @@ public class ConfigMapPropertySourceLocator implements PropertySourceLocator { public PropertySource locate(Environment environment) { if (environment instanceof ConfigurableEnvironment) { ConfigurableEnvironment env = (ConfigurableEnvironment) environment; - String appName = env.getProperty(SPRING_APPLICATION_NAME); + String appName = env.getProperty(SPRING_APPLICATION_NAME, FALLBACK_APPLICATION_NAME); String name = properties.getName() == null || properties.getName().isEmpty() ? appName : properties.getName(); String namespace = properties.getNamespace(); return new ConfigMapPropertySource(client, name, namespace);