Commit 32d481df by Dave Syer

Be defensive about classpath in eureka auto config

Before this change we were seeing test failures in spring-cloud-netflix-eureka-server (but only with Spring Boot 1.4) caused by annotation processing explosion when RefreshScopeAutoConfiguration is not on the classpath.
parent b084eb03
...@@ -70,7 +70,7 @@ import static org.springframework.cloud.commons.util.IdUtils.getDefaultInstanceI ...@@ -70,7 +70,7 @@ import static org.springframework.cloud.commons.util.IdUtils.getDefaultInstanceI
@ConditionalOnProperty(value = "eureka.client.enabled", matchIfMissing = true) @ConditionalOnProperty(value = "eureka.client.enabled", matchIfMissing = true)
@AutoConfigureBefore({ NoopDiscoveryClientAutoConfiguration.class, @AutoConfigureBefore({ NoopDiscoveryClientAutoConfiguration.class,
CommonsClientAutoConfiguration.class }) CommonsClientAutoConfiguration.class })
@AutoConfigureAfter(RefreshAutoConfiguration.class) @AutoConfigureAfter(name = "org.springframework.cloud.autoconfigure.RefreshAutoConfiguration")
public class EurekaClientAutoConfiguration { public class EurekaClientAutoConfiguration {
@Value("${server.port:${SERVER_PORT:${PORT:8080}}}") @Value("${server.port:${SERVER_PORT:${PORT:8080}}}")
...@@ -147,7 +147,8 @@ public class EurekaClientAutoConfiguration { ...@@ -147,7 +147,8 @@ public class EurekaClientAutoConfiguration {
@ConditionalOnMissingBean(value = EurekaClient.class, search = SearchStrategy.CURRENT) @ConditionalOnMissingBean(value = EurekaClient.class, search = SearchStrategy.CURRENT)
public EurekaClient eurekaClient(ApplicationInfoManager manager, public EurekaClient eurekaClient(ApplicationInfoManager manager,
EurekaClientConfig config) { EurekaClientConfig config) {
return new CloudEurekaClient(manager, config, this.optionalArgs, this.context); return new CloudEurekaClient(manager, config, this.optionalArgs,
this.context);
} }
@Bean @Bean
...@@ -176,7 +177,8 @@ public class EurekaClientAutoConfiguration { ...@@ -176,7 +177,8 @@ public class EurekaClientAutoConfiguration {
public EurekaClient eurekaClient(ApplicationInfoManager manager, public EurekaClient eurekaClient(ApplicationInfoManager manager,
EurekaClientConfig config, EurekaInstanceConfig instance) { EurekaClientConfig config, EurekaInstanceConfig instance) {
manager.getInfo(); // force initialization manager.getInfo(); // force initialization
return new CloudEurekaClient(manager, config, this.optionalArgs, this.context); return new CloudEurekaClient(manager, config, this.optionalArgs,
this.context);
} }
@Bean @Bean
...@@ -217,6 +219,7 @@ public class EurekaClientAutoConfiguration { ...@@ -217,6 +219,7 @@ public class EurekaClientAutoConfiguration {
static class MissingClass { static class MissingClass {
} }
@ConditionalOnClass(RefreshScope.class)
@ConditionalOnMissingBean(RefreshAutoConfiguration.class) @ConditionalOnMissingBean(RefreshAutoConfiguration.class)
static class MissingScope { static class MissingScope {
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment