diff --git a/pom.xml b/pom.xml index 07e113be..a4b147e7 100644 --- a/pom.xml +++ b/pom.xml @@ -170,11 +170,6 @@ 1.12.6 provided - - com.google.guava - guava - 18.0 - diff --git a/spring-cloud-consul-bus/pom.xml b/spring-cloud-consul-bus/pom.xml index 8829bd93..bd09281e 100644 --- a/spring-cloud-consul-bus/pom.xml +++ b/spring-cloud-consul-bus/pom.xml @@ -35,10 +35,6 @@ spring-boot-starter-test test - - com.google.guava - guava - diff --git a/spring-cloud-consul-config/pom.xml b/spring-cloud-consul-config/pom.xml index 49977d18..d7b04401 100644 --- a/spring-cloud-consul-config/pom.xml +++ b/spring-cloud-consul-config/pom.xml @@ -35,10 +35,6 @@ spring-boot-starter-test test - - com.google.guava - guava - diff --git a/spring-cloud-consul-core/pom.xml b/spring-cloud-consul-core/pom.xml index 7c28bb10..ed025c00 100644 --- a/spring-cloud-consul-core/pom.xml +++ b/spring-cloud-consul-core/pom.xml @@ -44,10 +44,6 @@ spring-boot-starter-test test - - com.google.guava - guava - diff --git a/spring-cloud-consul-discovery/pom.xml b/spring-cloud-consul-discovery/pom.xml index f337acae..df57be82 100644 --- a/spring-cloud-consul-discovery/pom.xml +++ b/spring-cloud-consul-discovery/pom.xml @@ -47,14 +47,6 @@ spring-boot-starter-test test - - org.springframework.boot - spring-boot-starter-web - - - com.google.guava - guava - diff --git a/spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/discovery/ConsulDiscoveryClient.java b/spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/discovery/ConsulDiscoveryClient.java index a6d3c8aa..f7a16d9a 100644 --- a/spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/discovery/ConsulDiscoveryClient.java +++ b/spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/discovery/ConsulDiscoveryClient.java @@ -1,20 +1,16 @@ package org.springframework.cloud.consul.discovery; import com.ecwid.consul.v1.ConsulClient; -import com.google.common.base.Function; -import com.google.common.collect.Lists; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.client.DefaultServiceInstance; import org.springframework.cloud.client.ServiceInstance; import org.springframework.cloud.client.discovery.DiscoveryClient; import org.springframework.context.ApplicationContext; -import javax.annotation.Nullable; +import java.util.ArrayList; import java.util.List; import java.util.Map; -import static com.google.common.collect.Iterables.*; - /** * @author Spencer Gibb */ @@ -33,7 +29,7 @@ public class ConsulDiscoveryClient implements DiscoveryClient { @Override public ServiceInstance getLocalServiceInstance() { - /*Map services = agentClient.getServices(); + /*FIXME: Map services = agentClient.getServices(); Service service = services.get(context.getId()); if (service == null) { throw new IllegalStateException("Unable to locate service in consul agent: "+context.getId()); @@ -52,42 +48,32 @@ public class ConsulDiscoveryClient implements DiscoveryClient { @Override public List getInstances(final String serviceId) { - /*List nodes = catalogClient.getServiceNodes(serviceId); - Iterable instances = transform(nodes, new Function() { - @Nullable - @Override - public ServiceInstance apply(@Nullable ServiceNode node) { - return new DefaultServiceInstance(serviceId, node.getNode(), node.getServicePort()); - } - }); + //FIXME: List nodes = catalogClient.getServiceNodes(serviceId); + List instances = new ArrayList<>(); + /*for (ServiceNode node : nodes) { + instances.add(new DefaultServiceInstance(serviceId, node.getNode(), node.getServicePort())); + }*/ - return Lists.newArrayList(instances);*/ - return Lists.newArrayList(); + return instances; } @Override public List getAllInstances() { - /*Iterable instances = transform(concat(transform(catalogClient.getServices().keySet(), new Function>() { - @Nullable - @Override - public List apply(@Nullable String input) { - return catalogClient.getServiceNodes(input); - } - })), new Function() { - @Nullable - @Override - public ServiceInstance apply(@Nullable ServiceNode input) { - return new DefaultServiceInstance(input.getServiceName(), input.getNode(), input.getServicePort()); - } - }); + List instances = new ArrayList<>(); - return Lists.newArrayList(instances);*/ - return Lists.newArrayList(); + /*FIXME: for (String serviceId : catalogClient.getServices().keySet()) { + List serviceNodes = catalogClient.getServiceNodes(serviceId); + if (serviceNodes != null) { + for (ServiceNode node : serviceNodes) { + instances.add(new DefaultServiceInstance(node.getServiceName(), node.getNode(), node.getServicePort())); + } + } + }*/ + return instances; } @Override public List getServices() { - //return Lists.newArrayList(catalogClient.getServices().keySet()); - return Lists.newArrayList(); + return new ArrayList<>();//FIXME: catalogClient.getServices().keySet()); } } diff --git a/spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/discovery/ConsulLoadBalancerClient.java b/spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/discovery/ConsulLoadBalancerClient.java index 492fd754..61ad8782 100644 --- a/spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/discovery/ConsulLoadBalancerClient.java +++ b/spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/discovery/ConsulLoadBalancerClient.java @@ -1,7 +1,6 @@ package org.springframework.cloud.consul.discovery; import com.ecwid.consul.v1.ConsulClient; -import com.google.common.base.Throwables; import com.netflix.client.config.DefaultClientConfigImpl; import com.netflix.client.config.IClientConfig; import com.netflix.loadbalancer.*; @@ -15,6 +14,8 @@ import org.springframework.web.util.UriComponentsBuilder; import java.net.URI; import java.util.concurrent.ConcurrentHashMap; +import static org.springframework.util.ReflectionUtils.rethrowRuntimeException; + /** * @author Spencer Gibb */ @@ -57,7 +58,7 @@ public class ConsulLoadBalancerClient implements LoadBalancerClient { try { return request.apply(choose(serviceId)); } catch (Exception e) { - Throwables.propagate(e); + rethrowRuntimeException(e); return null; } } diff --git a/spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/discovery/ConsulServerList.java b/spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/discovery/ConsulServerList.java index 1a9bda2b..2d90e6c8 100644 --- a/spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/discovery/ConsulServerList.java +++ b/spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/discovery/ConsulServerList.java @@ -4,18 +4,13 @@ import com.ecwid.consul.v1.ConsulClient; import com.ecwid.consul.v1.QueryParams; import com.ecwid.consul.v1.Response; import com.ecwid.consul.v1.catalog.model.CatalogService; -import com.google.common.base.Function; import com.netflix.client.config.IClientConfig; import com.netflix.loadbalancer.AbstractServerList; -import javax.annotation.Nullable; -import java.util.Collection; +import java.util.ArrayList; import java.util.Collections; import java.util.List; -import static com.google.common.collect.Collections2.transform; -import static com.google.common.collect.Lists.newArrayList; - /** * @author Spencer Gibb */ @@ -60,15 +55,13 @@ public class ConsulServerList extends AbstractServerList { if (response.getValue() == null || response.getValue().isEmpty()) { return Collections.EMPTY_LIST; } - Collection servers = transform(response.getValue(), new Function() { - @Nullable - @Override - public ConsulServer apply(@Nullable CatalogService service) { - ConsulServer server = new ConsulServer(service); - return server; - } - }); - return newArrayList(servers); + List servers = new ArrayList<>(); + for (ServiceNode node : nodes) { + ConsulServer server = new ConsulServer(node); + servers.add(server); + } + + return servers; } } diff --git a/spring-cloud-consul-tests/pom.xml b/spring-cloud-consul-tests/pom.xml index 61dbdcc3..aec59ace 100644 --- a/spring-cloud-consul-tests/pom.xml +++ b/spring-cloud-consul-tests/pom.xml @@ -52,10 +52,6 @@ spring-boot-starter-test test - - com.google.guava - guava -