diff --git a/pom.xml b/pom.xml
index 387c3357..6e5ef6f4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -161,11 +161,6 @@
1.12.6
provided
-
- com.google.guava
- guava
- 18.0
-
diff --git a/spring-cloud-zookeeper-bus/pom.xml b/spring-cloud-zookeeper-bus/pom.xml
index 5d9c344b..1b0fe0a6 100644
--- a/spring-cloud-zookeeper-bus/pom.xml
+++ b/spring-cloud-zookeeper-bus/pom.xml
@@ -36,10 +36,6 @@
spring-boot-starter-test
test
-
- com.google.guava
- guava
-
diff --git a/spring-cloud-zookeeper-config/pom.xml b/spring-cloud-zookeeper-config/pom.xml
index 6f38498b..3ba979e0 100644
--- a/spring-cloud-zookeeper-config/pom.xml
+++ b/spring-cloud-zookeeper-config/pom.xml
@@ -40,10 +40,6 @@
spring-boot-starter-test
test
-
- com.google.guava
- guava
-
diff --git a/spring-cloud-zookeeper-config/src/main/java/org/springframework/cloud/zookeeper/config/ZookeeperPropertySource.java b/spring-cloud-zookeeper-config/src/main/java/org/springframework/cloud/zookeeper/config/ZookeeperPropertySource.java
index 1341fce0..bf024c88 100644
--- a/spring-cloud-zookeeper-config/src/main/java/org/springframework/cloud/zookeeper/config/ZookeeperPropertySource.java
+++ b/spring-cloud-zookeeper-config/src/main/java/org/springframework/cloud/zookeeper/config/ZookeeperPropertySource.java
@@ -1,5 +1,6 @@
package org.springframework.cloud.zookeeper.config;
+import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -13,8 +14,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.context.Lifecycle;
import org.springframework.core.env.EnumerablePropertySource;
-import com.google.common.base.Charsets;
-
/**
* @author Spencer Gibb
*/
@@ -58,7 +57,7 @@ public class ZookeeperPropertySource extends EnumerablePropertySourcespring-boot-starter-test
test
-
- com.google.guava
- guava
-
diff --git a/spring-cloud-zookeeper-discovery/pom.xml b/spring-cloud-zookeeper-discovery/pom.xml
index e499f767..f11b53a2 100644
--- a/spring-cloud-zookeeper-discovery/pom.xml
+++ b/spring-cloud-zookeeper-discovery/pom.xml
@@ -52,10 +52,6 @@
spring-boot-starter-test
test
-
- com.google.guava
- guava
-
diff --git a/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/ZookeeperDiscoveryClient.java b/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/ZookeeperDiscoveryClient.java
index 7a692a49..67d1dcd7 100644
--- a/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/ZookeeperDiscoveryClient.java
+++ b/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/ZookeeperDiscoveryClient.java
@@ -1,14 +1,9 @@
package org.springframework.cloud.zookeeper.discovery;
-import static com.google.common.collect.Iterables.concat;
-import static com.google.common.collect.Iterables.transform;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import javax.annotation.Nullable;
-
import lombok.SneakyThrows;
import org.apache.curator.x.discovery.ServiceDiscovery;
@@ -18,9 +13,7 @@ import org.springframework.cloud.client.DefaultServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.context.ApplicationContext;
-import com.google.common.base.Function;
-import com.google.common.base.Throwables;
-import com.google.common.collect.Lists;
+import static org.springframework.util.ReflectionUtils.*;
/**
* @author Spencer Gibb
@@ -58,53 +51,39 @@ public class ZookeeperDiscoveryClient implements DiscoveryClient {
Collection> zkInstances = discovery
.queryForInstances(serviceId);
- Iterable instances = transform(
- zkInstances,
- new Function, org.springframework.cloud.client.ServiceInstance>() {
- @Nullable
- @Override
- public org.springframework.cloud.client.ServiceInstance apply(
- @Nullable ServiceInstance input) {
- return new DefaultServiceInstance(serviceId, input.getAddress(),
- input.getPort());
- }
- });
+ ArrayList instances = new ArrayList<>();
- return Lists.newArrayList(instances);
+ for (ServiceInstance instance : zkInstances) {
+ instances.add(new DefaultServiceInstance(serviceId, instance.getAddress(),
+ instance.getPort()));
+ }
+
+ return instances;
}
@Override
@SneakyThrows
public List getAllInstances() {
- Iterable instances = transform(
- concat(transform(
- discovery.queryForNames(),
- new Function>>() {
- @SneakyThrows
- public Collection> apply(
- String input) {
- return discovery.queryForInstances(input);
- }
- })),
- new Function, org.springframework.cloud.client.ServiceInstance>() {
- public org.springframework.cloud.client.ServiceInstance apply(
- ServiceInstance input) {
- return new DefaultServiceInstance(input.getName(), input
- .getAddress(), input.getPort());
- }
- });
+ List instances = new ArrayList<>();
- return Lists.newArrayList(instances);
+ for (String name : discovery.queryForNames()) {
+ for (ServiceInstance instance: discovery.queryForInstances(name)) {
+ instances.add(new DefaultServiceInstance(instance.getName(), instance
+ .getAddress(), instance.getPort()));
+ }
+ }
+
+ return instances;
}
@Override
public List getServices() {
ArrayList services = null;
try {
- services = Lists.newArrayList(discovery.queryForNames());
+ services = new ArrayList<>(discovery.queryForNames());
}
catch (Exception e) {
- Throwables.propagate(e);
+ rethrowRuntimeException(e);
}
return services;
}
diff --git a/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/ZookeeperServerList.java b/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/ZookeeperServerList.java
index 4a7fbe39..bb0fb9cb 100644
--- a/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/ZookeeperServerList.java
+++ b/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/ZookeeperServerList.java
@@ -1,22 +1,18 @@
package org.springframework.cloud.zookeeper.discovery;
-import static com.google.common.collect.Collections2.transform;
-import static com.google.common.collect.Lists.newArrayList;
-
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import javax.annotation.Nullable;
-
import org.apache.curator.x.discovery.ServiceDiscovery;
import org.apache.curator.x.discovery.ServiceInstance;
-import com.google.common.base.Function;
-import com.google.common.base.Throwables;
import com.netflix.client.config.IClientConfig;
import com.netflix.loadbalancer.AbstractServerList;
+import static org.springframework.util.ReflectionUtils.rethrowRuntimeException;
+
/**
* @author Spencer Gibb
*/
@@ -52,21 +48,15 @@ public class ZookeeperServerList extends AbstractServerList {
if (instances == null || instances.isEmpty()) {
return Collections.EMPTY_LIST;
}
- Collection servers = transform(instances,
- new Function, ZookeeperServer>() {
- @Nullable
- @Override
- public ZookeeperServer apply(
- @Nullable ServiceInstance instance) {
- ZookeeperServer server = new ZookeeperServer(instance);
- return server;
- }
- });
+ List servers = new ArrayList<>();
+ for (ServiceInstance instance : instances) {
+ servers.add(new ZookeeperServer(instance));
+ }
- return newArrayList(servers);
+ return servers;
}
catch (Exception e) {
- Throwables.propagate(e);
+ rethrowRuntimeException(e);
}
return Collections.EMPTY_LIST;
}