From b468c744016743f3cd8a7200713346bd0c0a2df0 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Fri, 9 Oct 2015 14:49:25 -0400 Subject: [PATCH] Remove Guava as a dependency This commit removes Guava as a dependency. Note that Guava will remain as a test-only dependency (transitively through Elasticsearch through Jimfs). Relates elastic/elasticsearchelastic/elasticsearch#13224 Original commit: elastic/x-pack-elasticsearch@fe23d5f25fe6b56b9e93a7b8ac4499c3cd90ec9f --- qa/pom.xml | 5 ----- .../shield/audit/index/IndexAuditTrail.java | 10 ++------- .../shield/authc/RunAsIntegTests.java | 1 - .../support/SearchRequestEquivalence.java | 21 ++++++------------- .../watcher/WatcherLifeCycleServiceTests.java | 1 - 5 files changed, 8 insertions(+), 30 deletions(-) diff --git a/qa/pom.xml b/qa/pom.xml index a402f1793f5..dd048c6e41e 100644 --- a/qa/pom.xml +++ b/qa/pom.xml @@ -113,11 +113,6 @@ compiler provided - - com.google.guava - guava - provided - com.carrotsearch hppc diff --git a/shield/src/main/java/org/elasticsearch/shield/audit/index/IndexAuditTrail.java b/shield/src/main/java/org/elasticsearch/shield/audit/index/IndexAuditTrail.java index 67196f549f5..30512967d70 100644 --- a/shield/src/main/java/org/elasticsearch/shield/audit/index/IndexAuditTrail.java +++ b/shield/src/main/java/org/elasticsearch/shield/audit/index/IndexAuditTrail.java @@ -5,8 +5,6 @@ */ package org.elasticsearch.shield.audit.index; -import com.google.common.base.Splitter; - import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest; @@ -66,11 +64,7 @@ import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.SocketAddress; import java.net.UnknownHostException; -import java.util.ArrayList; -import java.util.EnumSet; -import java.util.List; -import java.util.Locale; -import java.util.Map; +import java.util.*; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.locks.Lock; @@ -696,7 +690,7 @@ public class IndexAuditTrail extends AbstractComponent implements AuditTrail, Cl List> hostPortPairs = new ArrayList<>(); for (String host : hosts) { - List hostPort = Splitter.on(":").splitToList(host.trim()); + List hostPort = Arrays.asList(host.trim().split(":")); if (hostPort.size() != 1 && hostPort.size() != 2) { logger.warn("invalid host:port specified: [{}] for setting [shield.audit.index.client.hosts]", host); } diff --git a/shield/src/test/java/org/elasticsearch/shield/authc/RunAsIntegTests.java b/shield/src/test/java/org/elasticsearch/shield/authc/RunAsIntegTests.java index e5072ae8028..2cad0946887 100644 --- a/shield/src/test/java/org/elasticsearch/shield/authc/RunAsIntegTests.java +++ b/shield/src/test/java/org/elasticsearch/shield/authc/RunAsIntegTests.java @@ -5,7 +5,6 @@ */ package org.elasticsearch.shield.authc; -import com.google.common.base.Predicate; import org.elasticsearch.ElasticsearchSecurityException; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.node.info.NodeInfo; diff --git a/watcher/src/main/java/org/elasticsearch/watcher/support/SearchRequestEquivalence.java b/watcher/src/main/java/org/elasticsearch/watcher/support/SearchRequestEquivalence.java index 17d7eb6f8d7..04d294bca63 100644 --- a/watcher/src/main/java/org/elasticsearch/watcher/support/SearchRequestEquivalence.java +++ b/watcher/src/main/java/org/elasticsearch/watcher/support/SearchRequestEquivalence.java @@ -5,11 +5,10 @@ */ package org.elasticsearch.watcher.support; -import com.google.common.base.Equivalence; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.common.io.stream.BytesStreamOutput; -import java.io.IOException; +import javax.annotation.Nullable; import java.util.Arrays; import static org.elasticsearch.watcher.support.Exceptions.illegalState; @@ -21,14 +20,17 @@ import static org.elasticsearch.watcher.support.Exceptions.illegalState; * don't compare search requests in normal runtime... we only do it in the tests. The is here basically * due to the lack of equals/hashcode support in SearchRequest in core. */ -public final class SearchRequestEquivalence extends Equivalence { +public final class SearchRequestEquivalence { public static final SearchRequestEquivalence INSTANCE = new SearchRequestEquivalence(); private SearchRequestEquivalence() { } - @Override + public final boolean equivalent(@Nullable SearchRequest a, @Nullable SearchRequest b) { + return a == b ? true : (a != null && b != null ? this.doEquivalent(a, b) : false); + } + protected boolean doEquivalent(SearchRequest r1, SearchRequest r2) { try { BytesStreamOutput output1 = new BytesStreamOutput(); @@ -42,15 +44,4 @@ public final class SearchRequestEquivalence extends Equivalence { throw illegalState("could not compare search requests", t); } } - - @Override - protected int doHash(SearchRequest request) { - try { - BytesStreamOutput output = new BytesStreamOutput(); - request.writeTo(output); - return Arrays.hashCode(output.bytes().toBytes()); - } catch (IOException ioe) { - throw illegalState("could not compute hashcode for search request", ioe); - } - } } diff --git a/watcher/src/test/java/org/elasticsearch/watcher/WatcherLifeCycleServiceTests.java b/watcher/src/test/java/org/elasticsearch/watcher/WatcherLifeCycleServiceTests.java index ec44247fb26..4bf872df99d 100644 --- a/watcher/src/test/java/org/elasticsearch/watcher/WatcherLifeCycleServiceTests.java +++ b/watcher/src/test/java/org/elasticsearch/watcher/WatcherLifeCycleServiceTests.java @@ -5,7 +5,6 @@ */ package org.elasticsearch.watcher; -import com.google.common.util.concurrent.MoreExecutors; import org.elasticsearch.cluster.*; import org.elasticsearch.cluster.block.ClusterBlocks; import org.elasticsearch.cluster.node.DiscoveryNodes;