Remove deprecated DiscoveryClient.getLocalServiceInstance()

This commit is contained in:
Spencer Gibb
2017-10-18 10:34:07 -04:00
parent a52f64076c
commit 89170d127d
7 changed files with 8 additions and 66 deletions

View File

@@ -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

View File

@@ -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<ServiceInstance> getInstances(String serviceId) {
if (this.discoveryClients != null) {

View File

@@ -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<ServiceInstance> getInstances(String serviceId) {
return Collections.emptyList();

View File

@@ -26,11 +26,6 @@ public class SimpleDiscoveryClient implements DiscoveryClient {
return "Simple Discovery Client";
}
@Override
public ServiceInstance getLocalServiceInstance() {
return this.simpleDiscoveryProperties.getLocal();
}
@Override
public List<ServiceInstance> getInstances(String serviceId) {
List<ServiceInstance> serviceInstances = new ArrayList<>();

View File

@@ -59,11 +59,6 @@ public class CompositeDiscoveryClientAutoConfigurationTests {
return "A custom discovery client";
}
@Override
public ServiceInstance getLocalServiceInstance() {
return null;
}
@Override
public List<ServiceInstance> getInstances(String serviceId) {
return null;

View File

@@ -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<ServiceInstance> getInstances(String serviceId) {
if (serviceId.equals("custom")) {

View File

@@ -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 {