From ef19c34666da5198e50edf6cef0588151f29007c Mon Sep 17 00:00:00 2001 From: Spencer Gibb Date: Mon, 1 May 2017 10:25:39 -0600 Subject: [PATCH] Work around https://github.com/spring-projects/spring-boot/issues/9053#issuecomment-298362685 --- .../bootstrap/BootstrapApplicationListener.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/BootstrapApplicationListener.java b/spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/BootstrapApplicationListener.java index 72e98a14..d1c3903a 100644 --- a/spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/BootstrapApplicationListener.java +++ b/spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/BootstrapApplicationListener.java @@ -155,12 +155,7 @@ public class BootstrapApplicationListener environment.getProperty("spring.cloud.bootstrap.sources", ""))) { names.add(name); } - // TODO: is it possible or sensible to share a ResourceLoader? - SpringApplicationBuilder builder = new SpringApplicationBuilder() - .profiles(environment.getActiveProfiles()).bannerMode(Mode.OFF) - .environment(bootstrapEnvironment) - .properties("spring.application.name:" + configName) - .registerShutdownHook(false).logStartupInfo(false).web(NONE); + List> sources = new ArrayList<>(); for (String name : names) { Class cls = ClassUtils.resolveClassName(name, null); @@ -173,7 +168,15 @@ public class BootstrapApplicationListener sources.add(cls); } AnnotationAwareOrderComparator.sort(sources); - builder.sources(sources.toArray(new Class[sources.size()])); + + // TODO: is it possible or sensible to share a ResourceLoader? + SpringApplicationBuilder builder = new SpringApplicationBuilder(sources.toArray(new Class[sources.size()])) + .profiles(environment.getActiveProfiles()).bannerMode(Mode.OFF) + .environment(bootstrapEnvironment) + .properties("spring.application.name:" + configName) + .registerShutdownHook(false).logStartupInfo(false).web(NONE); + // Move back to below when https://github.com/spring-projects/spring-boot/issues/9053 is fixed + // builder.sources(sources.toArray(new Class[sources.size()])); final ConfigurableApplicationContext context = builder.run(); // Make the bootstrap context a parent of the app context addAncestorInitializer(application, context);