Browse Source

Remove deprecated DiscoveryClient.getLocalServiceInstance()

pull/284/head
Spencer Gibb 7 years ago
parent
commit
89170d127d
No known key found for this signature in database
GPG Key ID: 7788A47380690861
  1. 8
      spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClient.java
  2. 19
      spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClient.java
  3. 8
      spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/noop/NoopDiscoveryClient.java
  4. 5
      spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClient.java
  5. 5
      spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientAutoConfigurationTests.java
  6. 21
      spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientTests.java
  7. 8
      spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClientPropertiesMappingTests.java

8
spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClient.java

@ -33,14 +33,6 @@ public interface DiscoveryClient { @@ -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

19
spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClient.java

@ -1,13 +1,13 @@ @@ -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 { @@ -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) {

8
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; @@ -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 { @@ -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();

5
spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClient.java

@ -26,11 +26,6 @@ public class SimpleDiscoveryClient implements DiscoveryClient { @@ -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<>();

5
spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientAutoConfigurationTests.java

@ -59,11 +59,6 @@ public class CompositeDiscoveryClientAutoConfigurationTests { @@ -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;

21
spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientTests.java

@ -1,5 +1,10 @@ @@ -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; @@ -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 { @@ -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 { @@ -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")) {

8
spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClientPropertiesMappingTests.java

@ -82,14 +82,6 @@ public class SimpleDiscoveryClientPropertiesMappingTests { @@ -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 {

Loading…
Cancel
Save