diff --git a/spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClient.java b/spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClient.java index c2d553d9..a6d0f93c 100644 --- a/spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClient.java +++ b/spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClient.java @@ -33,14 +33,6 @@ public interface DiscoveryClient { */ String description(); - /** - * @deprecated use the {@link org.springframework.cloud.client.serviceregistry.Registration} bean instead - * - * @return ServiceInstance with information used to register the local service - */ - @Deprecated - ServiceInstance getLocalServiceInstance(); - /** * Get all ServiceInstances associated with a particular serviceId * @param serviceId the serviceId to query diff --git a/spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClient.java b/spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClient.java index ff7cf2de..62e40beb 100644 --- a/spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClient.java +++ b/spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClient.java @@ -1,13 +1,13 @@ package org.springframework.cloud.client.discovery.composite; -import org.springframework.cloud.client.ServiceInstance; -import org.springframework.cloud.client.discovery.DiscoveryClient; - import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashSet; import java.util.List; +import org.springframework.cloud.client.ServiceInstance; +import org.springframework.cloud.client.discovery.DiscoveryClient; + /** * A {@link DiscoveryClient} composed of other Discovery Client's and will delegate the * calls to each of them in order @@ -27,19 +27,6 @@ public class CompositeDiscoveryClient implements DiscoveryClient { return "Composite Discovery Client"; } - @Override - public ServiceInstance getLocalServiceInstance() { - if (this.discoveryClients != null) { - for (DiscoveryClient discoveryClient : discoveryClients) { - ServiceInstance serviceInstance = discoveryClient.getLocalServiceInstance(); - if (serviceInstance != null) { - return serviceInstance; - } - } - } - return null; - } - @Override public List getInstances(String serviceId) { if (this.discoveryClients != null) { diff --git a/spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/noop/NoopDiscoveryClient.java b/spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/noop/NoopDiscoveryClient.java index 351b3458..d3a115cf 100644 --- a/spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/noop/NoopDiscoveryClient.java +++ b/spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/noop/NoopDiscoveryClient.java @@ -33,10 +33,7 @@ import org.springframework.cloud.client.discovery.DiscoveryClient; @Deprecated public class NoopDiscoveryClient implements DiscoveryClient { - private final ServiceInstance instance; - public NoopDiscoveryClient(ServiceInstance instance) { - this.instance = instance; } @Override @@ -44,11 +41,6 @@ public class NoopDiscoveryClient implements DiscoveryClient { return "Spring Cloud No-op DiscoveryClient"; } - @Override - public ServiceInstance getLocalServiceInstance() { - return this.instance; - } - @Override public List getInstances(String serviceId) { return Collections.emptyList(); diff --git a/spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClient.java b/spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClient.java index c8009540..f9b3d4fb 100644 --- a/spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClient.java +++ b/spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClient.java @@ -26,11 +26,6 @@ public class SimpleDiscoveryClient implements DiscoveryClient { return "Simple Discovery Client"; } - @Override - public ServiceInstance getLocalServiceInstance() { - return this.simpleDiscoveryProperties.getLocal(); - } - @Override public List getInstances(String serviceId) { List serviceInstances = new ArrayList<>(); diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientAutoConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientAutoConfigurationTests.java index f7572297..4832c33f 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientAutoConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientAutoConfigurationTests.java @@ -59,11 +59,6 @@ public class CompositeDiscoveryClientAutoConfigurationTests { return "A custom discovery client"; } - @Override - public ServiceInstance getLocalServiceInstance() { - return null; - } - @Override public List getInstances(String serviceId) { return null; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientTests.java index bb5a9f24..841ab3cd 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientTests.java @@ -1,5 +1,10 @@ package org.springframework.cloud.client.discovery.composite; +import java.net.URI; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -13,11 +18,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.core.annotation.Order; import org.springframework.test.context.junit4.SpringRunner; -import java.net.URI; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - import static org.assertj.core.api.Assertions.assertThat; /** @@ -72,12 +72,6 @@ public class CompositeDiscoveryClientTests { assertThat(this.discoveryClient.getInstances("unknown")).hasSize(0); } - - @Test - public void localServiceInstanceShouldReturnTheFirstMatch() { - assertThat(this.discoveryClient.getLocalServiceInstance().getServiceId()).isEqualTo("service0"); - } - @EnableAutoConfiguration @Configuration public static class Config { @@ -91,11 +85,6 @@ public class CompositeDiscoveryClientTests { return "A custom discovery client"; } - @Override - public ServiceInstance getLocalServiceInstance() { - return null; - } - @Override public List getInstances(String serviceId) { if (serviceId.equals("custom")) { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClientPropertiesMappingTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClientPropertiesMappingTests.java index 56435d5a..c42c7bb2 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClientPropertiesMappingTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClientPropertiesMappingTests.java @@ -82,14 +82,6 @@ public class SimpleDiscoveryClientPropertiesMappingTests { assertThat(this.discoveryClient.getInstances("nonexistent")).isEmpty(); } - @Test - public void testGetLocalInstance() { - assertThat(this.discoveryClient.getLocalServiceInstance().getServiceId()) - .isEqualTo("service0"); - assertThat(this.discoveryClient.getLocalServiceInstance().getPort()) - .isEqualTo(8080); - } - @Configuration @EnableAutoConfiguration public static class SampleConfig {