diff --git a/core/pom.xml b/core/pom.xml index 5c0dd2555c6..3186718248f 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -161,10 +161,6 @@ org.hdrhistogram HdrHistogram - - org.apache.commons - commons-lang3 - commons-cli commons-cli diff --git a/core/src/main/assemblies/common-bin.xml b/core/src/main/assemblies/common-bin.xml index d40299497f8..35c522e9c98 100644 --- a/core/src/main/assemblies/common-bin.xml +++ b/core/src/main/assemblies/common-bin.xml @@ -23,7 +23,6 @@ com.ning:compress-lzf com.github.spullara.mustache.java:compiler com.tdunning:t-digest - org.apache.commons:commons-lang3 commons-cli:commons-cli com.twitter:jsr166e org.hdrhistogram:HdrHistogram diff --git a/core/src/main/java/org/elasticsearch/common/cli/CliTool.java b/core/src/main/java/org/elasticsearch/common/cli/CliTool.java index 6b11e65147f..b3533b59417 100644 --- a/core/src/main/java/org/elasticsearch/common/cli/CliTool.java +++ b/core/src/main/java/org/elasticsearch/common/cli/CliTool.java @@ -23,7 +23,6 @@ import com.google.common.base.Preconditions; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; import org.apache.commons.cli.DefaultParser; -import org.apache.commons.cli.GnuParser; import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; diff --git a/core/src/main/java/org/elasticsearch/common/collect/CopyOnWriteHashMap.java b/core/src/main/java/org/elasticsearch/common/collect/CopyOnWriteHashMap.java index 6bd3a5bd45b..0675f55c00c 100644 --- a/core/src/main/java/org/elasticsearch/common/collect/CopyOnWriteHashMap.java +++ b/core/src/main/java/org/elasticsearch/common/collect/CopyOnWriteHashMap.java @@ -22,9 +22,9 @@ package org.elasticsearch.common.collect; import com.google.common.base.Preconditions; import com.google.common.collect.Maps; import com.google.common.collect.UnmodifiableIterator; -import org.apache.commons.lang3.ArrayUtils; import org.apache.lucene.util.mutable.MutableValueInt; +import java.lang.reflect.Array; import java.util.*; /** @@ -134,12 +134,13 @@ public final class CopyOnWriteHashMap extends AbstractMap { @Override V get(Object key, int hash) { - final int slot = ArrayUtils.indexOf(keys, key); - if (slot < 0) { - return null; - } else { - return values[slot]; + for (int i = 0; i < keys.length; i++) { + if (key.equals(keys[i])) { + return values[i]; + } } + return null; + } private static T[] replace(T[] array, int index, T value) { @@ -151,14 +152,20 @@ public final class CopyOnWriteHashMap extends AbstractMap { @Override Leaf put(K key, int hash, int hashBits, V value, MutableValueInt newValue) { assert hashBits <= 0 : hashBits; - final int slot = ArrayUtils.indexOf(keys, key); + int slot = -1; + for (int i = 0; i < keys.length; i++) { + if (key.equals(keys[i])) { + slot = i; + break; + } + } final K[] keys2; final V[] values2; if (slot < 0) { - keys2 = ArrayUtils.add(keys, key); - values2 = ArrayUtils.add(values, value); + keys2 = appendElement(keys, key); + values2 = appendElement(values, value); newValue.value = 1; } else { keys2 = replace(keys, slot, key); @@ -170,16 +177,49 @@ public final class CopyOnWriteHashMap extends AbstractMap { @Override Leaf remove(Object key, int hash) { - final int slot = ArrayUtils.indexOf(keys, key); + int slot = -1; + for (int i = 0; i < keys.length; i++) { + if (key.equals(keys[i])) { + slot = i; + break; + } + } if (slot < 0) { return this; } - final K[] keys2 = ArrayUtils.remove(keys, slot); - final V[] values2 = ArrayUtils.remove(values, slot); + final K[] keys2 = removeArrayElement(keys, slot); + final V[] values2 = removeArrayElement(values, slot); return new Leaf<>(keys2, values2); } } + private static T[] removeArrayElement(T[] array, int index) { + final Object result = Array.newInstance(array.getClass().getComponentType(), array.length - 1); + System.arraycopy(array, 0, result, 0, index); + if (index < array.length - 1) { + System.arraycopy(array, index + 1, result, index, array.length - index - 1); + } + + return (T[]) result; + } + + public static T[] appendElement(final T[] array, final T element) { + final T[] newArray = Arrays.copyOf(array, array.length + 1); + newArray[newArray.length - 1] = element; + return newArray; + } + + public static T[] insertElement(final T[] array, final T element, final int index) { + final T[] result = Arrays.copyOf(array, array.length + 1); + System.arraycopy(array, 0, result, 0, index); + result[index] = element; + if (index < array.length) { + System.arraycopy(array, index, result, index + 1, array.length - index); + } + return result; + } + + /** * An inner node in this trie. Inner nodes store up to 64 key-value pairs * and use a bitmap in order to associate hashes to them. For example, if @@ -320,8 +360,8 @@ public final class CopyOnWriteHashMap extends AbstractMap { private InnerNode putNew(K key, int hash6, int slot, V value) { final long mask2 = mask | (1L << hash6); - final K[] keys2 = ArrayUtils.add(keys, slot, key); - final Object[] subNodes2 = ArrayUtils.add(subNodes, slot, value); + final K[] keys2 = insertElement(keys, key, slot); + final Object[] subNodes2 = insertElement(subNodes, value, slot); return new InnerNode<>(mask2, keys2, subNodes2); } @@ -342,8 +382,8 @@ public final class CopyOnWriteHashMap extends AbstractMap { private InnerNode removeSlot(int hash6, int slot) { final long mask2 = mask & ~(1L << hash6); - final K[] keys2 = ArrayUtils.remove(keys, slot); - final Object[] subNodes2 = ArrayUtils.remove(subNodes, slot); + final K[] keys2 = removeArrayElement(keys, slot); + final Object[] subNodes2 = removeArrayElement(subNodes, slot); return new InnerNode<>(mask2, keys2, subNodes2); } diff --git a/core/src/main/java/org/elasticsearch/common/geo/builders/BasePolygonBuilder.java b/core/src/main/java/org/elasticsearch/common/geo/builders/BasePolygonBuilder.java index c1cb9bb32ac..c37c8a66d6b 100644 --- a/core/src/main/java/org/elasticsearch/common/geo/builders/BasePolygonBuilder.java +++ b/core/src/main/java/org/elasticsearch/common/geo/builders/BasePolygonBuilder.java @@ -23,7 +23,7 @@ import com.google.common.collect.Sets; import com.spatial4j.core.exception.InvalidShapeException; import com.spatial4j.core.shape.Shape; import com.vividsolutions.jts.geom.*; -import org.apache.commons.lang3.tuple.Pair; +import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; @@ -98,7 +98,6 @@ public abstract class BasePolygonBuilder> extend /** * build new hole to the polygon - * @param hole linear ring defining the hole * @return this */ public Ring hole() { @@ -285,7 +284,7 @@ public abstract class BasePolygonBuilder> extend Edge current = edge; Edge prev = edge; // bookkeep the source and sink of each visited coordinate - HashMap> visitedEdge = new HashMap<>(); + HashMap> visitedEdge = new HashMap<>(); do { current.coordinate = shift(current.coordinate, shiftOffset); current.component = id; @@ -301,7 +300,7 @@ public abstract class BasePolygonBuilder> extend // since we're splitting connected components, we want the edges method to visit // the newly separated component final int visitID = -id; - Edge firstAppearance = visitedEdge.get(current.coordinate).getRight(); + Edge firstAppearance = visitedEdge.get(current.coordinate).v2(); // correct the graph pointers by correcting the 'next' pointer for both the // first appearance and this appearance of the edge Edge temp = firstAppearance.next; @@ -312,12 +311,12 @@ public abstract class BasePolygonBuilder> extend // a non-visited value (anything positive) do { prev.component = visitID; - prev = visitedEdge.get(prev.coordinate).getLeft(); + prev = visitedEdge.get(prev.coordinate).v1(); ++splitIndex; } while (!current.coordinate.equals(prev.coordinate)); ++connectedComponents; } else { - visitedEdge.put(current.coordinate, Pair.of(prev, current)); + visitedEdge.put(current.coordinate, new Tuple(prev, current)); } edges.add(current); prev = current; diff --git a/core/src/main/java/org/elasticsearch/common/geo/builders/ShapeBuilder.java b/core/src/main/java/org/elasticsearch/common/geo/builders/ShapeBuilder.java index 2443e5156e3..bfb41094214 100644 --- a/core/src/main/java/org/elasticsearch/common/geo/builders/ShapeBuilder.java +++ b/core/src/main/java/org/elasticsearch/common/geo/builders/ShapeBuilder.java @@ -26,9 +26,8 @@ import com.spatial4j.core.shape.jts.JtsGeometry; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.GeometryFactory; -import org.apache.commons.lang3.tuple.Pair; import org.elasticsearch.ElasticsearchParseException; -import org.elasticsearch.common.Explicit; +import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLoggerFactory; import org.elasticsearch.common.unit.DistanceUnit.Distance; @@ -487,7 +486,7 @@ public abstract class ShapeBuilder implements ToXContent { return top; } - private static final Pair range(Coordinate[] points, int offset, int length) { + private static final double[] range(Coordinate[] points, int offset, int length) { double minX = points[0].x; double maxX = points[0].x; double minY = points[0].y; @@ -507,7 +506,7 @@ public abstract class ShapeBuilder implements ToXContent { maxY = points[offset + i].y; } } - return Pair.of(Pair.of(minX, maxX), Pair.of(minY, maxY)); + return new double[] {minX, maxX, minY, maxY}; } /** @@ -585,8 +584,8 @@ public abstract class ShapeBuilder implements ToXContent { // and convert to a right handed system // compute the bounding box and calculate range - Pair range = range(points, offset, length); - final double rng = (Double)range.getLeft().getRight() - (Double)range.getLeft().getLeft(); + double[] range = range(points, offset, length); + final double rng = range[1] - range[0]; // translate the points if the following is true // 1. shell orientation is cw and range is greater than a hemisphere (180 degrees) but not spanning 2 hemispheres // (translation would result in a collapsed poly) diff --git a/core/src/test/java/org/elasticsearch/common/ParseFieldTests.java b/core/src/test/java/org/elasticsearch/common/ParseFieldTests.java index 6df6a50f9a3..b3397a55b32 100644 --- a/core/src/test/java/org/elasticsearch/common/ParseFieldTests.java +++ b/core/src/test/java/org/elasticsearch/common/ParseFieldTests.java @@ -18,7 +18,6 @@ */ package org.elasticsearch.common; -import org.apache.commons.lang3.ArrayUtils; import org.elasticsearch.test.ESTestCase; import org.junit.Test; @@ -77,7 +76,10 @@ public class ParseFieldTests extends ESTestCase { String[] deprecated = new String[]{"text", "same_as_text"}; String[] allValues = values; if (withDeprecatedNames) { - allValues = ArrayUtils.addAll(values, deprecated); + String[] newArray = new String[allValues.length + deprecated.length]; + System.arraycopy(allValues, 0, newArray, 0, allValues.length); + System.arraycopy(deprecated, 0, newArray, allValues.length, deprecated.length); + allValues = newArray; } ParseField field = new ParseField(randomFrom(values)); diff --git a/core/src/test/java/org/elasticsearch/test/ESBackcompatTestCase.java b/core/src/test/java/org/elasticsearch/test/ESBackcompatTestCase.java index 4c8c0f976de..39780db1026 100644 --- a/core/src/test/java/org/elasticsearch/test/ESBackcompatTestCase.java +++ b/core/src/test/java/org/elasticsearch/test/ESBackcompatTestCase.java @@ -19,7 +19,6 @@ package org.elasticsearch.test; import com.carrotsearch.randomizedtesting.annotations.TestGroup; -import org.apache.commons.lang3.ArrayUtils; import org.elasticsearch.Version; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.routing.IndexRoutingTable; @@ -32,13 +31,8 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.indices.recovery.RecoverySettings; import org.elasticsearch.test.junit.annotations.TestLogging; import org.elasticsearch.test.junit.listeners.LoggingListener; -import org.elasticsearch.test.transport.AssertingLocalTransport; -import org.elasticsearch.test.transport.MockTransportService; import org.elasticsearch.transport.Transport; import org.elasticsearch.transport.TransportModule; -import org.elasticsearch.transport.TransportService; -import org.elasticsearch.transport.netty.NettyTransport; -import org.junit.Ignore; import java.io.IOException; import java.lang.annotation.ElementType; diff --git a/core/src/test/java/org/elasticsearch/test/ESIntegTestCase.java b/core/src/test/java/org/elasticsearch/test/ESIntegTestCase.java index 4bb9b7b7b60..80a60ffbd20 100644 --- a/core/src/test/java/org/elasticsearch/test/ESIntegTestCase.java +++ b/core/src/test/java/org/elasticsearch/test/ESIntegTestCase.java @@ -28,12 +28,10 @@ import com.google.common.base.Joiner; import com.google.common.base.Predicate; import com.google.common.collect.Lists; -import org.apache.commons.lang3.StringUtils; import org.apache.http.impl.client.HttpClients; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.routing.UnassignedInfo; import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider; -import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.index.shard.MergeSchedulerConfig; import org.apache.lucene.util.IOUtils; import org.apache.lucene.util.LuceneTestCase; @@ -80,7 +78,6 @@ import org.elasticsearch.common.Priority; import org.elasticsearch.common.Strings; import org.elasticsearch.common.collect.ImmutableOpenMap; import org.elasticsearch.common.collect.Tuple; -import org.elasticsearch.common.io.PathUtils; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.InetSocketTransportAddress; @@ -1920,7 +1917,11 @@ public abstract class ESIntegTestCase extends ESTestCase { } if (list.length != 1) { - throw new IllegalStateException("Backwards index must contain exactly one cluster\n" + StringUtils.join(list, "\n")); + StringBuilder builder = new StringBuilder("Backwards index must contain exactly one cluster\n"); + for (Path line : list) { + builder.append(line.toString()).append('\n'); + } + throw new IllegalStateException(builder.toString()); } Path src = list[0]; Path dest = dataDir.resolve(internalCluster().getClusterName()); diff --git a/distribution/licenses/commons-lang3-3.3.2.jar.sha1 b/plugins/cloud-azure/licenses/commons-lang3-3.3.2.jar.sha1 similarity index 100% rename from distribution/licenses/commons-lang3-3.3.2.jar.sha1 rename to plugins/cloud-azure/licenses/commons-lang3-3.3.2.jar.sha1 diff --git a/distribution/licenses/commons-lang3-LICENSE.txt b/plugins/cloud-azure/licenses/commons-lang3-LICENSE.txt similarity index 100% rename from distribution/licenses/commons-lang3-LICENSE.txt rename to plugins/cloud-azure/licenses/commons-lang3-LICENSE.txt diff --git a/distribution/licenses/commons-lang3-NOTICE.txt b/plugins/cloud-azure/licenses/commons-lang3-NOTICE.txt similarity index 100% rename from distribution/licenses/commons-lang3-NOTICE.txt rename to plugins/cloud-azure/licenses/commons-lang3-NOTICE.txt diff --git a/plugins/pom.xml b/plugins/pom.xml index e87ef1e0678..5bc7f5f83f2 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -177,11 +177,6 @@ t-digest provided - - org.apache.commons - commons-lang3 - provided - commons-cli commons-cli diff --git a/pom.xml b/pom.xml index 71129a6689c..d82b7cab6f9 100644 --- a/pom.xml +++ b/pom.xml @@ -409,12 +409,6 @@ 2.1.6 - - org.apache.commons - commons-lang3 - 3.3.2 - - commons-cli commons-cli diff --git a/qa/smoke-test-multinode/pom.xml b/qa/smoke-test-multinode/pom.xml index 4b44c58665b..4c23f7bba56 100644 --- a/qa/smoke-test-multinode/pom.xml +++ b/qa/smoke-test-multinode/pom.xml @@ -165,11 +165,6 @@ t-digest provided - - org.apache.commons - commons-lang3 - provided - commons-cli commons-cli diff --git a/qa/smoke-test-plugins/pom.xml b/qa/smoke-test-plugins/pom.xml index 8a08bcd619b..9714885b5e6 100644 --- a/qa/smoke-test-plugins/pom.xml +++ b/qa/smoke-test-plugins/pom.xml @@ -170,11 +170,6 @@ t-digest provided - - org.apache.commons - commons-lang3 - provided - commons-cli commons-cli