From 856c47138a723ab78f8c4b380c48e27baca4bda3 Mon Sep 17 00:00:00 2001 From: Spencer Gibb Date: Mon, 20 Jun 2016 18:27:12 -0600 Subject: [PATCH] Don't use deprecated constructor. Eliminates a legacy use of a static singleton. This will help allow multiple registrations. --- .../ribbon/eureka/EurekaRibbonClientConfiguration.java | 6 ++++-- .../eureka/RibbonClientPreprocessorIntegrationTests.java | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/ribbon/eureka/EurekaRibbonClientConfiguration.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/ribbon/eureka/EurekaRibbonClientConfiguration.java index 89827cfb..9ae7b7a9 100644 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/ribbon/eureka/EurekaRibbonClientConfiguration.java +++ b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/ribbon/eureka/EurekaRibbonClientConfiguration.java @@ -17,7 +17,9 @@ package org.springframework.cloud.netflix.ribbon.eureka; import javax.annotation.PostConstruct; +import javax.inject.Provider; +import com.netflix.discovery.EurekaClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; @@ -89,9 +91,9 @@ public class EurekaRibbonClientConfiguration { @Bean @ConditionalOnMissingBean - public ServerList ribbonServerList(IClientConfig config) { + public ServerList ribbonServerList(IClientConfig config, Provider eurekaClientProvider) { DiscoveryEnabledNIWSServerList discoveryServerList = new DiscoveryEnabledNIWSServerList( - config); + config, eurekaClientProvider); DomainExtractingServerList serverList = new DomainExtractingServerList( discoveryServerList, config, this.approximateZoneFromHostname); return serverList; diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/ribbon/eureka/RibbonClientPreprocessorIntegrationTests.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/ribbon/eureka/RibbonClientPreprocessorIntegrationTests.java index 321b76dd..045389fe 100644 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/ribbon/eureka/RibbonClientPreprocessorIntegrationTests.java +++ b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/ribbon/eureka/RibbonClientPreprocessorIntegrationTests.java @@ -16,8 +16,10 @@ package org.springframework.cloud.netflix.ribbon.eureka; +import com.netflix.discovery.EurekaClient; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.test.SpringApplicationConfiguration; @@ -92,6 +94,10 @@ public class RibbonClientPreprocessorIntegrationTests { ArchaiusAutoConfiguration.class, RibbonAutoConfiguration.class, RibbonEurekaAutoConfiguration.class }) protected static class TestConfiguration { + @Bean + EurekaClient eurekaClient() { + return Mockito.mock(EurekaClient.class); + } } @Configuration