Browse Source

Make eureka application manager @Lazy

So that it isn't instantated eagerly on startup by the RefreshScope.

Fixes gh-789
pull/6/head
Dave Syer 9 years ago
parent
commit
2e9ff4c7d7
  1. 3
      spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration.java

3
spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration.java

@ -46,6 +46,7 @@ import org.springframework.context.ApplicationContext; @@ -46,6 +46,7 @@ import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.util.StringUtils;
@ -161,6 +162,7 @@ public class EurekaClientAutoConfiguration { @@ -161,6 +162,7 @@ public class EurekaClientAutoConfiguration {
@Bean(destroyMethod = "shutdown")
@ConditionalOnMissingBean(value = EurekaClient.class, search = SearchStrategy.CURRENT)
@org.springframework.cloud.context.config.annotation.RefreshScope
@Lazy
public EurekaClient eurekaClient(ApplicationInfoManager applicationInfoManager,
EurekaClientConfig config, EurekaInstanceConfig instance) {
applicationInfoManager.getInfo(); // force initialization
@ -171,6 +173,7 @@ public class EurekaClientAutoConfiguration { @@ -171,6 +173,7 @@ public class EurekaClientAutoConfiguration {
@Bean
@ConditionalOnMissingBean(value = ApplicationInfoManager.class, search = SearchStrategy.CURRENT)
@org.springframework.cloud.context.config.annotation.RefreshScope
@Lazy
public ApplicationInfoManager eurekaApplicationInfoManager(
EurekaInstanceConfig config) {
InstanceInfo instanceInfo = new InstanceInfoFactory().create(config);

Loading…
Cancel
Save