From 6ecda41485614e3eaf6cf5a0762e5f9ce57e2d39 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Wed, 23 Sep 2015 13:53:17 -0400 Subject: [PATCH] Remove and ban ImmutableSet#builder --- .../elasticsearch/cluster/ClusterState.java | 2 +- .../cluster/block/ClusterBlockException.java | 19 +-- .../cluster/block/ClusterBlocks.java | 124 ++++++++---------- .../common/inject/ConstructorInjector.java | 8 +- .../common/inject/MembersInjectorImpl.java | 13 +- .../common/io/stream/StreamInput.java | 37 +++++- .../elasticsearch/common/util/set/Sets.java | 13 ++ .../elasticsearch/env/NodeEnvironment.java | 32 ++++- .../gateway/GatewayMetaState.java | 21 +-- .../index/mapper/MapperService.java | 14 +- .../monitor/jvm/DeadlockAnalyzer.java | 17 ++- .../elasticsearch/plugins/PluginManager.java | 72 +++++----- .../settings/RestUpdateSettingsAction.java | 22 +++- .../script/ScriptContextRegistry.java | 25 ++-- .../snapshots/RestoreService.java | 70 +++++++--- .../gateway/GatewayMetaStateTests.java | 6 +- .../gateway/RecoverAfterNodesIT.java | 9 +- .../plugins/PluginManagerUnitTests.java | 3 +- .../resources/forbidden/all-signatures.txt | 1 + 19 files changed, 309 insertions(+), 199 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/cluster/ClusterState.java b/core/src/main/java/org/elasticsearch/cluster/ClusterState.java index 3a71530d6a5..d1196372065 100644 --- a/core/src/main/java/org/elasticsearch/cluster/ClusterState.java +++ b/core/src/main/java/org/elasticsearch/cluster/ClusterState.java @@ -380,7 +380,7 @@ public class ClusterState implements ToXContent, Diffable { if (!blocks().indices().isEmpty()) { builder.startObject("indices"); - for (Map.Entry> entry : blocks().indices().entrySet()) { + for (Map.Entry> entry : blocks().indices().entrySet()) { builder.startObject(entry.getKey()); for (ClusterBlock block : entry.getValue()) { block.toXContent(builder, params); diff --git a/core/src/main/java/org/elasticsearch/cluster/block/ClusterBlockException.java b/core/src/main/java/org/elasticsearch/cluster/block/ClusterBlockException.java index 9d1a41d4abf..ff5fbf52195 100644 --- a/core/src/main/java/org/elasticsearch/cluster/block/ClusterBlockException.java +++ b/core/src/main/java/org/elasticsearch/cluster/block/ClusterBlockException.java @@ -19,7 +19,6 @@ package org.elasticsearch.cluster.block; -import com.google.common.collect.ImmutableSet; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -28,26 +27,22 @@ import org.elasticsearch.rest.RestStatus; import java.io.IOException; import java.util.Set; +import static java.util.Collections.unmodifiableSet; + /** * */ public class ClusterBlockException extends ElasticsearchException { + private final Set blocks; - private final ImmutableSet blocks; - - public ClusterBlockException(ImmutableSet blocks) { + public ClusterBlockException(Set blocks) { super(buildMessage(blocks)); this.blocks = blocks; } public ClusterBlockException(StreamInput in) throws IOException { super(in); - int num = in.readVInt(); - ImmutableSet.Builder builder = ImmutableSet.builder(); - for (int i = 0; i < num; i++) { - builder.add(ClusterBlock.readClusterBlock(in)); - } - blocks = builder.build(); + blocks = unmodifiableSet(in.readSet(ClusterBlock::readClusterBlock)); } @Override @@ -72,11 +67,11 @@ public class ClusterBlockException extends ElasticsearchException { return true; } - public ImmutableSet blocks() { + public Set blocks() { return blocks; } - private static String buildMessage(ImmutableSet blocks) { + private static String buildMessage(Set blocks) { StringBuilder sb = new StringBuilder("blocked by: "); for (ClusterBlock block : blocks) { sb.append("[").append(block.status()).append("/").append(block.id()).append("/").append(block.description()).append("];"); diff --git a/core/src/main/java/org/elasticsearch/cluster/block/ClusterBlocks.java b/core/src/main/java/org/elasticsearch/cluster/block/ClusterBlocks.java index 2352a363a42..950b5381f49 100644 --- a/core/src/main/java/org/elasticsearch/cluster/block/ClusterBlocks.java +++ b/core/src/main/java/org/elasticsearch/cluster/block/ClusterBlocks.java @@ -21,6 +21,7 @@ package org.elasticsearch.cluster.block; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; + import org.elasticsearch.cluster.AbstractDiffable; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.MetaDataIndexStateService; @@ -33,68 +34,68 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.stream.Stream; + +import static java.util.Collections.emptyMap; +import static java.util.Collections.emptySet; +import static java.util.Collections.unmodifiableSet; +import static java.util.stream.Collectors.toSet; +import static java.util.stream.Stream.concat; /** * Represents current cluster level blocks to block dirty operations done against the cluster. */ public class ClusterBlocks extends AbstractDiffable { - - public static final ClusterBlocks EMPTY_CLUSTER_BLOCK = new ClusterBlocks(ImmutableSet.of(), ImmutableMap.>of()); + public static final ClusterBlocks EMPTY_CLUSTER_BLOCK = new ClusterBlocks(emptySet(), emptyMap()); public static final ClusterBlocks PROTO = EMPTY_CLUSTER_BLOCK; - private final ImmutableSet global; + private final Set global; - private final Map> indicesBlocks; + private final Map> indicesBlocks; private final ImmutableLevelHolder[] levelHolders; - ClusterBlocks(ImmutableSet global, Map> indicesBlocks) { + ClusterBlocks(Set global, Map> indicesBlocks) { this.global = global; this.indicesBlocks = indicesBlocks; levelHolders = new ImmutableLevelHolder[ClusterBlockLevel.values().length]; - for (ClusterBlockLevel level : ClusterBlockLevel.values()) { - ImmutableSet.Builder globalBuilder = ImmutableSet.builder(); - for (ClusterBlock block : global) { - if (block.contains(level)) { - globalBuilder.add(block); - } + for (final ClusterBlockLevel level : ClusterBlockLevel.values()) { + Predicate containsLevel = block -> block.contains(level); + Set newGlobal = unmodifiableSet(global.stream().filter(containsLevel).collect(toSet())); + + ImmutableMap.Builder> indicesBuilder = ImmutableMap.builder(); + for (Map.Entry> entry : indicesBlocks.entrySet()) { + indicesBuilder.put(entry.getKey(), unmodifiableSet(entry.getValue().stream().filter(containsLevel).collect(toSet()))); } - - ImmutableMap.Builder> indicesBuilder = ImmutableMap.builder(); - for (Map.Entry> entry : indicesBlocks.entrySet()) { - ImmutableSet.Builder indexBuilder = ImmutableSet.builder(); - for (ClusterBlock block : entry.getValue()) { - if (block.contains(level)) { - indexBuilder.add(block); - } - } - - indicesBuilder.put(entry.getKey(), indexBuilder.build()); - } - - levelHolders[level.id()] = new ImmutableLevelHolder(globalBuilder.build(), indicesBuilder.build()); + levelHolders[level.id()] = new ImmutableLevelHolder(newGlobal, indicesBuilder.build()); } } - public ImmutableSet global() { + public Set global() { return global; } - public Map> indices() { + public Map> indices() { return indicesBlocks; } - public ImmutableSet global(ClusterBlockLevel level) { + public Set global(ClusterBlockLevel level) { return levelHolders[level.id()].global(); } - public Map> indices(ClusterBlockLevel level) { + public Map> indices(ClusterBlockLevel level) { return levelHolders[level.id()].indices(); } + public Set blocksForIndex(ClusterBlockLevel level, String index) { + return indices(level).getOrDefault(index, emptySet()); + } + /** * Returns true if one of the global blocks as its disable state persistence flag set. */ @@ -165,24 +166,15 @@ public class ClusterBlocks extends AbstractDiffable { if (!indexBlocked(level, index)) { return null; } - ImmutableSet.Builder builder = ImmutableSet.builder(); - builder.addAll(global(level)); - ImmutableSet indexBlocks = indices(level).get(index); - if (indexBlocks != null) { - builder.addAll(indexBlocks); - } - return new ClusterBlockException(builder.build()); + Stream blocks = concat(global(level).stream(), blocksForIndex(level, index).stream()); + return new ClusterBlockException(unmodifiableSet(blocks.collect(toSet()))); } public boolean indexBlocked(ClusterBlockLevel level, String index) { if (!global(level).isEmpty()) { return true; } - ImmutableSet indexBlocks = indices(level).get(index); - if (indexBlocks != null && !indexBlocks.isEmpty()) { - return true; - } - return false; + return !blocksForIndex(level, index).isEmpty(); } public ClusterBlockException indicesBlockedException(ClusterBlockLevel level, String[] indices) { @@ -195,28 +187,22 @@ public class ClusterBlocks extends AbstractDiffable { if (!indexIsBlocked) { return null; } - ImmutableSet.Builder builder = ImmutableSet.builder(); - builder.addAll(global(level)); - for (String index : indices) { - ImmutableSet indexBlocks = indices(level).get(index); - if (indexBlocks != null) { - builder.addAll(indexBlocks); - } - } - return new ClusterBlockException(builder.build()); + Function> blocksForIndexAtLevel = index -> blocksForIndex(level, index).stream(); + Stream blocks = concat(global(level).stream(), Stream.of(indices).flatMap(blocksForIndexAtLevel)); + return new ClusterBlockException(unmodifiableSet(blocks.collect(toSet()))); } @Override public void writeTo(StreamOutput out) throws IOException { writeBlockSet(global, out); out.writeVInt(indicesBlocks.size()); - for (Map.Entry> entry : indicesBlocks.entrySet()) { + for (Map.Entry> entry : indicesBlocks.entrySet()) { out.writeString(entry.getKey()); writeBlockSet(entry.getValue(), out); } } - private static void writeBlockSet(ImmutableSet blocks, StreamOutput out) throws IOException { + private static void writeBlockSet(Set blocks, StreamOutput out) throws IOException { out.writeVInt(blocks.size()); for (ClusterBlock block : blocks) { block.writeTo(out); @@ -225,8 +211,8 @@ public class ClusterBlocks extends AbstractDiffable { @Override public ClusterBlocks readFrom(StreamInput in) throws IOException { - ImmutableSet global = readBlockSet(in); - ImmutableMap.Builder> indicesBuilder = ImmutableMap.builder(); + Set global = readBlockSet(in); + ImmutableMap.Builder> indicesBuilder = ImmutableMap.builder(); int size = in.readVInt(); for (int j = 0; j < size; j++) { indicesBuilder.put(in.readString().intern(), readBlockSet(in)); @@ -234,32 +220,27 @@ public class ClusterBlocks extends AbstractDiffable { return new ClusterBlocks(global, indicesBuilder.build()); } - private static ImmutableSet readBlockSet(StreamInput in) throws IOException { - ImmutableSet.Builder builder = ImmutableSet.builder(); - int size = in.readVInt(); - for (int i = 0; i < size; i++) { - builder.add(ClusterBlock.readClusterBlock(in)); - } - return builder.build(); + private static Set readBlockSet(StreamInput in) throws IOException { + return unmodifiableSet(in.readSet(ClusterBlock::readClusterBlock)); } static class ImmutableLevelHolder { - static final ImmutableLevelHolder EMPTY = new ImmutableLevelHolder(ImmutableSet.of(), ImmutableMap.>of()); + static final ImmutableLevelHolder EMPTY = new ImmutableLevelHolder(emptySet(), ImmutableMap.of()); - private final ImmutableSet global; - private final ImmutableMap> indices; + private final Set global; + private final ImmutableMap> indices; - ImmutableLevelHolder(ImmutableSet global, ImmutableMap> indices) { + ImmutableLevelHolder(Set global, ImmutableMap> indices) { this.global = global; this.indices = indices; } - public ImmutableSet global() { + public Set global() { return global; } - public ImmutableMap> indices() { + public ImmutableMap> indices() { return indices; } } @@ -279,7 +260,7 @@ public class ClusterBlocks extends AbstractDiffable { public Builder blocks(ClusterBlocks blocks) { global.addAll(blocks.global()); - for (Map.Entry> entry : blocks.indices().entrySet()) { + for (Map.Entry> entry : blocks.indices().entrySet()) { if (!indices.containsKey(entry.getKey())) { indices.put(entry.getKey(), new HashSet<>()); } @@ -345,11 +326,12 @@ public class ClusterBlocks extends AbstractDiffable { } public ClusterBlocks build() { - ImmutableMap.Builder> indicesBuilder = ImmutableMap.builder(); + // We copy the block sets here in case of the builder is modified after build is called + ImmutableMap.Builder> indicesBuilder = ImmutableMap.builder(); for (Map.Entry> entry : indices.entrySet()) { - indicesBuilder.put(entry.getKey(), ImmutableSet.copyOf(entry.getValue())); + indicesBuilder.put(entry.getKey(), unmodifiableSet(new HashSet<>(entry.getValue()))); } - return new ClusterBlocks(ImmutableSet.copyOf(global), indicesBuilder.build()); + return new ClusterBlocks(unmodifiableSet(new HashSet<>(global)), indicesBuilder.build()); } public static ClusterBlocks readClusterBlocks(StreamInput in) throws IOException { diff --git a/core/src/main/java/org/elasticsearch/common/inject/ConstructorInjector.java b/core/src/main/java/org/elasticsearch/common/inject/ConstructorInjector.java index c8792afef59..734e07d23c2 100644 --- a/core/src/main/java/org/elasticsearch/common/inject/ConstructorInjector.java +++ b/core/src/main/java/org/elasticsearch/common/inject/ConstructorInjector.java @@ -16,7 +16,6 @@ package org.elasticsearch.common.inject; -import com.google.common.collect.ImmutableSet; import org.elasticsearch.common.inject.internal.ConstructionContext; import org.elasticsearch.common.inject.internal.Errors; import org.elasticsearch.common.inject.internal.ErrorsException; @@ -24,6 +23,7 @@ import org.elasticsearch.common.inject.internal.InternalContext; import org.elasticsearch.common.inject.spi.InjectionPoint; import java.lang.reflect.InvocationTargetException; +import java.util.Set; /** * Creates instances using an injectable constructor. After construction, all injectable fields and @@ -33,12 +33,12 @@ import java.lang.reflect.InvocationTargetException; */ class ConstructorInjector { - private final ImmutableSet injectableMembers; + private final Set injectableMembers; private final SingleParameterInjector[] parameterInjectors; private final ConstructionProxy constructionProxy; private final MembersInjectorImpl membersInjector; - ConstructorInjector(ImmutableSet injectableMembers, + ConstructorInjector(Set injectableMembers, ConstructionProxy constructionProxy, SingleParameterInjector[] parameterInjectors, MembersInjectorImpl membersInjector) @@ -49,7 +49,7 @@ class ConstructorInjector { this.membersInjector = membersInjector; } - public ImmutableSet getInjectableMembers() { + public Set getInjectableMembers() { return injectableMembers; } diff --git a/core/src/main/java/org/elasticsearch/common/inject/MembersInjectorImpl.java b/core/src/main/java/org/elasticsearch/common/inject/MembersInjectorImpl.java index 420897172f2..bdd0bdefc68 100644 --- a/core/src/main/java/org/elasticsearch/common/inject/MembersInjectorImpl.java +++ b/core/src/main/java/org/elasticsearch/common/inject/MembersInjectorImpl.java @@ -16,7 +16,6 @@ package org.elasticsearch.common.inject; -import com.google.common.collect.ImmutableSet; import org.elasticsearch.common.inject.internal.Errors; import org.elasticsearch.common.inject.internal.ErrorsException; import org.elasticsearch.common.inject.internal.InternalContext; @@ -24,6 +23,10 @@ import org.elasticsearch.common.inject.spi.InjectionListener; import org.elasticsearch.common.inject.spi.InjectionPoint; import java.util.List; +import java.util.Set; + +import static java.util.Collections.unmodifiableSet; +import static java.util.stream.Collectors.toSet; /** * Injects members of instances of a given type. @@ -112,11 +115,7 @@ class MembersInjectorImpl implements MembersInjector { return "MembersInjector<" + typeLiteral + ">"; } - public ImmutableSet getInjectionPoints() { - ImmutableSet.Builder builder = ImmutableSet.builder(); - for (SingleMemberInjector memberInjector : memberInjectors) { - builder.add(memberInjector.getInjectionPoint()); - } - return builder.build(); + public Set getInjectionPoints() { + return unmodifiableSet(memberInjectors.stream().map(SingleMemberInjector::getInjectionPoint).collect(toSet())); } } diff --git a/core/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java b/core/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java index 1b412bb774b..43cc4fd58a8 100644 --- a/core/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java +++ b/core/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java @@ -36,9 +36,22 @@ import org.elasticsearch.common.text.Text; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; -import java.io.*; +import java.io.ByteArrayInputStream; +import java.io.EOFException; +import java.io.FileNotFoundException; +import java.io.FilterInputStream; +import java.io.IOException; +import java.io.InputStream; import java.nio.file.NoSuchFileException; -import java.util.*; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Function; import static org.elasticsearch.ElasticsearchException.readException; import static org.elasticsearch.ElasticsearchException.readStackTrace; @@ -470,6 +483,18 @@ public abstract class StreamInput extends InputStream { return values; } + /** + * Reads a set using reader to decode the set elements. + */ + public Set readSet(ObjectReader reader) throws IOException { + int num = readVInt(); + Set builder = new HashSet<>(num); + for (int i = 0; i < num; i++) { + builder.add(reader.read(this)); + } + return builder; + } + /** * Serializes a potential null value. */ @@ -575,4 +600,12 @@ public abstract class StreamInput extends InputStream { public static StreamInput wrap(byte[] bytes, int offset, int length) { return new InputStreamStreamInput(new ByteArrayInputStream(bytes, offset, length)); } + + /** + * FunctionalInterface for methods that read an object from the stream. + */ + @FunctionalInterface + public static interface ObjectReader { + public T read(StreamInput in) throws IOException; + } } diff --git a/core/src/main/java/org/elasticsearch/common/util/set/Sets.java b/core/src/main/java/org/elasticsearch/common/util/set/Sets.java index 4b323c42a37..a4bfe5200af 100644 --- a/core/src/main/java/org/elasticsearch/common/util/set/Sets.java +++ b/core/src/main/java/org/elasticsearch/common/util/set/Sets.java @@ -53,6 +53,19 @@ public final class Sets { return set; } + /** + * Create a new HashSet copying the original set with elements added. Useful + * for initializing constants without static blocks. + */ + public static HashSet newHashSetCopyWith(Set original, T... elements) { + Objects.requireNonNull(original); + Objects.requireNonNull(elements); + HashSet set = new HashSet<>(original.size() + elements.length); + set.addAll(original); + Collections.addAll(set, elements); + return set; + } + public static Set newConcurrentHashSet() { return Collections.newSetFromMap(new ConcurrentHashMap<>()); } diff --git a/core/src/main/java/org/elasticsearch/env/NodeEnvironment.java b/core/src/main/java/org/elasticsearch/env/NodeEnvironment.java index 41f209b8ea2..8c599995b9b 100644 --- a/core/src/main/java/org/elasticsearch/env/NodeEnvironment.java +++ b/core/src/main/java/org/elasticsearch/env/NodeEnvironment.java @@ -19,10 +19,14 @@ package org.elasticsearch.env; -import com.google.common.collect.ImmutableSet; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.SegmentInfos; -import org.apache.lucene.store.*; +import org.apache.lucene.store.Directory; +import org.apache.lucene.store.FSDirectory; +import org.apache.lucene.store.Lock; +import org.apache.lucene.store.LockObtainFailedException; +import org.apache.lucene.store.NativeFSLockFactory; +import org.apache.lucene.store.SimpleFSDirectory; import org.apache.lucene.util.IOUtils; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.cluster.metadata.IndexMetaData; @@ -42,12 +46,27 @@ import org.elasticsearch.monitor.fs.FsProbe; import java.io.Closeable; import java.io.IOException; -import java.nio.file.*; -import java.util.*; +import java.nio.file.AtomicMoveNotSupportedException; +import java.nio.file.DirectoryStream; +import java.nio.file.FileStore; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; +import static java.util.Collections.unmodifiableSet; + /** * A component that holds all data paths for a single node. */ @@ -507,12 +526,11 @@ public class NodeEnvironment extends AbstractComponent implements Closeable { } /** - * Returns all currently lock shards + * Returns all currently lock shards. */ public Set lockedShards() { synchronized (shardLocks) { - ImmutableSet.Builder builder = ImmutableSet.builder(); - return builder.addAll(shardLocks.keySet()).build(); + return unmodifiableSet(new HashSet<>(shardLocks.keySet())); } } diff --git a/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java b/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java index 43398c55917..5fbcfcf693d 100644 --- a/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java +++ b/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java @@ -47,6 +47,9 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import static java.util.Collections.emptySet; +import static java.util.Collections.unmodifiableSet; + /** * */ @@ -60,7 +63,7 @@ public class GatewayMetaState extends AbstractComponent implements ClusterStateL @Nullable private volatile MetaData previousMetaData; - private volatile ImmutableSet previouslyWrittenIndices = ImmutableSet.of(); + private volatile Set previouslyWrittenIndices = emptySet(); @Inject public GatewayMetaState(Settings settings, NodeEnvironment nodeEnv, MetaStateService metaStateService, @@ -126,17 +129,18 @@ public class GatewayMetaState extends AbstractComponent implements ClusterStateL // persistence was disabled or the node was restarted), see getRelevantIndicesOnDataOnlyNode(). // we therefore have to check here if we have shards on disk and add their indices to the previouslyWrittenIndices list if (isDataOnlyNode(state)) { - ImmutableSet.Builder previouslyWrittenIndicesBuilder = ImmutableSet.builder(); + Set newPreviouslyWrittenIndices = new HashSet<>(previouslyWrittenIndices.size()); for (IndexMetaData indexMetaData : newMetaData) { IndexMetaData indexMetaDataOnDisk = null; if (indexMetaData.state().equals(IndexMetaData.State.CLOSE)) { indexMetaDataOnDisk = metaStateService.loadIndexState(indexMetaData.index()); } if (indexMetaDataOnDisk != null) { - previouslyWrittenIndicesBuilder.add(indexMetaDataOnDisk.index()); + newPreviouslyWrittenIndices.add(indexMetaDataOnDisk.index()); } } - previouslyWrittenIndices = previouslyWrittenIndicesBuilder.addAll(previouslyWrittenIndices).build(); + newPreviouslyWrittenIndices.addAll(previouslyWrittenIndices); + previouslyWrittenIndices = unmodifiableSet(newPreviouslyWrittenIndices); } } catch (Throwable e) { success = false; @@ -168,12 +172,11 @@ public class GatewayMetaState extends AbstractComponent implements ClusterStateL if (success) { previousMetaData = newMetaData; - ImmutableSet.Builder builder = ImmutableSet.builder(); - previouslyWrittenIndices = builder.addAll(relevantIndices).build(); + previouslyWrittenIndices = unmodifiableSet(relevantIndices); } } - public static Set getRelevantIndices(ClusterState state, ClusterState previousState,ImmutableSet previouslyWrittenIndices) { + public static Set getRelevantIndices(ClusterState state, ClusterState previousState, Set previouslyWrittenIndices) { Set relevantIndices; if (isDataOnlyNode(state)) { relevantIndices = getRelevantIndicesOnDataOnlyNode(state, previousState, previouslyWrittenIndices); @@ -264,7 +267,7 @@ public class GatewayMetaState extends AbstractComponent implements ClusterStateL * @param newMetaData The new metadata * @return iterable over all indices states that should be written to disk */ - public static Iterable resolveStatesToBeWritten(ImmutableSet previouslyWrittenIndices, Set potentiallyUnwrittenIndices, MetaData previousMetaData, MetaData newMetaData) { + public static Iterable resolveStatesToBeWritten(Set previouslyWrittenIndices, Set potentiallyUnwrittenIndices, MetaData previousMetaData, MetaData newMetaData) { List indicesToWrite = new ArrayList<>(); for (String index : potentiallyUnwrittenIndices) { IndexMetaData newIndexMetaData = newMetaData.index(index); @@ -282,7 +285,7 @@ public class GatewayMetaState extends AbstractComponent implements ClusterStateL return indicesToWrite; } - public static Set getRelevantIndicesOnDataOnlyNode(ClusterState state, ClusterState previousState, ImmutableSet previouslyWrittenIndices) { + public static Set getRelevantIndicesOnDataOnlyNode(ClusterState state, ClusterState previousState, Set previouslyWrittenIndices) { RoutingNode newRoutingNode = state.getRoutingNodes().node(state.nodes().localNodeId()); if (newRoutingNode == null) { throw new IllegalStateException("cluster state does not contain this node - cannot write index meta state"); diff --git a/core/src/main/java/org/elasticsearch/index/mapper/MapperService.java b/core/src/main/java/org/elasticsearch/index/mapper/MapperService.java index ecbf60cf78a..eef74622c5d 100755 --- a/core/src/main/java/org/elasticsearch/index/mapper/MapperService.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/MapperService.java @@ -21,8 +21,8 @@ package org.elasticsearch.index.mapper; import com.carrotsearch.hppc.ObjectHashSet; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterators; + import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.DelegatingAnalyzerWrapper; import org.apache.lucene.index.IndexOptions; @@ -64,13 +64,17 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.function.Function; +import static java.util.Collections.emptySet; +import static java.util.Collections.unmodifiableSet; import static org.elasticsearch.common.collect.MapBuilder.newMapBuilder; /** @@ -116,7 +120,7 @@ public class MapperService extends AbstractIndexComponent implements Closeable { private volatile ImmutableMap unmappedFieldTypes = ImmutableMap.of(); - private volatile ImmutableSet parentTypes = ImmutableSet.of(); + private volatile Set parentTypes = emptySet(); @Inject public MapperService(Index index, @IndexSettings Settings indexSettings, AnalysisService analysisService, @@ -283,10 +287,10 @@ public class MapperService extends AbstractIndexComponent implements Closeable { } mappers = newMapBuilder(mappers).put(mapper.type(), mapper).map(); if (mapper.parentFieldMapper().active()) { - ImmutableSet.Builder parentTypesCopy = ImmutableSet.builder(); + Set parentTypesCopy = new HashSet(); parentTypesCopy.addAll(parentTypes); parentTypesCopy.add(mapper.parentFieldMapper().type()); - parentTypes = parentTypesCopy.build(); + parentTypes = unmodifiableSet(parentTypes); } assert assertSerialization(mapper); return mapper; @@ -594,7 +598,7 @@ public class MapperService extends AbstractIndexComponent implements Closeable { return null; } - public ImmutableSet getParentTypes() { + public Set getParentTypes() { return parentTypes; } diff --git a/core/src/main/java/org/elasticsearch/monitor/jvm/DeadlockAnalyzer.java b/core/src/main/java/org/elasticsearch/monitor/jvm/DeadlockAnalyzer.java index 58e71896c68..97b97302e26 100644 --- a/core/src/main/java/org/elasticsearch/monitor/jvm/DeadlockAnalyzer.java +++ b/core/src/main/java/org/elasticsearch/monitor/jvm/DeadlockAnalyzer.java @@ -20,12 +20,17 @@ package org.elasticsearch.monitor.jvm; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import java.lang.management.ManagementFactory; import java.lang.management.ThreadInfo; import java.lang.management.ThreadMXBean; -import java.util.*; +import java.util.Arrays; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import static java.util.Collections.unmodifiableSet; /** * @@ -117,17 +122,15 @@ public class DeadlockAnalyzer { return threadInfoMap.build(); } - public static class Deadlock { - private final ThreadInfo members[]; private final String description; - private final ImmutableSet memberIds; + private final Set memberIds; public Deadlock(ThreadInfo[] members) { this.members = members; - ImmutableSet.Builder builder = ImmutableSet.builder(); + Set builder = new HashSet<>(); StringBuilder sb = new StringBuilder(); for (int x = 0; x < members.length; x++) { ThreadInfo ti = members[x]; @@ -139,7 +142,7 @@ public class DeadlockAnalyzer { builder.add(ti.getThreadId()); } this.description = sb.toString(); - this.memberIds = builder.build(); + this.memberIds = unmodifiableSet(builder); } public ThreadInfo[] members() { diff --git a/core/src/main/java/org/elasticsearch/plugins/PluginManager.java b/core/src/main/java/org/elasticsearch/plugins/PluginManager.java index 9d3aac4bf36..e5b4b0e92fe 100644 --- a/core/src/main/java/org/elasticsearch/plugins/PluginManager.java +++ b/core/src/main/java/org/elasticsearch/plugins/PluginManager.java @@ -19,8 +19,8 @@ package org.elasticsearch.plugins; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterators; + import org.apache.lucene.util.IOUtils; import org.elasticsearch.Build; import org.elasticsearch.ElasticsearchCorruptionException; @@ -41,17 +41,29 @@ import java.io.IOException; import java.io.OutputStream; import java.net.MalformedURLException; import java.net.URL; -import java.nio.file.*; +import java.nio.file.DirectoryStream; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.attribute.PosixFileAttributeView; import java.nio.file.attribute.PosixFilePermission; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Locale; +import java.util.Random; +import java.util.Set; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; +import static java.util.Collections.unmodifiableSet; import static org.elasticsearch.common.Strings.hasLength; import static org.elasticsearch.common.cli.Terminal.Verbosity.VERBOSE; import static org.elasticsearch.common.io.FileSystemUtils.moveFilesWithoutOverwriting; +import static org.elasticsearch.common.util.set.Sets.newHashSet; /** * @@ -64,35 +76,33 @@ public class PluginManager { DEFAULT, SILENT, VERBOSE } - private static final ImmutableSet BLACKLIST = ImmutableSet.builder() - .add("elasticsearch", - "elasticsearch.bat", - "elasticsearch.in.sh", - "plugin", - "plugin.bat", - "service.bat").build(); + private static final Set BLACKLIST = unmodifiableSet(newHashSet( + "elasticsearch", + "elasticsearch.bat", + "elasticsearch.in.sh", + "plugin", + "plugin.bat", + "service.bat")); - static final ImmutableSet OFFICIAL_PLUGINS = ImmutableSet.builder() - .add( - "analysis-icu", - "analysis-kuromoji", - "analysis-phonetic", - "analysis-smartcn", - "analysis-stempel", - "cloud-gce", - "delete-by-query", - "discovery-azure", - "discovery-ec2", - "discovery-multicast", - "lang-expression", - "lang-javascript", - "lang-python", - "mapper-murmur3", - "mapper-size", - "repository-azure", - "repository-s3", - "store-smb" - ).build(); + static final Set OFFICIAL_PLUGINS = unmodifiableSet(newHashSet( + "analysis-icu", + "analysis-kuromoji", + "analysis-phonetic", + "analysis-smartcn", + "analysis-stempel", + "cloud-gce", + "delete-by-query", + "discovery-azure", + "discovery-ec2", + "discovery-multicast", + "lang-expression", + "lang-javascript", + "lang-python", + "mapper-murmur3", + "mapper-size", + "repository-azure", + "repository-s3", + "store-smb")); private final Environment environment; private URL url; diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/settings/RestUpdateSettingsAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/settings/RestUpdateSettingsAction.java index 40061435883..005b30e6207 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/settings/RestUpdateSettingsAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/settings/RestUpdateSettingsAction.java @@ -26,23 +26,31 @@ import org.elasticsearch.client.Client; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.rest.*; +import org.elasticsearch.rest.BaseRestHandler; +import org.elasticsearch.rest.RestChannel; +import org.elasticsearch.rest.RestController; +import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.action.support.AcknowledgedRestListener; import java.util.Map; +import java.util.Set; +import static java.util.Collections.unmodifiableSet; import static org.elasticsearch.client.Requests.updateSettingsRequest; -import com.google.common.collect.ImmutableSet; +import static org.elasticsearch.common.util.set.Sets.newHashSet; /** * */ public class RestUpdateSettingsAction extends BaseRestHandler { - - private static final ImmutableSet VALUES_TO_EXCLUDE = ImmutableSet.builder() - .add("pretty").add("timeout").add("master_timeout").add("index") - .add("expand_wildcards").add("ignore_unavailable").add("allow_no_indices") - .build(); + private static final Set VALUES_TO_EXCLUDE = unmodifiableSet(newHashSet( + "pretty", + "timeout", + "master_timeout", + "index", + "expand_wildcards", + "ignore_unavailable", + "allow_no_indices")); @Inject public RestUpdateSettingsAction(Settings settings, RestController controller, Client client) { diff --git a/core/src/main/java/org/elasticsearch/script/ScriptContextRegistry.java b/core/src/main/java/org/elasticsearch/script/ScriptContextRegistry.java index acd050d586a..1f985486dc5 100644 --- a/core/src/main/java/org/elasticsearch/script/ScriptContextRegistry.java +++ b/core/src/main/java/org/elasticsearch/script/ScriptContextRegistry.java @@ -21,11 +21,16 @@ package org.elasticsearch.script; import com.google.common.collect.ImmutableCollection; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import java.util.Collection; import java.util.HashMap; import java.util.Map; +import java.util.Set; + +import static java.util.Arrays.stream; +import static java.util.Collections.unmodifiableSet; +import static java.util.stream.Collectors.toSet; +import static java.util.stream.Stream.concat; /** * Registry for operations that use scripts as part of their execution. Can be standard operations of custom defined ones (via plugin). @@ -33,7 +38,7 @@ import java.util.Map; * Scripts can be enabled/disabled via fine-grained settings for each single registered operation. */ public final class ScriptContextRegistry { - static final ImmutableSet RESERVED_SCRIPT_CONTEXTS = reservedScriptContexts(); + static final Set RESERVED_SCRIPT_CONTEXTS = reservedScriptContexts(); private final ImmutableMap scriptContexts; @@ -76,15 +81,11 @@ public final class ScriptContextRegistry { } } - private static ImmutableSet reservedScriptContexts() { - ImmutableSet.Builder builder = ImmutableSet.builder(); - for (ScriptService.ScriptType scriptType : ScriptService.ScriptType.values()) { - builder.add(scriptType.toString()); - } - for (ScriptContext.Standard scriptContext : ScriptContext.Standard.values()) { - builder.add(scriptContext.getKey()); - } - builder.add("script").add("engine"); - return builder.build(); + private static Set reservedScriptContexts() { + Set reserved = concat(stream(ScriptService.ScriptType.values()), stream(ScriptContext.Standard.values())) + .map(Object::toString).collect(toSet()); + reserved.add("script"); + reserved.add("engine"); + return unmodifiableSet(reserved); } } diff --git a/core/src/main/java/org/elasticsearch/snapshots/RestoreService.java b/core/src/main/java/org/elasticsearch/snapshots/RestoreService.java index 1b49da57340..ca64f34fea8 100644 --- a/core/src/main/java/org/elasticsearch/snapshots/RestoreService.java +++ b/core/src/main/java/org/elasticsearch/snapshots/RestoreService.java @@ -23,15 +23,31 @@ import com.carrotsearch.hppc.IntSet; import com.carrotsearch.hppc.cursors.ObjectCursor; import com.carrotsearch.hppc.cursors.ObjectObjectCursor; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; + import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.cluster.*; +import org.elasticsearch.cluster.ClusterChangedEvent; +import org.elasticsearch.cluster.ClusterService; +import org.elasticsearch.cluster.ClusterState; +import org.elasticsearch.cluster.ClusterStateListener; +import org.elasticsearch.cluster.ClusterStateUpdateTask; +import org.elasticsearch.cluster.RestoreInProgress; import org.elasticsearch.cluster.RestoreInProgress.ShardRestoreStatus; import org.elasticsearch.cluster.block.ClusterBlocks; -import org.elasticsearch.cluster.metadata.*; -import org.elasticsearch.cluster.routing.*; +import org.elasticsearch.cluster.metadata.AliasMetaData; +import org.elasticsearch.cluster.metadata.IndexMetaData; +import org.elasticsearch.cluster.metadata.IndexTemplateMetaData; +import org.elasticsearch.cluster.metadata.MetaData; +import org.elasticsearch.cluster.metadata.MetaDataCreateIndexService; +import org.elasticsearch.cluster.metadata.MetaDataIndexUpgradeService; +import org.elasticsearch.cluster.metadata.RepositoriesMetaData; +import org.elasticsearch.cluster.metadata.SnapshotId; +import org.elasticsearch.cluster.routing.IndexRoutingTable; +import org.elasticsearch.cluster.routing.IndexShardRoutingTable; +import org.elasticsearch.cluster.routing.RestoreSource; +import org.elasticsearch.cluster.routing.RoutingTable; +import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.cluster.routing.allocation.RoutingAllocation; import org.elasticsearch.cluster.settings.ClusterDynamicSettings; @@ -53,16 +69,40 @@ import org.elasticsearch.index.shard.StoreRecoveryService; import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.repositories.Repository; import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.*; +import org.elasticsearch.transport.EmptyTransportResponseHandler; +import org.elasticsearch.transport.TransportChannel; +import org.elasticsearch.transport.TransportRequest; +import org.elasticsearch.transport.TransportRequestHandler; +import org.elasticsearch.transport.TransportResponse; +import org.elasticsearch.transport.TransportService; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import java.util.concurrent.BlockingQueue; import java.util.concurrent.CopyOnWriteArrayList; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; +import static java.util.Collections.unmodifiableSet; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_AUTO_EXPAND_REPLICAS; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_CREATION_DATE; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_INDEX_UUID; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_LEGACY_ROUTING_HASH_FUNCTION; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_LEGACY_ROUTING_USE_TYPE; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_VERSION_CREATED; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_VERSION_MINIMUM_COMPATIBLE; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_VERSION_UPGRADED; import static org.elasticsearch.cluster.metadata.MetaDataIndexStateService.INDEX_CLOSED_BLOCK; +import static org.elasticsearch.common.util.set.Sets.newHashSet; +import static org.elasticsearch.common.util.set.Sets.newHashSetCopyWith; /** * Service responsible for restoring snapshots @@ -90,22 +130,20 @@ public class RestoreService extends AbstractComponent implements ClusterStateLis public static final String UPDATE_RESTORE_ACTION_NAME = "internal:cluster/snapshot/update_restore"; - private static final ImmutableSet UNMODIFIABLE_SETTINGS = ImmutableSet.of( + private static final Set UNMODIFIABLE_SETTINGS = unmodifiableSet(newHashSet( SETTING_NUMBER_OF_SHARDS, SETTING_VERSION_CREATED, SETTING_LEGACY_ROUTING_HASH_FUNCTION, SETTING_LEGACY_ROUTING_USE_TYPE, SETTING_INDEX_UUID, - SETTING_CREATION_DATE); + SETTING_CREATION_DATE)); // It's OK to change some settings, but we shouldn't allow simply removing them - private static final ImmutableSet UNREMOVABLE_SETTINGS = ImmutableSet.builder() - .addAll(UNMODIFIABLE_SETTINGS) - .add(SETTING_NUMBER_OF_REPLICAS) - .add(SETTING_AUTO_EXPAND_REPLICAS) - .add(SETTING_VERSION_UPGRADED) - .add(SETTING_VERSION_MINIMUM_COMPATIBLE) - .build(); + private static final Set UNREMOVABLE_SETTINGS = unmodifiableSet(newHashSetCopyWith(UNMODIFIABLE_SETTINGS, + SETTING_NUMBER_OF_REPLICAS, + SETTING_AUTO_EXPAND_REPLICAS, + SETTING_VERSION_UPGRADED, + SETTING_VERSION_MINIMUM_COMPATIBLE)); private final ClusterService clusterService; diff --git a/core/src/test/java/org/elasticsearch/gateway/GatewayMetaStateTests.java b/core/src/test/java/org/elasticsearch/gateway/GatewayMetaStateTests.java index 22850e13cbe..6e71b94fe90 100644 --- a/core/src/test/java/org/elasticsearch/gateway/GatewayMetaStateTests.java +++ b/core/src/test/java/org/elasticsearch/gateway/GatewayMetaStateTests.java @@ -34,6 +34,7 @@ import org.junit.Test; import java.util.*; +import static java.util.Collections.emptySet; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.hamcrest.Matchers.equalTo; @@ -170,11 +171,10 @@ public class GatewayMetaStateTests extends ESAllocationTestCase { boolean stateInMemory, boolean expectMetaData) throws Exception { MetaData inMemoryMetaData = null; - ImmutableSet oldIndicesList = ImmutableSet.of(); + Set oldIndicesList = emptySet(); if (stateInMemory) { inMemoryMetaData = event.previousState().metaData(); - ImmutableSet.Builder relevantIndices = ImmutableSet.builder(); - oldIndicesList = relevantIndices.addAll(GatewayMetaState.getRelevantIndices(event.previousState(), event.previousState(), oldIndicesList)).build(); + oldIndicesList = GatewayMetaState.getRelevantIndices(event.previousState(), event.previousState(), oldIndicesList); } Set newIndicesList = GatewayMetaState.getRelevantIndices(event.state(),event.previousState(), oldIndicesList); // third, get the actual write info diff --git a/core/src/test/java/org/elasticsearch/gateway/RecoverAfterNodesIT.java b/core/src/test/java/org/elasticsearch/gateway/RecoverAfterNodesIT.java index 458bb69c2bd..5766ef30d0f 100644 --- a/core/src/test/java/org/elasticsearch/gateway/RecoverAfterNodesIT.java +++ b/core/src/test/java/org/elasticsearch/gateway/RecoverAfterNodesIT.java @@ -19,7 +19,6 @@ package org.elasticsearch.gateway; -import com.google.common.collect.ImmutableSet; import org.elasticsearch.client.Client; import org.elasticsearch.cluster.block.ClusterBlock; import org.elasticsearch.cluster.block.ClusterBlockLevel; @@ -27,10 +26,12 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase.ClusterScope; +import org.elasticsearch.test.ESIntegTestCase.Scope; import org.junit.Test; +import java.util.Set; + import static org.elasticsearch.common.settings.Settings.settingsBuilder; -import static org.elasticsearch.test.ESIntegTestCase.Scope; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasItem; @@ -39,9 +40,9 @@ public class RecoverAfterNodesIT extends ESIntegTestCase { private final static TimeValue BLOCK_WAIT_TIMEOUT = TimeValue.timeValueSeconds(10); - public ImmutableSet waitForNoBlocksOnNode(TimeValue timeout, Client nodeClient) throws InterruptedException { + public Set waitForNoBlocksOnNode(TimeValue timeout, Client nodeClient) throws InterruptedException { long start = System.currentTimeMillis(); - ImmutableSet blocks; + Set blocks; do { blocks = nodeClient.admin().cluster().prepareState().setLocal(true).execute().actionGet() .getState().blocks().global(ClusterBlockLevel.METADATA_WRITE); diff --git a/core/src/test/java/org/elasticsearch/plugins/PluginManagerUnitTests.java b/core/src/test/java/org/elasticsearch/plugins/PluginManagerUnitTests.java index c1ae4c22ea2..81c834ab9ae 100644 --- a/core/src/test/java/org/elasticsearch/plugins/PluginManagerUnitTests.java +++ b/core/src/test/java/org/elasticsearch/plugins/PluginManagerUnitTests.java @@ -32,6 +32,7 @@ import java.io.IOException; import java.net.URL; import java.nio.charset.Charset; import java.nio.file.Path; +import java.util.ArrayList; import java.util.Iterator; import java.util.Locale; @@ -94,7 +95,7 @@ public class PluginManagerUnitTests extends ESTestCase { @Test public void testOfficialPluginName() throws IOException { - String randomPluginName = randomFrom(PluginManager.OFFICIAL_PLUGINS.asList()); + String randomPluginName = randomFrom(new ArrayList<>(PluginManager.OFFICIAL_PLUGINS)); PluginManager.PluginHandle handle = PluginManager.PluginHandle.parse(randomPluginName); assertThat(handle.name, is(randomPluginName)); diff --git a/dev-tools/src/main/resources/forbidden/all-signatures.txt b/dev-tools/src/main/resources/forbidden/all-signatures.txt index 60a07c0c0da..885f2b694c9 100644 --- a/dev-tools/src/main/resources/forbidden/all-signatures.txt +++ b/dev-tools/src/main/resources/forbidden/all-signatures.txt @@ -128,6 +128,7 @@ com.google.common.collect.FluentIterable com.google.common.io.Files com.google.common.primitives.Ints com.google.common.collect.ImmutableMap#entrySet() +com.google.common.collect.ImmutableSet#builder() @defaultMessage Do not violate java's access system java.lang.reflect.AccessibleObject#setAccessible(boolean)