From 3067cacb66879428664d0e34e594842e30fcf90c Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Thu, 27 Aug 2015 22:14:33 -0400 Subject: [PATCH] Remove and forbid use of com.google.common.collect.Lists This commit removes and now forbids all uses of com.google.common.collect.Lists across the codebase. This is the first of many steps in the eventual removal of Guava as a dependency. --- .../elasticsearch/action/ActionModule.java | 51 ++++++-- .../cluster/health/ClusterHealthResponse.java | 9 +- .../TransportNodesHotThreadsAction.java | 4 +- .../node/stats/TransportNodesStatsAction.java | 4 +- .../snapshots/status/SnapshotStatus.java | 6 +- .../status/TransportNodesSnapshotsStatus.java | 12 +- .../indices/alias/IndicesAliasesRequest.java | 4 +- .../analyze/TransportAnalyzeAction.java | 12 +- .../TransportClearIndicesCacheAction.java | 5 +- .../indices/flush/TransportFlushAction.java | 5 +- .../TransportGetFieldMappingsIndexAction.java | 5 +- .../optimize/TransportOptimizeAction.java | 5 +- .../refresh/TransportRefreshAction.java | 5 +- .../admin/indices/segments/IndexSegments.java | 4 +- .../segments/IndicesSegmentResponse.java | 4 +- .../TransportIndicesSegmentsAction.java | 7 +- .../admin/indices/stats/IndexStats.java | 4 +- .../indices/stats/IndicesStatsResponse.java | 4 +- .../stats/TransportIndicesStatsAction.java | 8 +- .../get/GetIndexTemplatesResponse.java | 4 +- .../get/TransportGetIndexTemplatesAction.java | 7 +- .../upgrade/get/IndexUpgradeStatus.java | 4 +- .../get/TransportUpgradeStatusAction.java | 7 +- .../upgrade/get/UpgradeStatusResponse.java | 4 +- .../upgrade/post/TransportUpgradeAction.java | 9 +- .../query/TransportValidateQueryAction.java | 7 +- .../delete/TransportDeleteWarmerAction.java | 4 +- .../action/bulk/BulkRequest.java | 6 +- .../action/bulk/TransportBulkAction.java | 17 ++- .../action/exists/TransportExistsAction.java | 4 +- .../percolate/MultiPercolateRequest.java | 6 +- .../action/percolate/PercolateRequest.java | 4 +- .../percolate/PercolateSourceBuilder.java | 7 +- .../percolate/TransportPercolateAction.java | 7 +- .../action/search/ClearScrollRequest.java | 4 +- .../action/search/MultiSearchRequest.java | 8 +- .../suggest/TransportSuggestAction.java | 5 +- .../AbstractListenableActionFuture.java | 4 +- .../dfs/TransportDfsOnlyAction.java | 5 +- .../TransportClientNodesService.java | 18 ++- .../cluster/ClusterChangedEvent.java | 6 +- .../elasticsearch/cluster/DiffableUtils.java | 6 +- .../metadata/IndexNameExpressionResolver.java | 13 +- .../cluster/metadata/MetaData.java | 35 ++++-- .../metadata/MetaDataCreateIndexService.java | 14 ++- .../metadata/MetaDataIndexAliasesService.java | 6 +- .../MetaDataIndexTemplateService.java | 6 +- .../metadata/MetaDataMappingService.java | 12 +- .../cluster/node/DiscoveryNodes.java | 7 +- .../cluster/routing/IndexRoutingTable.java | 5 +- .../routing/IndexShardRoutingTable.java | 18 +-- .../cluster/routing/OperationRouting.java | 4 +- .../cluster/routing/RoutingNode.java | 6 +- .../cluster/routing/RoutingNodes.java | 28 +++-- .../cluster/routing/RoutingTable.java | 15 ++- .../routing/RoutingTableValidation.java | 14 +-- .../allocation/AllocationExplanation.java | 6 +- .../routing/allocation/AllocationService.java | 11 +- .../allocation/RoutingExplanations.java | 5 +- .../command/AllocationCommands.java | 7 +- .../routing/allocation/decider/Decision.java | 4 +- .../common/inject/BindingProcessor.java | 33 ++++- .../common/inject/DeferredLookups.java | 4 +- .../common/inject/EncounterImpl.java | 6 +- .../common/inject/InheritingState.java | 12 +- .../common/inject/Initializer.java | 4 +- .../inject/InjectionRequestProcessor.java | 4 +- .../common/inject/InjectorImpl.java | 32 ++++- .../common/inject/InjectorShell.java | 25 +++- .../common/inject/MembersInjectorStore.java | 4 +- .../common/inject/ModulesBuilder.java | 5 +- .../inject/PrivateElementProcessor.java | 4 +- .../assistedinject/AssistedConstructor.java | 9 +- .../assistedinject/FactoryProvider.java | 21 +++- .../assistedinject/FactoryProvider2.java | 16 ++- .../common/inject/internal/Errors.java | 31 +++-- .../common/inject/internal/Join.java | 6 +- .../inject/internal/PrivateElementsImpl.java | 6 +- .../internal/ProviderMethodsModule.java | 15 ++- .../inject/internal/SourceProvider.java | 4 +- .../inject/multibindings/Multibinder.java | 16 ++- .../common/inject/spi/Dependency.java | 4 +- .../common/inject/spi/Elements.java | 32 ++++- .../common/inject/spi/InjectionPoint.java | 27 ++-- .../common/inject/util/Modules.java | 19 ++- .../org/elasticsearch/common/io/Streams.java | 13 +- .../elasticsearch/common/logging/Loggers.java | 12 +- .../common/lucene/all/AllEntries.java | 4 +- .../lucene/index/FilterableTermsEnum.java | 5 +- .../common/settings/Settings.java | 25 +++- .../common/settings/SettingsFilter.java | 5 +- .../settings/loader/SettingsLoader.java | 4 +- .../loader/XContentSettingsLoader.java | 4 +- .../common/util/CollectionUtils.java | 119 ++++++++++++++++-- .../PrioritizedEsThreadPoolExecutor.java | 18 ++- .../xcontent/support/XContentMapValues.java | 3 +- .../discovery/zen/ZenDiscovery.java | 26 ++-- .../zen/elect/ElectMasterService.java | 14 ++- .../zen/ping/unicast/UnicastZenPing.java | 37 ++++-- .../gateway/GatewayMetaState.java | 10 +- .../gateway/PrimaryShardAllocator.java | 10 +- .../TransportNodesListGatewayMetaState.java | 12 +- ...ransportNodesListGatewayStartedShards.java | 13 +- .../index/analysis/AnalysisModule.java | 5 +- .../analysis/CustomAnalyzerProvider.java | 7 +- .../index/engine/InternalEngine.java | 34 ++++- .../elasticsearch/index/get/GetResult.java | 6 +- .../index/mapper/ParseContext.java | 10 +- .../mapper/core/CompletionFieldMapper.java | 4 +- .../index/mapper/object/ObjectMapper.java | 3 +- .../index/mapper/object/RootObjectMapper.java | 24 ++-- .../index/query/AndQueryBuilder.java | 3 +- .../index/query/AndQueryParser.java | 4 +- .../index/query/BoolQueryParser.java | 4 +- .../index/query/DisMaxQueryBuilder.java | 4 +- .../index/query/DisMaxQueryParser.java | 5 +- .../index/query/GeoPolygonQueryBuilder.java | 5 +- .../index/query/GeoPolygonQueryParser.java | 5 +- .../index/query/MoreLikeThisQueryParser.java | 7 +- .../index/query/MultiMatchQueryBuilder.java | 4 +- .../index/query/OrQueryBuilder.java | 3 +- .../index/query/OrQueryParser.java | 4 +- .../index/query/QueryStringQueryBuilder.java | 8 +- .../index/query/QueryStringQueryParser.java | 5 +- .../index/query/SpanNearQueryParser.java | 5 +- .../index/query/SpanOrQueryParser.java | 5 +- .../index/query/TermsQueryParser.java | 5 +- .../index/shard/CommitPoints.java | 6 +- .../index/shard/ElasticsearchMergePolicy.java | 11 +- .../BlobStoreIndexShardRepository.java | 38 +++--- .../BlobStoreIndexShardSnapshot.java | 11 +- .../BlobStoreIndexShardSnapshots.java | 14 ++- .../elasticsearch/indices/IndicesService.java | 29 ++++- .../elasticsearch/indices/IndicesWarmer.java | 6 +- .../indices/NodeIndicesStats.java | 5 +- .../HierarchyCircuitBreakerService.java | 5 +- .../cluster/IndicesClusterStateService.java | 17 ++- .../memory/IndexingMemoryController.java | 10 +- .../indices/recovery/RecoveryResponse.java | 18 +-- .../recovery/RecoverySourceHandler.java | 4 +- .../RecoveryTranslogOperationsRequest.java | 1 - .../TransportNodesListShardStoreMetaData.java | 12 +- .../percolator/PercolatorService.java | 18 ++- .../VerifyNodeRepositoryAction.java | 15 ++- .../blobstore/BlobStoreRepository.java | 11 +- .../org/elasticsearch/rest/RestModule.java | 4 +- .../org/elasticsearch/rest/RestResponse.java | 9 +- .../rest/action/RestActionModule.java | 22 +++- .../indices/analyze/RestAnalyzeAction.java | 13 +- .../elasticsearch/script/ScriptModule.java | 6 +- .../aggregations/AggregationBuilder.java | 5 +- .../aggregations/InternalAggregation.java | 5 +- .../aggregations/InternalAggregations.java | 7 +- .../bucket/filters/FiltersAggregator.java | 7 +- .../bucket/filters/InternalFilters.java | 6 +- .../bucket/histogram/InternalHistogram.java | 7 +- .../bucket/range/AbstractRangeBuilder.java | 4 +- .../bucket/range/InternalRange.java | 6 +- .../bucket/range/RangeAggregator.java | 6 +- .../range/geodistance/GeoDistanceBuilder.java | 4 +- .../pipeline/SiblingPipelineAggregator.java | 8 +- .../BucketScriptPipelineAggregator.java | 5 +- .../CumulativeSumPipelineAggregator.java | 5 +- .../DerivativePipelineAggregator.java | 5 +- .../movavg/MovAvgPipelineAggregator.java | 7 +- .../SerialDiffPipelineAggregator.java | 11 +- .../search/builder/SearchSourceBuilder.java | 15 +-- .../controller/SearchPhaseController.java | 6 +- .../search/fetch/FetchPhase.java | 11 +- .../fielddata/FieldDataFieldsContext.java | 4 +- .../MatchedQueriesFetchSubPhase.java | 5 +- .../fetch/script/ScriptFieldsContext.java | 4 +- .../search/highlight/HighlightBuilder.java | 13 +- .../highlight/HighlighterParseElement.java | 17 ++- .../search/internal/DefaultSearchContext.java | 24 +++- .../search/internal/InternalSearchHit.java | 6 +- .../search/internal/SubSearchContext.java | 4 +- .../search/sort/SortParseElement.java | 5 +- .../context/CategoryContextMapping.java | 9 +- .../suggest/context/ContextMapping.java | 11 +- .../context/GeolocationContextMapping.java | 11 +- .../search/warmer/IndexWarmersMetaData.java | 10 +- .../snapshots/RestoreService.java | 50 ++++++-- .../snapshots/SnapshotShardsService.java | 21 +++- .../snapshots/SnapshotsService.java | 36 ++++-- .../org/elasticsearch/tribe/TribeService.java | 10 +- .../action/RejectionActionIT.java | 3 +- .../MetaDataIndexTemplateServiceTests.java | 5 +- .../TransportActionFilterChainTests.java | 24 ++-- ...AggregationSearchCollectModeBenchmark.java | 5 +- .../TermsAggregationSearchBenchmark.java | 5 +- ...TimeDataHistogramAggregationBenchmark.java | 5 +- .../bwcompat/RestoreBackwardsCompatIT.java | 9 +- .../allocation/AddIncrementallyTests.java | 4 +- .../SingleShardNoReplicasRoutingTests.java | 6 +- .../allocation/decider/MockDiskUsagesIT.java | 14 ++- .../cluster/settings/SettingsFilteringIT.java | 1 - .../lucene/index/FreqTermsEnumTests.java | 8 +- .../common/util/CollectionUtilsTests.java | 57 ++++++++- .../concurrent/PrioritizedExecutorsTests.java | 12 +- .../builder/XContentBuilderTests.java | 22 +++- .../netty/NettyHttpServerPipeliningTest.java | 21 ++-- .../http/netty/NettyPipeliningDisabledIT.java | 7 +- .../index/IndexWithShadowReplicasIT.java | 9 +- .../index/fielddata/DuelFieldDataTests.java | 21 +++- .../index/mapper/FieldTypeLookupTests.java | 5 +- .../date/DateBackwardsCompatibilityTests.java | 4 +- .../mapper/externalvalues/ExternalMapper.java | 4 +- .../string/SimpleStringMappingTests.java | 19 +-- .../query/SimpleIndexQueryParserTests.java | 43 +++++-- .../index/shard/CommitPointsTests.java | 6 +- .../index/store/CorruptedFileIT.java | 35 ++++-- .../index/store/CorruptedTranslogIT.java | 11 +- .../index/translog/TranslogTests.java | 43 ++++--- .../PreBuiltAnalyzerIntegrationIT.java | 6 +- .../mapping/UpdateMappingIntegrationIT.java | 10 +- .../memory/breaker/CircuitBreakerNoopIT.java | 6 +- .../breaker/CircuitBreakerServiceIT.java | 10 +- .../template/SimpleIndexTemplateIT.java | 8 +- .../plugins/PluginInfoTests.java | 5 +- .../rest/RestFilterChainTests.java | 16 ++- .../elasticsearch/script/GroovyScriptIT.java | 14 +-- .../script/NativeScriptTests.java | 4 +- .../script/ScriptContextRegistryTests.java | 11 +- .../AggregationsIntegrationIT.java | 4 +- .../search/aggregations/EquivalenceIT.java | 20 +-- .../metrics/HDRPercentileRanksIT.java | 15 +-- .../metrics/HDRPercentilesIT.java | 16 +-- .../metrics/TDigestPercentileRanksIT.java | 15 +-- .../metrics/TDigestPercentilesIT.java | 15 +-- .../functionscore/RandomScoreFunctionIT.java | 20 +-- .../search/highlight/CustomHighlighter.java | 4 +- .../suggest/CompletionSuggestSearchIT.java | 13 +- .../suggest/CustomSuggesterSearchIT.java | 6 +- .../CompletionPostingsFormatTest.java | 4 +- .../DedicatedClusterSnapshotRestoreIT.java | 18 +-- .../SharedClusterSnapshotRestoreIT.java | 23 +--- ...anyNodesManyIndicesRecoveryStressTest.java | 6 +- .../test/ESAllocationTestCase.java | 4 +- .../elasticsearch/test/ESIntegTestCase.java | 47 ++++--- .../org/elasticsearch/test/ESTestCase.java | 24 ++-- .../test/ExternalTestCluster.java | 4 +- .../test/InternalTestCluster.java | 21 ++-- .../elasticsearch/test/MockLogAppender.java | 4 +- .../elasticsearch/test/XContentTestUtils.java | 4 +- .../test/rest/ESRestTestCase.java | 10 +- .../test/rest/client/RestClient.java | 8 +- .../test/rest/json/JsonPath.java | 5 +- .../test/rest/parser/SkipSectionParser.java | 4 +- .../test/rest/section/ApiCallSection.java | 4 +- .../test/rest/section/RestTestSuite.java | 4 +- .../test/rest/section/SetupSection.java | 5 +- .../test/rest/section/SkipSection.java | 5 +- .../test/rest/section/TestSection.java | 5 +- .../elasticsearch/test/rest/spec/RestApi.java | 14 +-- .../test/rest/support/Features.java | 4 +- .../watcher/FileWatcherTest.java | 8 +- .../resources/forbidden/core-signatures.txt | 3 + .../azure/AzureComputeServiceSimpleMock.java | 6 +- .../AzureComputeServiceTwoNodesMock.java | 19 ++- .../cloud/gce/GceComputeServiceImpl.java | 8 +- 261 files changed, 1780 insertions(+), 1141 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/action/ActionModule.java b/core/src/main/java/org/elasticsearch/action/ActionModule.java index a4b71626fa8..c613f617774 100644 --- a/core/src/main/java/org/elasticsearch/action/ActionModule.java +++ b/core/src/main/java/org/elasticsearch/action/ActionModule.java @@ -19,9 +19,7 @@ package org.elasticsearch.action; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; - import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; import org.elasticsearch.action.admin.cluster.health.TransportClusterHealthAction; import org.elasticsearch.action.admin.cluster.node.hotthreads.NodesHotThreadsAction; @@ -85,7 +83,11 @@ import org.elasticsearch.action.admin.indices.flush.FlushAction; import org.elasticsearch.action.admin.indices.flush.TransportFlushAction; import org.elasticsearch.action.admin.indices.get.GetIndexAction; import org.elasticsearch.action.admin.indices.get.TransportGetIndexAction; -import org.elasticsearch.action.admin.indices.mapping.get.*; +import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsAction; +import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsAction; +import org.elasticsearch.action.admin.indices.mapping.get.TransportGetFieldMappingsAction; +import org.elasticsearch.action.admin.indices.mapping.get.TransportGetFieldMappingsIndexAction; +import org.elasticsearch.action.admin.indices.mapping.get.TransportGetMappingsAction; import org.elasticsearch.action.admin.indices.mapping.put.PutMappingAction; import org.elasticsearch.action.admin.indices.mapping.put.TransportPutMappingAction; import org.elasticsearch.action.admin.indices.open.OpenIndexAction; @@ -96,14 +98,14 @@ import org.elasticsearch.action.admin.indices.recovery.RecoveryAction; import org.elasticsearch.action.admin.indices.recovery.TransportRecoveryAction; import org.elasticsearch.action.admin.indices.refresh.RefreshAction; import org.elasticsearch.action.admin.indices.refresh.TransportRefreshAction; -import org.elasticsearch.action.admin.indices.shards.IndicesShardStoresAction; -import org.elasticsearch.action.admin.indices.shards.TransportIndicesShardStoresAction; import org.elasticsearch.action.admin.indices.segments.IndicesSegmentsAction; import org.elasticsearch.action.admin.indices.segments.TransportIndicesSegmentsAction; import org.elasticsearch.action.admin.indices.settings.get.GetSettingsAction; import org.elasticsearch.action.admin.indices.settings.get.TransportGetSettingsAction; import org.elasticsearch.action.admin.indices.settings.put.TransportUpdateSettingsAction; import org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsAction; +import org.elasticsearch.action.admin.indices.shards.IndicesShardStoresAction; +import org.elasticsearch.action.admin.indices.shards.TransportIndicesShardStoresAction; import org.elasticsearch.action.admin.indices.stats.IndicesStatsAction; import org.elasticsearch.action.admin.indices.stats.TransportIndicesStatsAction; import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateAction; @@ -139,7 +141,11 @@ import org.elasticsearch.action.explain.ExplainAction; import org.elasticsearch.action.explain.TransportExplainAction; import org.elasticsearch.action.fieldstats.FieldStatsAction; import org.elasticsearch.action.fieldstats.TransportFieldStatsTransportAction; -import org.elasticsearch.action.get.*; +import org.elasticsearch.action.get.GetAction; +import org.elasticsearch.action.get.MultiGetAction; +import org.elasticsearch.action.get.TransportGetAction; +import org.elasticsearch.action.get.TransportMultiGetAction; +import org.elasticsearch.action.get.TransportShardMultiGetAction; import org.elasticsearch.action.index.IndexAction; import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.indexedscripts.delete.DeleteIndexedScriptAction; @@ -148,16 +154,38 @@ import org.elasticsearch.action.indexedscripts.get.GetIndexedScriptAction; import org.elasticsearch.action.indexedscripts.get.TransportGetIndexedScriptAction; import org.elasticsearch.action.indexedscripts.put.PutIndexedScriptAction; import org.elasticsearch.action.indexedscripts.put.TransportPutIndexedScriptAction; -import org.elasticsearch.action.percolate.*; -import org.elasticsearch.action.search.*; -import org.elasticsearch.action.search.type.*; +import org.elasticsearch.action.percolate.MultiPercolateAction; +import org.elasticsearch.action.percolate.PercolateAction; +import org.elasticsearch.action.percolate.TransportMultiPercolateAction; +import org.elasticsearch.action.percolate.TransportPercolateAction; +import org.elasticsearch.action.percolate.TransportShardMultiPercolateAction; +import org.elasticsearch.action.search.ClearScrollAction; +import org.elasticsearch.action.search.MultiSearchAction; +import org.elasticsearch.action.search.SearchAction; +import org.elasticsearch.action.search.SearchScrollAction; +import org.elasticsearch.action.search.TransportClearScrollAction; +import org.elasticsearch.action.search.TransportMultiSearchAction; +import org.elasticsearch.action.search.TransportSearchAction; +import org.elasticsearch.action.search.TransportSearchScrollAction; +import org.elasticsearch.action.search.type.TransportSearchDfsQueryAndFetchAction; +import org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction; +import org.elasticsearch.action.search.type.TransportSearchQueryAndFetchAction; +import org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction; +import org.elasticsearch.action.search.type.TransportSearchScanAction; +import org.elasticsearch.action.search.type.TransportSearchScrollQueryAndFetchAction; +import org.elasticsearch.action.search.type.TransportSearchScrollQueryThenFetchAction; +import org.elasticsearch.action.search.type.TransportSearchScrollScanAction; import org.elasticsearch.action.suggest.SuggestAction; import org.elasticsearch.action.suggest.TransportSuggestAction; import org.elasticsearch.action.support.ActionFilter; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.AutoCreateIndex; import org.elasticsearch.action.support.TransportAction; -import org.elasticsearch.action.termvectors.*; +import org.elasticsearch.action.termvectors.MultiTermVectorsAction; +import org.elasticsearch.action.termvectors.TermVectorsAction; +import org.elasticsearch.action.termvectors.TransportMultiTermVectorsAction; +import org.elasticsearch.action.termvectors.TransportShardMultiTermsVectorAction; +import org.elasticsearch.action.termvectors.TransportTermVectorsAction; import org.elasticsearch.action.termvectors.dfs.TransportDfsOnlyAction; import org.elasticsearch.action.update.TransportUpdateAction; import org.elasticsearch.action.update.UpdateAction; @@ -165,6 +193,7 @@ import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.multibindings.MapBinder; import org.elasticsearch.common.inject.multibindings.Multibinder; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -174,7 +203,7 @@ import java.util.Map; public class ActionModule extends AbstractModule { private final Map actions = Maps.newHashMap(); - private final List> actionFilters = Lists.newArrayList(); + private final List> actionFilters = new ArrayList<>(); static class ActionEntry { public final GenericAction action; diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthResponse.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthResponse.java index 7172c254dd8..755fb330f7b 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthResponse.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthResponse.java @@ -31,16 +31,19 @@ import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.common.xcontent.*; +import org.elasticsearch.common.xcontent.StatusToXContent; +import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.common.xcontent.XContentBuilderString; +import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.rest.RestStatus; import java.io.IOException; +import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; -import static com.google.common.collect.Lists.newArrayList; import static org.elasticsearch.action.admin.cluster.health.ClusterIndexHealth.readClusterIndexHealth; /** @@ -152,7 +155,7 @@ public class ClusterHealthResponse extends ActionResponse implements Iterable getAllValidationFailures() { - List allFailures = newArrayList(getValidationFailures()); + List allFailures = new ArrayList<>(getValidationFailures()); for (ClusterIndexHealth indexHealth : indices.values()) { allFailures.addAll(indexHealth.getValidationFailures()); } diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/hotthreads/TransportNodesHotThreadsAction.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/hotthreads/TransportNodesHotThreadsAction.java index 7f2c1994197..59fd9138ef9 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/hotthreads/TransportNodesHotThreadsAction.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/hotthreads/TransportNodesHotThreadsAction.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.admin.cluster.node.hotthreads; -import com.google.common.collect.Lists; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.nodes.BaseNodeRequest; @@ -36,6 +35,7 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicReferenceArray; @@ -54,7 +54,7 @@ public class TransportNodesHotThreadsAction extends TransportNodesAction nodes = Lists.newArrayList(); + final List nodes = new ArrayList<>(); for (int i = 0; i < responses.length(); i++) { Object resp = responses.get(i); if (resp instanceof NodeHotThreads) { diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/TransportNodesStatsAction.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/TransportNodesStatsAction.java index 90ad8663ec9..b3d1bd43739 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/TransportNodesStatsAction.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/TransportNodesStatsAction.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.admin.cluster.node.stats; -import com.google.common.collect.Lists; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.nodes.BaseNodeRequest; import org.elasticsearch.action.support.nodes.TransportNodesAction; @@ -35,6 +34,7 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicReferenceArray; @@ -56,7 +56,7 @@ public class TransportNodesStatsAction extends TransportNodesAction nodeStats = Lists.newArrayList(); + final List nodeStats = new ArrayList<>(); for (int i = 0; i < responses.length(); i++) { Object resp = responses.get(i); if (resp instanceof NodeStats) { diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotStatus.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotStatus.java index d6a0cd52d04..3e8a122978c 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotStatus.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotStatus.java @@ -21,8 +21,8 @@ package org.elasticsearch.action.admin.cluster.snapshots.status; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import org.elasticsearch.cluster.metadata.SnapshotId; import org.elasticsearch.cluster.SnapshotsInProgress.State; +import org.elasticsearch.cluster.metadata.SnapshotId; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Streamable; @@ -32,11 +32,11 @@ import org.elasticsearch.common.xcontent.XContentBuilderString; import org.elasticsearch.common.xcontent.XContentFactory; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; -import static com.google.common.collect.Lists.newArrayList; import static com.google.common.collect.Sets.newHashSet; /** @@ -109,7 +109,7 @@ public class SnapshotStatus implements ToXContent, Streamable { } for (String index : indices) { - List shards = newArrayList(); + List shards = new ArrayList<>(); for (SnapshotIndexShardStatus shard : this.shards) { if (shard.getIndex().equals(index)) { shards.add(shard); diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportNodesSnapshotsStatus.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportNodesSnapshotsStatus.java index 8c535ec67de..25701a80039 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportNodesSnapshotsStatus.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportNodesSnapshotsStatus.java @@ -20,12 +20,15 @@ package org.elasticsearch.action.admin.cluster.snapshots.status; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Lists; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.action.support.ActionFilters; -import org.elasticsearch.action.support.nodes.*; +import org.elasticsearch.action.support.nodes.BaseNodeRequest; +import org.elasticsearch.action.support.nodes.BaseNodeResponse; +import org.elasticsearch.action.support.nodes.BaseNodesRequest; +import org.elasticsearch.action.support.nodes.BaseNodesResponse; +import org.elasticsearch.action.support.nodes.TransportNodesAction; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; @@ -42,6 +45,7 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicReferenceArray; @@ -82,8 +86,8 @@ public class TransportNodesSnapshotsStatus extends TransportNodesAction nodesList = Lists.newArrayList(); - final List failures = Lists.newArrayList(); + final List nodesList = new ArrayList<>(); + final List failures = new ArrayList<>(); for (int i = 0; i < responses.length(); i++) { Object resp = responses.get(i); if (resp instanceof NodeSnapshotStatus) { // will also filter out null response for unallocated ones diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequest.java b/core/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequest.java index fd6819c7fc9..779f9a3a328 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequest.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequest.java @@ -21,8 +21,6 @@ package org.elasticsearch.action.admin.indices.alias; import com.carrotsearch.hppc.cursors.ObjectCursor; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; - import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.AliasesRequest; import org.elasticsearch.action.CompositeIndicesRequest; @@ -54,7 +52,7 @@ import static org.elasticsearch.cluster.metadata.AliasAction.readAliasAction; */ public class IndicesAliasesRequest extends AcknowledgedRequest implements CompositeIndicesRequest { - private List allAliasActions = Lists.newArrayList(); + private List allAliasActions = new ArrayList<>(); //indices options that require every specified index to exist, expand wildcards only to open indices and //don't allow that no indices are resolved from wildcard expressions diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/analyze/TransportAnalyzeAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/analyze/TransportAnalyzeAction.java index 9d34c6f346e..3e7a03aa66a 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/analyze/TransportAnalyzeAction.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/analyze/TransportAnalyzeAction.java @@ -18,7 +18,6 @@ */ package org.elasticsearch.action.admin.indices.analyze; -import com.google.common.collect.Lists; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; @@ -39,7 +38,13 @@ import org.elasticsearch.cluster.routing.ShardsIterator; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.IndexService; -import org.elasticsearch.index.analysis.*; +import org.elasticsearch.index.analysis.CharFilterFactory; +import org.elasticsearch.index.analysis.CharFilterFactoryFactory; +import org.elasticsearch.index.analysis.CustomAnalyzer; +import org.elasticsearch.index.analysis.TokenFilterFactory; +import org.elasticsearch.index.analysis.TokenFilterFactoryFactory; +import org.elasticsearch.index.analysis.TokenizerFactory; +import org.elasticsearch.index.analysis.TokenizerFactoryFactory; import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.internal.AllFieldMapper; import org.elasticsearch.index.shard.ShardId; @@ -49,6 +54,7 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import java.io.IOException; +import java.util.ArrayList; import java.util.List; /** @@ -210,7 +216,7 @@ public class TransportAnalyzeAction extends TransportSingleShardAction tokens = Lists.newArrayList(); + List tokens = new ArrayList<>(); TokenStream stream = null; int lastPosition = -1; int lastOffset = 0; diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/TransportClearIndicesCacheAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/TransportClearIndicesCacheAction.java index e77b7009fb0..2f8d7f84cda 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/TransportClearIndicesCacheAction.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/TransportClearIndicesCacheAction.java @@ -40,11 +40,10 @@ import org.elasticsearch.indices.cache.request.IndicesRequestCache; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicReferenceArray; -import static com.google.common.collect.Lists.newArrayList; - /** * Indices clear cache action. */ @@ -76,7 +75,7 @@ public class TransportClearIndicesCacheAction extends TransportBroadcastAction(); } shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse)); } else { diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportFlushAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportFlushAction.java index c6c3c316f68..323a6cc2382 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportFlushAction.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportFlushAction.java @@ -38,11 +38,10 @@ import org.elasticsearch.indices.IndicesService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicReferenceArray; -import static com.google.common.collect.Lists.newArrayList; - /** * Flush Action. */ @@ -71,7 +70,7 @@ public class TransportFlushAction extends TransportBroadcastAction(); } shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse)); } else { diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/TransportGetFieldMappingsIndexAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/TransportGetFieldMappingsIndexAction.java index 8e51133d132..265d326f164 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/TransportGetFieldMappingsIndexAction.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/TransportGetFieldMappingsIndexAction.java @@ -22,7 +22,6 @@ package org.elasticsearch.action.admin.indices.mapping.get; import com.google.common.base.Predicate; import com.google.common.collect.Collections2; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Lists; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse.FieldMappingMetaData; import org.elasticsearch.action.support.ActionFilters; @@ -55,6 +54,8 @@ import java.io.IOException; import java.util.Collection; import java.util.Iterator; +import static org.elasticsearch.common.util.CollectionUtils.newLinkedList; + /** * Transport action used to retrieve the mappings related to fields that belong to a specific index */ @@ -178,7 +179,7 @@ public class TransportGetFieldMappingsIndexAction extends TransportSingleShardAc } else if (Regex.isSimpleMatchPattern(field)) { // go through the field mappers 3 times, to make sure we give preference to the resolve order: full name, index name, name. // also make sure we only store each mapper once. - Collection remainingFieldMappers = Lists.newLinkedList(allFieldMappers); + Collection remainingFieldMappers = newLinkedList(allFieldMappers); for (Iterator it = remainingFieldMappers.iterator(); it.hasNext(); ) { final FieldMapper fieldMapper = it.next(); if (Regex.simpleMatch(field, fieldMapper.fieldType().names().fullName())) { diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/optimize/TransportOptimizeAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/optimize/TransportOptimizeAction.java index 6b5416985e7..bc5cb57d8b5 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/optimize/TransportOptimizeAction.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/optimize/TransportOptimizeAction.java @@ -38,11 +38,10 @@ import org.elasticsearch.indices.IndicesService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicReferenceArray; -import static com.google.common.collect.Lists.newArrayList; - /** * Optimize index/indices action. */ @@ -71,7 +70,7 @@ public class TransportOptimizeAction extends TransportBroadcastAction(); } shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse)); } else { diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/TransportRefreshAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/TransportRefreshAction.java index 32e9e509993..2eead86e202 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/TransportRefreshAction.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/TransportRefreshAction.java @@ -38,11 +38,10 @@ import org.elasticsearch.indices.IndicesService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicReferenceArray; -import static com.google.common.collect.Lists.newArrayList; - /** * Refresh action. */ @@ -71,7 +70,7 @@ public class TransportRefreshAction extends TransportBroadcastAction(); } shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse)); } else { diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/segments/IndexSegments.java b/core/src/main/java/org/elasticsearch/action/admin/indices/segments/IndexSegments.java index 453a6f12b1a..52c31433591 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/segments/IndexSegments.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/segments/IndexSegments.java @@ -19,9 +19,9 @@ package org.elasticsearch.action.admin.indices.segments; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -39,7 +39,7 @@ public class IndexSegments implements Iterable { for (ShardSegments shard : shards) { List lst = tmpIndexShards.get(shard.getShardRouting().id()); if (lst == null) { - lst = Lists.newArrayList(); + lst = new ArrayList<>(); tmpIndexShards.put(shard.getShardRouting().id(), lst); } lst.add(shard); diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/segments/IndicesSegmentResponse.java b/core/src/main/java/org/elasticsearch/action/admin/indices/segments/IndicesSegmentResponse.java index 6b0dc8697f3..033ecf78555 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/segments/IndicesSegmentResponse.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/segments/IndicesSegmentResponse.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.admin.indices.segments; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import org.apache.lucene.util.Accountable; @@ -35,6 +34,7 @@ import org.elasticsearch.common.xcontent.XContentBuilderString; import org.elasticsearch.index.engine.Segment; import java.io.IOException; +import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Map; @@ -67,7 +67,7 @@ public class IndicesSegmentResponse extends BroadcastResponse implements ToXCont } for (String index : indices) { - List shards = Lists.newArrayList(); + List shards = new ArrayList<>(); for (ShardSegments shard : this.shards) { if (shard.getShardRouting().index().equals(index)) { shards.add(shard); diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/segments/TransportIndicesSegmentsAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/segments/TransportIndicesSegmentsAction.java index ee7cc5a98a1..5a6ff58360c 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/segments/TransportIndicesSegmentsAction.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/segments/TransportIndicesSegmentsAction.java @@ -44,11 +44,10 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicReferenceArray; -import static com.google.common.collect.Lists.newArrayList; - /** * */ @@ -87,7 +86,7 @@ public class TransportIndicesSegmentsAction extends TransportBroadcastAction shardFailures = null; - final List shards = newArrayList(); + final List shards = new ArrayList<>(); for (int i = 0; i < shardsResponses.length(); i++) { Object shardResponse = shardsResponses.get(i); if (shardResponse == null) { @@ -95,7 +94,7 @@ public class TransportIndicesSegmentsAction extends TransportBroadcastAction(); } shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse)); } else { diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/stats/IndexStats.java b/core/src/main/java/org/elasticsearch/action/admin/indices/stats/IndexStats.java index 7cda8d0972a..6f701e4134c 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/stats/IndexStats.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/stats/IndexStats.java @@ -19,9 +19,9 @@ package org.elasticsearch.action.admin.indices.stats; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -57,7 +57,7 @@ public class IndexStats implements Iterable { for (ShardStats shard : shards) { List lst = tmpIndexShards.get(shard.getShardRouting().id()); if (lst == null) { - lst = Lists.newArrayList(); + lst = new ArrayList<>(); tmpIndexShards.put(shard.getShardRouting().id(), lst); } lst.add(shard); diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsResponse.java b/core/src/main/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsResponse.java index 2d9bf1e78f9..d9b8e9da77d 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsResponse.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsResponse.java @@ -20,7 +20,6 @@ package org.elasticsearch.action.admin.indices.stats; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import org.elasticsearch.action.ShardOperationFailedException; @@ -35,6 +34,7 @@ import org.elasticsearch.common.xcontent.XContentBuilderString; import org.elasticsearch.common.xcontent.XContentFactory; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; @@ -94,7 +94,7 @@ public class IndicesStatsResponse extends BroadcastResponse implements ToXConten } for (String index : indices) { - List shards = Lists.newArrayList(); + List shards = new ArrayList<>(); for (ShardStats shard : this.shards) { if (shard.getShardRouting().index().equals(index)) { shards.add(shard); diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/stats/TransportIndicesStatsAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/stats/TransportIndicesStatsAction.java index fa347c838ca..9ce5291ba66 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/stats/TransportIndicesStatsAction.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/stats/TransportIndicesStatsAction.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.admin.indices.stats; -import com.google.common.collect.Lists; import org.elasticsearch.action.ShardOperationFailedException; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.DefaultShardOperationFailedException; @@ -46,11 +45,10 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicReferenceArray; -import static com.google.common.collect.Lists.newArrayList; - /** */ public class TransportIndicesStatsAction extends TransportBroadcastAction { @@ -90,7 +88,7 @@ public class TransportIndicesStatsAction extends TransportBroadcastAction shardFailures = null; - final List shards = Lists.newArrayList(); + final List shards = new ArrayList<>(); for (int i = 0; i < shardsResponses.length(); i++) { Object shardResponse = shardsResponses.get(i); if (shardResponse == null) { @@ -98,7 +96,7 @@ public class TransportIndicesStatsAction extends TransportBroadcastAction(); } shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse)); } else { diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/template/get/GetIndexTemplatesResponse.java b/core/src/main/java/org/elasticsearch/action/admin/indices/template/get/GetIndexTemplatesResponse.java index 2ce6d8d2c1a..dfe99852dce 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/template/get/GetIndexTemplatesResponse.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/template/get/GetIndexTemplatesResponse.java @@ -18,13 +18,13 @@ */ package org.elasticsearch.action.admin.indices.template.get; -import com.google.common.collect.Lists; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.cluster.metadata.IndexTemplateMetaData; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import java.io.IOException; +import java.util.ArrayList; import java.util.List; /** @@ -49,7 +49,7 @@ public class GetIndexTemplatesResponse extends ActionResponse { public void readFrom(StreamInput in) throws IOException { super.readFrom(in); int size = in.readVInt(); - indexTemplates = Lists.newArrayListWithExpectedSize(size); + indexTemplates = new ArrayList<>(size); for (int i = 0 ; i < size ; i++) { indexTemplates.add(0, IndexTemplateMetaData.Builder.readFrom(in)); } diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/template/get/TransportGetIndexTemplatesAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/template/get/TransportGetIndexTemplatesAction.java index f5f33c657a3..23f2399da39 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/template/get/TransportGetIndexTemplatesAction.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/template/get/TransportGetIndexTemplatesAction.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.admin.indices.template.get; import com.carrotsearch.hppc.cursors.ObjectObjectCursor; -import com.google.common.collect.Lists; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.master.TransportMasterNodeReadAction; @@ -35,6 +34,8 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; /** @@ -69,9 +70,9 @@ public class TransportGetIndexTemplatesAction extends TransportMasterNodeReadAct // If we did not ask for a specific name, then we return all templates if (request.names().length == 0) { - results = Lists.newArrayList(state.metaData().templates().values().toArray(IndexTemplateMetaData.class)); + results = Arrays.asList(state.metaData().templates().values().toArray(IndexTemplateMetaData.class)); } else { - results = Lists.newArrayList(); + results = new ArrayList<>(); } for (String name : request.names()) { diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/IndexUpgradeStatus.java b/core/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/IndexUpgradeStatus.java index 33a60328951..b85359cb696 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/IndexUpgradeStatus.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/IndexUpgradeStatus.java @@ -19,9 +19,9 @@ package org.elasticsearch.action.admin.indices.upgrade.get; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -39,7 +39,7 @@ public class IndexUpgradeStatus implements Iterable { for (ShardUpgradeStatus shard : shards) { List lst = tmpIndexShards.get(shard.getShardRouting().id()); if (lst == null) { - lst = Lists.newArrayList(); + lst = new ArrayList<>(); tmpIndexShards.put(shard.getShardRouting().id(), lst); } lst.add(shard); diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/TransportUpgradeStatusAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/TransportUpgradeStatusAction.java index a169bc4f76d..72cc2277ab7 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/TransportUpgradeStatusAction.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/TransportUpgradeStatusAction.java @@ -43,11 +43,10 @@ import org.elasticsearch.indices.IndicesService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicReferenceArray; -import static com.google.common.collect.Lists.newArrayList; - /** * */ @@ -86,7 +85,7 @@ public class TransportUpgradeStatusAction extends TransportBroadcastAction shardFailures = null; - final List shards = newArrayList(); + final List shards = new ArrayList<>(); for (int i = 0; i < shardsResponses.length(); i++) { Object shardResponse = shardsResponses.get(i); if (shardResponse == null) { @@ -94,7 +93,7 @@ public class TransportUpgradeStatusAction extends TransportBroadcastAction(); } shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse)); } else { diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/UpgradeStatusResponse.java b/core/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/UpgradeStatusResponse.java index 89520704049..16e24ee66ae 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/UpgradeStatusResponse.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/upgrade/get/UpgradeStatusResponse.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.admin.indices.upgrade.get; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import org.elasticsearch.action.ShardOperationFailedException; @@ -31,6 +30,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilderString; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; @@ -63,7 +63,7 @@ public class UpgradeStatusResponse extends BroadcastResponse implements ToXConte } for (String index : indices) { - List shards = Lists.newArrayList(); + List shards = new ArrayList<>(); for (ShardUpgradeStatus shard : this.shards) { if (shard.getShardRouting().index().equals(index)) { shards.add(shard); diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/TransportUpgradeAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/TransportUpgradeAction.java index 39a736019f4..23d40a55cf0 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/TransportUpgradeAction.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/TransportUpgradeAction.java @@ -33,7 +33,10 @@ import org.elasticsearch.cluster.block.ClusterBlockException; import org.elasticsearch.cluster.block.ClusterBlockLevel; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.MetaData; -import org.elasticsearch.cluster.routing.*; +import org.elasticsearch.cluster.routing.GroupShardsIterator; +import org.elasticsearch.cluster.routing.IndexRoutingTable; +import org.elasticsearch.cluster.routing.RoutingTable; +import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -42,12 +45,12 @@ import org.elasticsearch.indices.IndicesService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicReferenceArray; -import static com.google.common.collect.Lists.newArrayList; import static com.google.common.collect.Maps.newHashMap; import static com.google.common.collect.Sets.newHashSet; @@ -84,7 +87,7 @@ public class TransportUpgradeAction extends TransportBroadcastAction(); } shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse)); } else { diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/TransportValidateQueryAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/TransportValidateQueryAction.java index a87f497c21b..6fefa0ddfd4 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/TransportValidateQueryAction.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/TransportValidateQueryAction.java @@ -54,14 +54,13 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.atomic.AtomicReferenceArray; -import static com.google.common.collect.Lists.newArrayList; - /** * */ @@ -136,7 +135,7 @@ public class TransportValidateQueryAction extends TransportBroadcastAction(); } shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse)); } else { @@ -144,7 +143,7 @@ public class TransportValidateQueryAction extends TransportBroadcastAction(); } queryExplanations.add(new QueryExplanation( validateQueryResponse.getIndex(), diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/warmer/delete/TransportDeleteWarmerAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/warmer/delete/TransportDeleteWarmerAction.java index 18bd2afb743..8df668d1087 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/warmer/delete/TransportDeleteWarmerAction.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/warmer/delete/TransportDeleteWarmerAction.java @@ -18,7 +18,6 @@ */ package org.elasticsearch.action.admin.indices.warmer.delete; -import com.google.common.collect.Lists; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.master.TransportMasterNodeAction; @@ -39,6 +38,7 @@ import org.elasticsearch.search.warmer.IndexWarmersMetaData; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -107,7 +107,7 @@ public class TransportDeleteWarmerAction extends TransportMasterNodeAction entries = Lists.newArrayList(); + List entries = new ArrayList<>(); for (IndexWarmersMetaData.Entry entry : warmers.entries()) { boolean keepWarmer = true; for (String warmer : request.names()) { diff --git a/core/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java b/core/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java index 79abded861e..9a8419f80a8 100644 --- a/core/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java +++ b/core/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java @@ -19,8 +19,6 @@ package org.elasticsearch.action.bulk; -import com.google.common.collect.Lists; - import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.CompositeIndicesRequest; @@ -57,7 +55,7 @@ public class BulkRequest extends ActionRequest implements Composite private static final int REQUEST_OVERHEAD = 50; - final List requests = Lists.newArrayList(); + final List requests = new ArrayList<>(); List payloads = null; protected TimeValue timeout = BulkShardRequest.DEFAULT_TIMEOUT; @@ -186,7 +184,7 @@ public class BulkRequest extends ActionRequest implements Composite @Override @SuppressWarnings("unchecked") public List subRequests() { - List indicesRequests = Lists.newArrayList(); + List indicesRequests = new ArrayList<>(); for (ActionRequest request : requests) { assert request instanceof IndicesRequest; indicesRequests.add((IndicesRequest) request); diff --git a/core/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java b/core/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java index 07427acfd82..fd78241db6b 100644 --- a/core/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java +++ b/core/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.bulk; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.ElasticsearchParseException; @@ -57,7 +56,13 @@ import org.elasticsearch.indices.IndexClosedException; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; -import java.util.*; +import java.util.ArrayList; +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.atomic.AtomicInteger; /** @@ -251,7 +256,7 @@ public class TransportBulkAction extends HandledTransportAction list = requestsByShard.get(shardId); if (list == null) { - list = Lists.newArrayList(); + list = new ArrayList<>(); requestsByShard.put(shardId, list); } list.add(new BulkItemRequest(i, request)); @@ -265,7 +270,7 @@ public class TransportBulkAction extends HandledTransportAction list = requestsByShard.get(shardIt.shardId()); if (list == null) { - list = Lists.newArrayList(); + list = new ArrayList<>(); requestsByShard.put(shardIt.shardId(), list); } list.add(new BulkItemRequest(i, new DeleteRequest(deleteRequest))); @@ -274,7 +279,7 @@ public class TransportBulkAction extends HandledTransportAction list = requestsByShard.get(shardId); if (list == null) { - list = Lists.newArrayList(); + list = new ArrayList<>(); requestsByShard.put(shardId, list); } list.add(new BulkItemRequest(i, request)); @@ -292,7 +297,7 @@ public class TransportBulkAction extends HandledTransportAction list = requestsByShard.get(shardId); if (list == null) { - list = Lists.newArrayList(); + list = new ArrayList<>(); requestsByShard.put(shardId, list); } list.add(new BulkItemRequest(i, request)); diff --git a/core/src/main/java/org/elasticsearch/action/exists/TransportExistsAction.java b/core/src/main/java/org/elasticsearch/action/exists/TransportExistsAction.java index 693a6ccb935..d9c89e78328 100644 --- a/core/src/main/java/org/elasticsearch/action/exists/TransportExistsAction.java +++ b/core/src/main/java/org/elasticsearch/action/exists/TransportExistsAction.java @@ -54,13 +54,13 @@ import org.elasticsearch.search.query.QueryPhaseExecutionException; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReferenceArray; -import static com.google.common.collect.Lists.newArrayList; import static org.elasticsearch.action.exists.ExistsRequest.DEFAULT_MIN_SCORE; public class TransportExistsAction extends TransportBroadcastAction { @@ -131,7 +131,7 @@ public class TransportExistsAction extends TransportBroadcastAction(); } shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse)); } else { diff --git a/core/src/main/java/org/elasticsearch/action/percolate/MultiPercolateRequest.java b/core/src/main/java/org/elasticsearch/action/percolate/MultiPercolateRequest.java index 2778e03d8bc..74537379d1d 100644 --- a/core/src/main/java/org/elasticsearch/action/percolate/MultiPercolateRequest.java +++ b/core/src/main/java/org/elasticsearch/action/percolate/MultiPercolateRequest.java @@ -18,7 +18,6 @@ */ package org.elasticsearch.action.percolate; -import com.google.common.collect.Lists; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequestValidationException; @@ -35,6 +34,7 @@ import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -50,7 +50,7 @@ public class MultiPercolateRequest extends ActionRequest private String[] indices; private String documentType; private IndicesOptions indicesOptions = IndicesOptions.strictExpandOpenAndForbidClosed(); - private List requests = Lists.newArrayList(); + private List requests = new ArrayList<>(); /** * Embeds a percolate request to this multi percolate request @@ -163,7 +163,7 @@ public class MultiPercolateRequest extends ActionRequest @Override public List subRequests() { - List indicesRequests = Lists.newArrayList(); + List indicesRequests = new ArrayList<>(); for (PercolateRequest percolateRequest : this.requests) { indicesRequests.addAll(percolateRequest.subRequests()); } diff --git a/core/src/main/java/org/elasticsearch/action/percolate/PercolateRequest.java b/core/src/main/java/org/elasticsearch/action/percolate/PercolateRequest.java index 9c9a3859585..47f39cef0bd 100644 --- a/core/src/main/java/org/elasticsearch/action/percolate/PercolateRequest.java +++ b/core/src/main/java/org/elasticsearch/action/percolate/PercolateRequest.java @@ -18,7 +18,6 @@ */ package org.elasticsearch.action.percolate; -import com.google.common.collect.Lists; import org.elasticsearch.ElasticsearchGenerationException; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.CompositeIndicesRequest; @@ -35,6 +34,7 @@ import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentType; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -79,7 +79,7 @@ public class PercolateRequest extends BroadcastRequest impleme @Override public List subRequests() { - List requests = Lists.newArrayList(); + List requests = new ArrayList<>(); requests.add(this); if (getRequest != null) { requests.add(getRequest); diff --git a/core/src/main/java/org/elasticsearch/action/percolate/PercolateSourceBuilder.java b/core/src/main/java/org/elasticsearch/action/percolate/PercolateSourceBuilder.java index af8aa43837e..967d5a0a2b7 100644 --- a/core/src/main/java/org/elasticsearch/action/percolate/PercolateSourceBuilder.java +++ b/core/src/main/java/org/elasticsearch/action/percolate/PercolateSourceBuilder.java @@ -19,8 +19,6 @@ package org.elasticsearch.action.percolate; -import com.google.common.collect.Lists; - import org.elasticsearch.ElasticsearchGenerationException; import org.elasticsearch.action.support.ToXContentToBytes; import org.elasticsearch.client.Requests; @@ -38,6 +36,7 @@ import org.elasticsearch.search.sort.ScoreSortBuilder; import org.elasticsearch.search.sort.SortBuilder; import java.io.IOException; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -99,7 +98,7 @@ public class PercolateSourceBuilder extends ToXContentToBytes { */ public PercolateSourceBuilder addSort(SortBuilder sort) { if (sorts == null) { - sorts = Lists.newArrayList(); + sorts = new ArrayList<>(); } sorts.add(sort); return this; @@ -127,7 +126,7 @@ public class PercolateSourceBuilder extends ToXContentToBytes { */ public PercolateSourceBuilder addAggregation(AbstractAggregationBuilder aggregationBuilder) { if (aggregations == null) { - aggregations = Lists.newArrayList(); + aggregations = new ArrayList<>(); } aggregations.add(aggregationBuilder); return this; diff --git a/core/src/main/java/org/elasticsearch/action/percolate/TransportPercolateAction.java b/core/src/main/java/org/elasticsearch/action/percolate/TransportPercolateAction.java index bb160f84962..2194975161a 100644 --- a/core/src/main/java/org/elasticsearch/action/percolate/TransportPercolateAction.java +++ b/core/src/main/java/org/elasticsearch/action/percolate/TransportPercolateAction.java @@ -43,13 +43,12 @@ import org.elasticsearch.percolator.PercolatorService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicReferenceArray; -import static com.google.common.collect.Lists.newArrayList; - /** * */ @@ -126,7 +125,7 @@ public class TransportPercolateAction extends TransportBroadcastAction(); } shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse)); } else { @@ -135,7 +134,7 @@ public class TransportPercolateAction extends TransportBroadcastAction(); } shardResults.add(percolateShardResponse); } diff --git a/core/src/main/java/org/elasticsearch/action/search/ClearScrollRequest.java b/core/src/main/java/org/elasticsearch/action/search/ClearScrollRequest.java index 4ffd5e29ceb..17343e86912 100644 --- a/core/src/main/java/org/elasticsearch/action/search/ClearScrollRequest.java +++ b/core/src/main/java/org/elasticsearch/action/search/ClearScrollRequest.java @@ -25,10 +25,10 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import java.io.IOException; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import static com.google.common.collect.Lists.newArrayList; import static org.elasticsearch.action.ValidateActions.addValidationError; /** @@ -47,7 +47,7 @@ public class ClearScrollRequest extends ActionRequest { public void addScrollId(String scrollId) { if (scrollIds == null) { - scrollIds = newArrayList(); + scrollIds = new ArrayList<>(); } scrollIds.add(scrollId); } diff --git a/core/src/main/java/org/elasticsearch/action/search/MultiSearchRequest.java b/core/src/main/java/org/elasticsearch/action/search/MultiSearchRequest.java index 06e7d03b98d..df2e2424e71 100644 --- a/core/src/main/java/org/elasticsearch/action/search/MultiSearchRequest.java +++ b/core/src/main/java/org/elasticsearch/action/search/MultiSearchRequest.java @@ -19,8 +19,6 @@ package org.elasticsearch.action.search; -import com.google.common.collect.Lists; - import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.CompositeIndicesRequest; @@ -41,16 +39,14 @@ import java.util.List; import java.util.Map; import static org.elasticsearch.action.ValidateActions.addValidationError; -import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeBooleanValue; -import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeStringArrayValue; -import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeStringValue; +import static org.elasticsearch.common.xcontent.support.XContentMapValues.*; /** * A multi search API request. */ public class MultiSearchRequest extends ActionRequest implements CompositeIndicesRequest { - private List requests = Lists.newArrayList(); + private List requests = new ArrayList<>(); private IndicesOptions indicesOptions = IndicesOptions.strictExpandOpenAndForbidClosed(); diff --git a/core/src/main/java/org/elasticsearch/action/suggest/TransportSuggestAction.java b/core/src/main/java/org/elasticsearch/action/suggest/TransportSuggestAction.java index 2269856c072..c584c8856a5 100644 --- a/core/src/main/java/org/elasticsearch/action/suggest/TransportSuggestAction.java +++ b/core/src/main/java/org/elasticsearch/action/suggest/TransportSuggestAction.java @@ -48,14 +48,13 @@ import org.elasticsearch.search.suggest.SuggestionSearchContext; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicReferenceArray; -import static com.google.common.collect.Lists.newArrayList; - /** * Defines the transport of a suggestion request across the cluster */ @@ -115,7 +114,7 @@ public class TransportSuggestAction extends TransportBroadcastAction(); } shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse)); } else { diff --git a/core/src/main/java/org/elasticsearch/action/support/AbstractListenableActionFuture.java b/core/src/main/java/org/elasticsearch/action/support/AbstractListenableActionFuture.java index 7d4497d4bd6..790689b4206 100644 --- a/core/src/main/java/org/elasticsearch/action/support/AbstractListenableActionFuture.java +++ b/core/src/main/java/org/elasticsearch/action/support/AbstractListenableActionFuture.java @@ -19,13 +19,13 @@ package org.elasticsearch.action.support; -import com.google.common.collect.Lists; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ListenableActionFuture; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.threadpool.ThreadPool; +import java.util.ArrayList; import java.util.List; /** @@ -66,7 +66,7 @@ public abstract class AbstractListenableActionFuture extends AdapterAction ((List) this.listeners).add(listener); } else { Object orig = listeners; - listeners = Lists.newArrayListWithCapacity(2); + listeners = new ArrayList<>(2); ((List) listeners).add(orig); ((List) listeners).add(listener); } diff --git a/core/src/main/java/org/elasticsearch/action/termvectors/dfs/TransportDfsOnlyAction.java b/core/src/main/java/org/elasticsearch/action/termvectors/dfs/TransportDfsOnlyAction.java index d3bf24de577..32e9d05e497 100644 --- a/core/src/main/java/org/elasticsearch/action/termvectors/dfs/TransportDfsOnlyAction.java +++ b/core/src/main/java/org/elasticsearch/action/termvectors/dfs/TransportDfsOnlyAction.java @@ -42,13 +42,12 @@ import org.elasticsearch.search.dfs.DfsSearchResult; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicReferenceArray; -import static com.google.common.collect.Lists.newArrayList; - /** * Get the dfs only with no fetch phase. This is for internal use only. */ @@ -115,7 +114,7 @@ public class TransportDfsOnlyAction extends TransportBroadcastAction(); } shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse)); } else { diff --git a/core/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java b/core/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java index 4ffc2abae2b..8e93ded7b61 100644 --- a/core/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java +++ b/core/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java @@ -21,7 +21,6 @@ package org.elasticsearch.client.transport; import com.carrotsearch.hppc.cursors.ObjectCursor; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; import com.google.common.collect.Sets; import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.Version; @@ -43,9 +42,20 @@ import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.ConcurrentCollections; import org.elasticsearch.common.util.concurrent.FutureUtils; import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.*; +import org.elasticsearch.transport.BaseTransportResponseHandler; +import org.elasticsearch.transport.ConnectTransportException; +import org.elasticsearch.transport.FutureTransportResponseHandler; +import org.elasticsearch.transport.TransportException; +import org.elasticsearch.transport.TransportRequestOptions; +import org.elasticsearch.transport.TransportService; -import java.util.*; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ScheduledFuture; @@ -143,7 +153,7 @@ public class TransportClientNodesService extends AbstractComponent { if (closed) { throw new IllegalStateException("transport client is closed, can't add an address"); } - List filtered = Lists.newArrayListWithExpectedSize(transportAddresses.length); + List filtered = new ArrayList<>(transportAddresses.length); for (TransportAddress transportAddress : transportAddresses) { boolean found = false; for (DiscoveryNode otherNode : listedNodes) { diff --git a/core/src/main/java/org/elasticsearch/cluster/ClusterChangedEvent.java b/core/src/main/java/org/elasticsearch/cluster/ClusterChangedEvent.java index 1ceb822abfd..209781d78f5 100644 --- a/core/src/main/java/org/elasticsearch/cluster/ClusterChangedEvent.java +++ b/core/src/main/java/org/elasticsearch/cluster/ClusterChangedEvent.java @@ -21,11 +21,11 @@ package org.elasticsearch.cluster; import com.carrotsearch.hppc.cursors.ObjectCursor; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.node.DiscoveryNodes; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -93,7 +93,7 @@ public class ClusterChangedEvent { String index = cursor.value; if (!previousState.metaData().hasIndex(index)) { if (created == null) { - created = Lists.newArrayList(); + created = new ArrayList<>(); } created.add(index); } @@ -126,7 +126,7 @@ public class ClusterChangedEvent { String index = cursor.value; if (!state.metaData().hasIndex(index)) { if (deleted == null) { - deleted = Lists.newArrayList(); + deleted = new ArrayList<>(); } deleted.add(index); } diff --git a/core/src/main/java/org/elasticsearch/cluster/DiffableUtils.java b/core/src/main/java/org/elasticsearch/cluster/DiffableUtils.java index 4e912a34f97..60095de09a3 100644 --- a/core/src/main/java/org/elasticsearch/cluster/DiffableUtils.java +++ b/core/src/main/java/org/elasticsearch/cluster/DiffableUtils.java @@ -27,11 +27,11 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import java.io.IOException; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import static com.google.common.collect.Lists.newArrayList; import static com.google.common.collect.Maps.newHashMap; public final class DiffableUtils { @@ -232,13 +232,13 @@ public final class DiffableUtils { protected final Map adds; protected MapDiff() { - deletes = newArrayList(); + deletes = new ArrayList<>(); diffs = newHashMap(); adds = newHashMap(); } protected MapDiff(StreamInput in, KeyedReader reader) throws IOException { - deletes = newArrayList(); + deletes = new ArrayList<>(); diffs = newHashMap(); adds = newHashMap(); int deletesCount = in.readVInt(); diff --git a/core/src/main/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolver.java b/core/src/main/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolver.java index 2f28dcaf77d..eb5b716017a 100644 --- a/core/src/main/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolver.java +++ b/core/src/main/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolver.java @@ -41,10 +41,17 @@ import org.joda.time.DateTimeZone; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; import java.util.concurrent.Callable; -import static com.google.common.collect.Lists.newArrayList; import static com.google.common.collect.Maps.filterEntries; import static com.google.common.collect.Maps.newHashMap; @@ -268,7 +275,7 @@ public class IndexNameExpressionResolver extends AbstractComponent { if (filteringRequired) { // If filtering required - add it to the list of filters if (filteringAliases == null) { - filteringAliases = newArrayList(); + filteringAliases = new ArrayList<>(); } filteringAliases.add(alias); } else { diff --git a/core/src/main/java/org/elasticsearch/cluster/metadata/MetaData.java b/core/src/main/java/org/elasticsearch/cluster/metadata/MetaData.java index 32098e58c83..001bf424a2b 100644 --- a/core/src/main/java/org/elasticsearch/cluster/metadata/MetaData.java +++ b/core/src/main/java/org/elasticsearch/cluster/metadata/MetaData.java @@ -23,7 +23,10 @@ import com.carrotsearch.hppc.ObjectHashSet; import com.carrotsearch.hppc.cursors.ObjectCursor; import com.carrotsearch.hppc.cursors.ObjectObjectCursor; import com.google.common.base.Predicate; -import com.google.common.collect.*; +import com.google.common.collect.Collections2; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.UnmodifiableIterator; import org.apache.lucene.util.CollectionUtil; import org.elasticsearch.cluster.Diff; import org.elasticsearch.cluster.Diffable; @@ -45,7 +48,12 @@ import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.loader.SettingsLoader; -import org.elasticsearch.common.xcontent.*; +import org.elasticsearch.common.xcontent.FromXContentBuilder; +import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.common.xcontent.XContentFactory; +import org.elasticsearch.common.xcontent.XContentParser; +import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.discovery.DiscoverySettings; import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.indices.recovery.RecoverySettings; @@ -55,7 +63,18 @@ import org.elasticsearch.rest.RestStatus; import org.elasticsearch.search.warmer.IndexWarmersMetaData; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.SortedMap; +import java.util.TreeMap; import static org.elasticsearch.common.settings.Settings.*; @@ -246,7 +265,7 @@ public class MetaData implements Iterable, Diffable, Fr Iterable intersection = HppcMaps.intersection(ObjectHashSet.from(concreteIndices), indices.keys()); for (String index : intersection) { IndexMetaData indexMetaData = indices.get(index); - List filteredValues = Lists.newArrayList(); + List filteredValues = new ArrayList<>(); for (ObjectCursor cursor : indexMetaData.getAliases().values()) { AliasMetaData value = cursor.value; if (matchAllAliases || Regex.simpleMatch(aliases, value.alias())) { @@ -295,7 +314,7 @@ public class MetaData implements Iterable, Diffable, Fr Iterable intersection = HppcMaps.intersection(ObjectHashSet.from(concreteIndices), indices.keys()); for (String index : intersection) { IndexMetaData indexMetaData = indices.get(index); - List filteredValues = Lists.newArrayList(); + List filteredValues = new ArrayList<>(); for (ObjectCursor cursor : indexMetaData.getAliases().values()) { AliasMetaData value = cursor.value; if (Regex.simpleMatch(aliases, value.alias())) { @@ -978,14 +997,14 @@ public class MetaData implements Iterable, Diffable, Fr // TODO: I think we can remove these arrays. it isn't worth the effort, for operations on all indices. // When doing an operation across all indices, most of the time is spent on actually going to all shards and // do the required operations, the bottleneck isn't resolving expressions into concrete indices. - List allIndicesLst = Lists.newArrayList(); + List allIndicesLst = new ArrayList<>(); for (ObjectCursor cursor : indices.values()) { allIndicesLst.add(cursor.value.index()); } String[] allIndices = allIndicesLst.toArray(new String[allIndicesLst.size()]); - List allOpenIndicesLst = Lists.newArrayList(); - List allClosedIndicesLst = Lists.newArrayList(); + List allOpenIndicesLst = new ArrayList<>(); + List allClosedIndicesLst = new ArrayList<>(); for (ObjectCursor cursor : indices.values()) { IndexMetaData indexMetaData = cursor.value; if (indexMetaData.state() == IndexMetaData.State.OPEN) { diff --git a/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java b/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java index ff878a4f721..bebb8e52f07 100644 --- a/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java +++ b/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java @@ -22,7 +22,6 @@ package org.elasticsearch.cluster.metadata; import com.carrotsearch.hppc.cursors.ObjectCursor; import com.carrotsearch.hppc.cursors.ObjectObjectCursor; import com.google.common.base.Charsets; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import org.apache.lucene.util.CollectionUtil; import org.elasticsearch.ElasticsearchException; @@ -80,7 +79,12 @@ import java.io.UnsupportedEncodingException; import java.nio.file.DirectoryStream; import java.nio.file.Files; import java.nio.file.Path; -import java.util.*; +import java.util.ArrayList; +import java.util.Comparator; +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; @@ -248,7 +252,7 @@ public class MetaDataCreateIndexService extends AbstractComponent { Map templatesAliases = Maps.newHashMap(); - List templateNames = Lists.newArrayList(); + List templateNames = new ArrayList<>(); for (Map.Entry entry : request.mappings().entrySet()) { mappings.put(entry.getKey(), parseMapping(entry.getValue())); @@ -494,7 +498,7 @@ public class MetaDataCreateIndexService extends AbstractComponent { } private List findTemplates(CreateIndexClusterStateUpdateRequest request, ClusterState state, IndexTemplateFilter indexTemplateFilter) throws IOException { - List templates = Lists.newArrayList(); + List templates = new ArrayList<>(); for (ObjectCursor cursor : state.metaData().templates().values()) { IndexTemplateMetaData template = cursor.value; if (indexTemplateFilter.apply(request, template)) { @@ -527,7 +531,7 @@ public class MetaDataCreateIndexService extends AbstractComponent { List getIndexSettingsValidationErrors(Settings settings) { String customPath = settings.get(IndexMetaData.SETTING_DATA_PATH, null); - List validationErrors = Lists.newArrayList(); + List validationErrors = new ArrayList<>(); if (customPath != null && env.sharedDataFile() == null) { validationErrors.add("path.shared_data must be set in order to use custom data paths"); } else if (customPath != null) { diff --git a/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexAliasesService.java b/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexAliasesService.java index d5512f63172..787640db639 100644 --- a/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexAliasesService.java +++ b/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexAliasesService.java @@ -20,7 +20,6 @@ package org.elasticsearch.cluster.metadata; import com.carrotsearch.hppc.cursors.ObjectCursor; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesClusterStateUpdateRequest; @@ -34,10 +33,11 @@ import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.IndexNotFoundException; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.IndexService; +import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.indices.IndicesService; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -69,7 +69,7 @@ public class MetaDataIndexAliasesService extends AbstractComponent { @Override public ClusterState execute(final ClusterState currentState) { - List indicesToClose = Lists.newArrayList(); + List indicesToClose = new ArrayList<>(); Map indices = Maps.newHashMap(); try { for (AliasAction aliasAction : request.actions()) { diff --git a/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexTemplateService.java b/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexTemplateService.java index 66ad39f9225..7e26c2ca743 100644 --- a/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexTemplateService.java +++ b/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexTemplateService.java @@ -19,7 +19,6 @@ package org.elasticsearch.cluster.metadata; import com.carrotsearch.hppc.cursors.ObjectCursor; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import org.elasticsearch.action.admin.indices.alias.Alias; @@ -39,6 +38,7 @@ import org.elasticsearch.indices.IndexTemplateAlreadyExistsException; import org.elasticsearch.indices.IndexTemplateMissingException; import org.elasticsearch.indices.InvalidIndexTemplateException; +import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.Map; @@ -179,7 +179,7 @@ public class MetaDataIndexTemplateService extends AbstractComponent { } private void validate(PutRequest request) { - List validationErrors = Lists.newArrayList(); + List validationErrors = new ArrayList<>(); if (request.name.contains(" ")) { validationErrors.add("name must not contain a space"); } @@ -240,7 +240,7 @@ public class MetaDataIndexTemplateService extends AbstractComponent { String template; Settings settings = Settings.Builder.EMPTY_SETTINGS; Map mappings = Maps.newHashMap(); - List aliases = Lists.newArrayList(); + List aliases = new ArrayList<>(); Map customs = Maps.newHashMap(); TimeValue masterTimeout = MasterNodeRequest.DEFAULT_MASTER_NODE_TIMEOUT; diff --git a/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataMappingService.java b/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataMappingService.java index 04d52b0ea55..5839502832d 100644 --- a/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataMappingService.java +++ b/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataMappingService.java @@ -20,7 +20,6 @@ package org.elasticsearch.cluster.metadata; import com.carrotsearch.hppc.cursors.ObjectCursor; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import org.elasticsearch.Version; @@ -47,7 +46,12 @@ import org.elasticsearch.indices.IndicesService; import org.elasticsearch.indices.InvalidTypeNameException; import org.elasticsearch.percolator.PercolatorService; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; import static com.google.common.collect.Maps.newHashMap; /** @@ -226,7 +230,7 @@ public class MetaDataMappingService extends AbstractComponent { if (task instanceof RefreshTask) { RefreshTask refreshTask = (RefreshTask) task; try { - List updatedTypes = Lists.newArrayList(); + List updatedTypes = new ArrayList<>(); for (String type : refreshTask.types) { if (processedRefreshes.contains(type)) { continue; @@ -342,7 +346,7 @@ public class MetaDataMappingService extends AbstractComponent { @Override public ClusterState execute(final ClusterState currentState) throws Exception { - List indicesToClose = Lists.newArrayList(); + List indicesToClose = new ArrayList<>(); try { for (String index : request.indices()) { if (!currentState.metaData().hasIndex(index)) { diff --git a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java index 1b95aed4636..eebd770707f 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java @@ -35,12 +35,11 @@ import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.transport.TransportAddress; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; -import static com.google.common.collect.Lists.newArrayList; - /** * This class holds all {@link DiscoveryNode} in the cluster and provides convenience methods to * access, modify merge / diff discovery nodes. @@ -414,8 +413,8 @@ public class DiscoveryNodes extends AbstractDiffable implements * Returns the changes comparing this nodes to the provided nodes. */ public Delta delta(DiscoveryNodes other) { - List removed = newArrayList(); - List added = newArrayList(); + List removed = new ArrayList<>(); + List added = new ArrayList<>(); for (DiscoveryNode node : other) { if (!this.nodeExists(node.id())) { removed.add(node); diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/IndexRoutingTable.java b/core/src/main/java/org/elasticsearch/cluster/routing/IndexRoutingTable.java index 85a14e23008..e8311b5e294 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/IndexRoutingTable.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/IndexRoutingTable.java @@ -25,7 +25,6 @@ import com.carrotsearch.hppc.cursors.IntObjectCursor; import com.google.common.collect.ImmutableList; import com.google.common.collect.Sets; import com.google.common.collect.UnmodifiableIterator; - import org.apache.lucene.util.CollectionUtil; import org.elasticsearch.cluster.AbstractDiffable; import org.elasticsearch.cluster.metadata.IndexMetaData; @@ -42,8 +41,6 @@ import java.util.List; import java.util.Set; import java.util.concurrent.ThreadLocalRandom; -import static com.google.common.collect.Lists.*; - /** * The {@link IndexRoutingTable} represents routing information for a single * index. The routing table maintains a list of all shards in the index. A @@ -265,7 +262,7 @@ public class IndexRoutingTable extends AbstractDiffable imple * @return a {@link List} of shards that match one of the given {@link ShardRoutingState states} */ public List shardsWithState(ShardRoutingState state) { - List shards = newArrayList(); + List shards = new ArrayList<>(); for (IndexShardRoutingTable shardRoutingTable : this) { shards.addAll(shardRoutingTable.shardsWithState(state)); } diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/IndexShardRoutingTable.java b/core/src/main/java/org/elasticsearch/cluster/routing/IndexShardRoutingTable.java index bc13e081563..5cc35aeacef 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/IndexShardRoutingTable.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/IndexShardRoutingTable.java @@ -30,11 +30,15 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.index.shard.ShardId; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.concurrent.ThreadLocalRandom; -import static com.google.common.collect.Lists.newArrayList; - /** * {@link IndexShardRoutingTable} encapsulates all instances of a single shard. * Each Elasticsearch index consists of multiple shards, each shard encapsulates @@ -554,7 +558,7 @@ public class IndexShardRoutingTable implements Iterable { } public List replicaShardsWithState(ShardRoutingState... states) { - List shards = newArrayList(); + List shards = new ArrayList<>(); for (ShardRouting shardEntry : replicas) { for (ShardRoutingState state : states) { if (shardEntry.state() == state) { @@ -569,7 +573,7 @@ public class IndexShardRoutingTable implements Iterable { if (state == ShardRoutingState.INITIALIZING) { return allInitializingShards; } - List shards = newArrayList(); + List shards = new ArrayList<>(); for (ShardRouting shardEntry : this) { if (shardEntry.state() == state) { shards.add(shardEntry); @@ -585,12 +589,12 @@ public class IndexShardRoutingTable implements Iterable { public Builder(IndexShardRoutingTable indexShard) { this.shardId = indexShard.shardId; - this.shards = newArrayList(indexShard.shards); + this.shards = new ArrayList<>(indexShard.shards); } public Builder(ShardId shardId) { this.shardId = shardId; - this.shards = newArrayList(); + this.shards = new ArrayList<>(); } public Builder addShard(ShardRouting shardEntry) { diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/OperationRouting.java b/core/src/main/java/org/elasticsearch/cluster/routing/OperationRouting.java index 6db68524992..411a1ed6817 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/OperationRouting.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/OperationRouting.java @@ -19,7 +19,6 @@ package org.elasticsearch.cluster.routing; -import com.google.common.collect.Lists; import org.elasticsearch.Version; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetaData; @@ -36,6 +35,7 @@ import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.index.shard.ShardNotFoundException; +import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.Map; @@ -90,7 +90,7 @@ public class OperationRouting extends AbstractComponent { set.add(iterator); } } - return new GroupShardsIterator(Lists.newArrayList(set)); + return new GroupShardsIterator(new ArrayList<>(set)); } private static final Map> EMPTY_ROUTING = Collections.emptyMap(); diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/RoutingNode.java b/core/src/main/java/org/elasticsearch/cluster/routing/RoutingNode.java index b96eece2398..43ad6aff1ec 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/RoutingNode.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/RoutingNode.java @@ -27,8 +27,6 @@ import java.util.Collection; import java.util.Iterator; import java.util.List; -import static com.google.common.collect.Lists.newArrayList; - /** * A {@link RoutingNode} represents a cluster node associated with a single {@link DiscoveryNode} including all shards * that are hosted on that nodes. Each {@link RoutingNode} has a unique node id that can be used to identify the node. @@ -118,7 +116,7 @@ public class RoutingNode implements Iterable { * @return List of shards */ public List shardsWithState(ShardRoutingState... states) { - List shards = newArrayList(); + List shards = new ArrayList<>(); for (ShardRouting shardEntry : this) { for (ShardRoutingState state : states) { if (shardEntry.state() == state) { @@ -136,7 +134,7 @@ public class RoutingNode implements Iterable { * @return a list of shards */ public List shardsWithState(String index, ShardRoutingState... states) { - List shards = newArrayList(); + List shards = new ArrayList<>(); for (ShardRouting shardEntry : this) { if (!shardEntry.index().equals(index)) { diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java b/core/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java index 8c07429776a..0836909af8e 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java @@ -22,19 +22,25 @@ package org.elasticsearch.cluster.routing; import com.carrotsearch.hppc.ObjectIntHashMap; import com.carrotsearch.hppc.cursors.ObjectCursor; import com.google.common.base.Predicate; -import com.google.common.collect.*; +import com.google.common.collect.Iterables; +import com.google.common.collect.Iterators; import org.apache.lucene.util.CollectionUtil; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.block.ClusterBlocks; -import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.collect.ImmutableOpenMap; import org.elasticsearch.index.shard.ShardId; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; -import static com.google.common.collect.Lists.newArrayList; import static com.google.common.collect.Maps.newHashMap; import static com.google.common.collect.Sets.newHashSet; @@ -97,7 +103,7 @@ public class RoutingNodes implements Iterable { if (shard.assignedToNode()) { List entries = nodesToShards.get(shard.currentNodeId()); if (entries == null) { - entries = newArrayList(); + entries = new ArrayList<>(); nodesToShards.put(shard.currentNodeId(), entries); } final ShardRouting sr = getRouting(shard, readOnly); @@ -107,7 +113,7 @@ public class RoutingNodes implements Iterable { entries = nodesToShards.get(shard.relocatingNodeId()); relocatingShards++; if (entries == null) { - entries = newArrayList(); + entries = new ArrayList<>(); nodesToShards.put(shard.relocatingNodeId(), entries); } // add the counterpart shard with relocatingNodeId reflecting the source from which @@ -285,7 +291,7 @@ public class RoutingNodes implements Iterable { } public List shards(Predicate predicate) { - List shards = newArrayList(); + List shards = new ArrayList<>(); for (RoutingNode routingNode : this) { for (ShardRouting shardRouting : routingNode) { if (predicate.apply(shardRouting)) { @@ -298,7 +304,7 @@ public class RoutingNodes implements Iterable { public List shardsWithState(ShardRoutingState... state) { // TODO these are used on tests only - move into utils class - List shards = newArrayList(); + List shards = new ArrayList<>(); for (RoutingNode routingNode : this) { shards.addAll(routingNode.shardsWithState(state)); } @@ -313,7 +319,7 @@ public class RoutingNodes implements Iterable { public List shardsWithState(String index, ShardRoutingState... state) { // TODO these are used on tests only - move into utils class - List shards = newArrayList(); + List shards = new ArrayList<>(); for (RoutingNode routingNode : this) { shards.addAll(routingNode.shardsWithState(index, state)); } @@ -452,7 +458,7 @@ public class RoutingNodes implements Iterable { } List shards = assignedShards.get(shard.shardId()); if (shards == null) { - shards = Lists.newArrayList(); + shards = new ArrayList<>(); assignedShards.put(shard.shardId(), shards); } assert assertInstanceNotInList(shard, shards); @@ -724,7 +730,7 @@ public class RoutingNodes implements Iterable { } // Assert that the active shard routing are identical. Set> entries = indicesAndShards.entrySet(); - final List shards = newArrayList(); + final List shards = new ArrayList<>(); for (Map.Entry e : entries) { String index = e.getKey(); for (int i = 0; i < e.getValue(); i++) { diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/RoutingTable.java b/core/src/main/java/org/elasticsearch/cluster/routing/RoutingTable.java index 4fda8391d2b..97749e63819 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/RoutingTable.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/RoutingTable.java @@ -21,8 +21,12 @@ package org.elasticsearch.cluster.routing; import com.carrotsearch.hppc.IntSet; import com.google.common.base.Predicate; -import com.google.common.collect.*; -import org.elasticsearch.cluster.*; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Iterables; +import com.google.common.collect.UnmodifiableIterator; +import org.elasticsearch.cluster.Diff; +import org.elasticsearch.cluster.Diffable; +import org.elasticsearch.cluster.DiffableUtils; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.common.io.stream.StreamInput; @@ -35,7 +39,6 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import static com.google.common.collect.Lists.newArrayList; import static com.google.common.collect.Maps.newHashMap; /** @@ -107,7 +110,7 @@ public class RoutingTable implements Iterable, Diffable shardsWithState(ShardRoutingState state) { - List shards = newArrayList(); + List shards = new ArrayList<>(); for (IndexRoutingTable indexRoutingTable : this) { shards.addAll(indexRoutingTable.shardsWithState(state)); } @@ -120,7 +123,7 @@ public class RoutingTable implements Iterable, Diffable allShards() { - List shards = Lists.newArrayList(); + List shards = new ArrayList<>(); String[] indices = indicesRouting.keySet().toArray(new String[indicesRouting.keySet().size()]); for (String index : indices) { List allShardsIndex = allShards(index); @@ -137,7 +140,7 @@ public class RoutingTable implements Iterable, Diffable allShards(String index) { - List shards = Lists.newArrayList(); + List shards = new ArrayList<>(); IndexRoutingTable indexRoutingTable = index(index); if (indexRoutingTable == null) { throw new IndexNotFoundException(index); diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/RoutingTableValidation.java b/core/src/main/java/org/elasticsearch/cluster/routing/RoutingTableValidation.java index bd1e283f436..acd207f8ad5 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/RoutingTableValidation.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/RoutingTableValidation.java @@ -21,17 +21,15 @@ package org.elasticsearch.cluster.routing; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Lists; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Streamable; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Map; -import static com.google.common.collect.Lists.newArrayList; -import static com.google.common.collect.Lists.newArrayListWithCapacity; import static com.google.common.collect.Maps.newHashMap; /** @@ -57,7 +55,7 @@ public class RoutingTableValidation implements Streamable { if (failures().isEmpty() && indicesFailures().isEmpty()) { return ImmutableList.of(); } - List allFailures = newArrayList(failures()); + List allFailures = new ArrayList<>(failures()); for (Map.Entry> entry : indicesFailures().entrySet()) { for (String failure : entry.getValue()) { allFailures.add("Index [" + entry.getKey() + "]: " + failure); @@ -94,7 +92,7 @@ public class RoutingTableValidation implements Streamable { public void addFailure(String failure) { valid = false; if (failures == null) { - failures = newArrayList(); + failures = new ArrayList<>(); } failures.add(failure); } @@ -106,7 +104,7 @@ public class RoutingTableValidation implements Streamable { } List indexFailures = indicesFailures.get(index); if (indexFailures == null) { - indexFailures = Lists.newArrayList(); + indexFailures = new ArrayList<>(); indicesFailures.put(index, indexFailures); } indexFailures.add(failure); @@ -124,7 +122,7 @@ public class RoutingTableValidation implements Streamable { if (size == 0) { failures = ImmutableList.of(); } else { - failures = Lists.newArrayListWithCapacity(size); + failures = new ArrayList<>(size); for (int i = 0; i < size; i++) { failures.add(in.readString()); } @@ -137,7 +135,7 @@ public class RoutingTableValidation implements Streamable { for (int i = 0; i < size; i++) { String index = in.readString(); int size2 = in.readVInt(); - List indexFailures = newArrayListWithCapacity(size2); + List indexFailures = new ArrayList<>(size2); for (int j = 0; j < size2; j++) { indexFailures.add(in.readString()); } diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationExplanation.java b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationExplanation.java index 4bd19ca2526..f8126f5538a 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationExplanation.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationExplanation.java @@ -19,7 +19,6 @@ package org.elasticsearch.cluster.routing.allocation; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.io.stream.StreamInput; @@ -28,6 +27,7 @@ import org.elasticsearch.common.io.stream.Streamable; import org.elasticsearch.index.shard.ShardId; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -88,7 +88,7 @@ public class AllocationExplanation implements Streamable { public AllocationExplanation add(ShardId shardId, NodeExplanation nodeExplanation) { List list = explanations.get(shardId); if (list == null) { - list = Lists.newArrayList(); + list = new ArrayList<>(); explanations.put(shardId, list); } list.add(nodeExplanation); @@ -121,7 +121,7 @@ public class AllocationExplanation implements Streamable { for (int i = 0; i < size; i++) { ShardId shardId = ShardId.readShardId(in); int size2 = in.readVInt(); - List ne = Lists.newArrayListWithCapacity(size2); + List ne = new ArrayList<>(size2); for (int j = 0; j < size2; j++) { DiscoveryNode node = null; if (in.readBoolean()) { diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java index e5a46855e0c..191ec9556c5 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java @@ -21,12 +21,16 @@ package org.elasticsearch.cluster.routing.allocation; import com.carrotsearch.hppc.cursors.ObjectCursor; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; import org.elasticsearch.cluster.ClusterInfoService; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.node.DiscoveryNode; -import org.elasticsearch.cluster.routing.*; +import org.elasticsearch.cluster.routing.IndexRoutingTable; +import org.elasticsearch.cluster.routing.RoutingNode; +import org.elasticsearch.cluster.routing.RoutingNodes; +import org.elasticsearch.cluster.routing.RoutingTable; +import org.elasticsearch.cluster.routing.ShardRouting; +import org.elasticsearch.cluster.routing.UnassignedInfo; import org.elasticsearch.cluster.routing.allocation.allocator.ShardsAllocators; import org.elasticsearch.cluster.routing.allocation.command.AllocationCommands; import org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders; @@ -36,7 +40,6 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; @@ -235,7 +238,7 @@ public class AllocationService extends AbstractComponent { } // go over and remove dangling replicas that are initializing for primary shards - List shardsToFail = Lists.newArrayList(); + List shardsToFail = new ArrayList<>(); for (ShardRouting shardEntry : routingNodes.unassigned()) { if (shardEntry.primary()) { for (ShardRouting routing : routingNodes.assignedShards(shardEntry)) { diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/RoutingExplanations.java b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/RoutingExplanations.java index 8601bf1d79e..95f1a29eed5 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/RoutingExplanations.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/RoutingExplanations.java @@ -25,10 +25,9 @@ import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; +import java.util.ArrayList; import java.util.List; -import static com.google.common.collect.Lists.newArrayList; - /** * Class used to encapsulate a number of {@link RerouteExplanation} * explanations. @@ -37,7 +36,7 @@ public class RoutingExplanations implements ToXContent { private final List explanations; public RoutingExplanations() { - this.explanations = newArrayList(); + this.explanations = new ArrayList<>(); } public RoutingExplanations add(RerouteExplanation explanation) { diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/AllocationCommands.java b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/AllocationCommands.java index 33a44188407..3e17ce68584 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/AllocationCommands.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/AllocationCommands.java @@ -20,8 +20,8 @@ package org.elasticsearch.cluster.routing.allocation.command; import org.elasticsearch.ElasticsearchParseException; -import org.elasticsearch.cluster.routing.allocation.RoutingExplanations; import org.elasticsearch.cluster.routing.allocation.RoutingAllocation; +import org.elasticsearch.cluster.routing.allocation.RoutingExplanations; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -30,13 +30,12 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; +import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; -import static com.google.common.collect.Lists.newArrayList; - /** * A simple {@link AllocationCommand} composite managing several * {@link AllocationCommand} implementations @@ -73,7 +72,7 @@ public class AllocationCommands { registerFactory(MoveAllocationCommand.NAME, new MoveAllocationCommand.Factory()); } - private final List commands = newArrayList(); + private final List commands = new ArrayList<>(); /** * Creates a new set of {@link AllocationCommands} diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/Decision.java b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/Decision.java index 76922ae2462..02fc2fef948 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/Decision.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/Decision.java @@ -19,13 +19,13 @@ package org.elasticsearch.cluster.routing.allocation.decider; -import com.google.common.collect.Lists; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -226,7 +226,7 @@ public abstract class Decision implements ToXContent { */ public static class Multi extends Decision { - private final List decisions = Lists.newArrayList(); + private final List decisions = new ArrayList<>(); /** * Add a decision to this {@link Multi}decision instance diff --git a/core/src/main/java/org/elasticsearch/common/inject/BindingProcessor.java b/core/src/main/java/org/elasticsearch/common/inject/BindingProcessor.java index 9966a4e0206..58ea0be016d 100644 --- a/core/src/main/java/org/elasticsearch/common/inject/BindingProcessor.java +++ b/core/src/main/java/org/elasticsearch/common/inject/BindingProcessor.java @@ -17,10 +17,33 @@ package org.elasticsearch.common.inject; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; -import org.elasticsearch.common.inject.internal.*; -import org.elasticsearch.common.inject.spi.*; +import org.elasticsearch.common.inject.internal.Annotations; +import org.elasticsearch.common.inject.internal.BindingImpl; +import org.elasticsearch.common.inject.internal.Errors; +import org.elasticsearch.common.inject.internal.ErrorsException; +import org.elasticsearch.common.inject.internal.ExposedBindingImpl; +import org.elasticsearch.common.inject.internal.InstanceBindingImpl; +import org.elasticsearch.common.inject.internal.InternalFactory; +import org.elasticsearch.common.inject.internal.LinkedBindingImpl; +import org.elasticsearch.common.inject.internal.LinkedProviderBindingImpl; +import org.elasticsearch.common.inject.internal.ProviderInstanceBindingImpl; +import org.elasticsearch.common.inject.internal.ProviderMethod; +import org.elasticsearch.common.inject.internal.Scoping; +import org.elasticsearch.common.inject.internal.UntargettedBindingImpl; +import org.elasticsearch.common.inject.spi.BindingTargetVisitor; +import org.elasticsearch.common.inject.spi.ConstructorBinding; +import org.elasticsearch.common.inject.spi.ConvertedConstantBinding; +import org.elasticsearch.common.inject.spi.ExposedBinding; +import org.elasticsearch.common.inject.spi.InjectionPoint; +import org.elasticsearch.common.inject.spi.InstanceBinding; +import org.elasticsearch.common.inject.spi.LinkedKeyBinding; +import org.elasticsearch.common.inject.spi.PrivateElements; +import org.elasticsearch.common.inject.spi.ProviderBinding; +import org.elasticsearch.common.inject.spi.ProviderInstanceBinding; +import org.elasticsearch.common.inject.spi.ProviderKeyBinding; +import org.elasticsearch.common.inject.spi.UntargettedBinding; +import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -32,9 +55,9 @@ import java.util.Set; */ class BindingProcessor extends AbstractProcessor { - private final List creationListeners = Lists.newArrayList(); + private final List creationListeners = new ArrayList<>(); private final Initializer initializer; - private final List uninitializedBindings = Lists.newArrayList(); + private final List uninitializedBindings = new ArrayList<>(); BindingProcessor(Errors errors, Initializer initializer) { super(errors); diff --git a/core/src/main/java/org/elasticsearch/common/inject/DeferredLookups.java b/core/src/main/java/org/elasticsearch/common/inject/DeferredLookups.java index 1631d69bb81..c6ca9bab08a 100644 --- a/core/src/main/java/org/elasticsearch/common/inject/DeferredLookups.java +++ b/core/src/main/java/org/elasticsearch/common/inject/DeferredLookups.java @@ -16,12 +16,12 @@ package org.elasticsearch.common.inject; -import com.google.common.collect.Lists; import org.elasticsearch.common.inject.internal.Errors; import org.elasticsearch.common.inject.spi.Element; import org.elasticsearch.common.inject.spi.MembersInjectorLookup; import org.elasticsearch.common.inject.spi.ProviderLookup; +import java.util.ArrayList; import java.util.List; /** @@ -32,7 +32,7 @@ import java.util.List; */ class DeferredLookups implements Lookups { private final InjectorImpl injector; - private final List lookups = Lists.newArrayList(); + private final List lookups = new ArrayList<>(); public DeferredLookups(InjectorImpl injector) { this.injector = injector; diff --git a/core/src/main/java/org/elasticsearch/common/inject/EncounterImpl.java b/core/src/main/java/org/elasticsearch/common/inject/EncounterImpl.java index 4a06a48c9cf..2a3c419cc36 100644 --- a/core/src/main/java/org/elasticsearch/common/inject/EncounterImpl.java +++ b/core/src/main/java/org/elasticsearch/common/inject/EncounterImpl.java @@ -17,12 +17,12 @@ package org.elasticsearch.common.inject; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; import org.elasticsearch.common.inject.internal.Errors; import org.elasticsearch.common.inject.spi.InjectionListener; import org.elasticsearch.common.inject.spi.Message; import org.elasticsearch.common.inject.spi.TypeEncounter; +import java.util.ArrayList; import java.util.List; import static com.google.common.base.Preconditions.checkState; @@ -64,7 +64,7 @@ final class EncounterImpl implements TypeEncounter { checkState(valid, "Encounters may not be used after hear() returns."); if (membersInjectors == null) { - membersInjectors = Lists.newArrayList(); + membersInjectors = new ArrayList<>(); } membersInjectors.add(membersInjector); @@ -75,7 +75,7 @@ final class EncounterImpl implements TypeEncounter { checkState(valid, "Encounters may not be used after hear() returns."); if (injectionListeners == null) { - injectionListeners = Lists.newArrayList(); + injectionListeners = new ArrayList<>(); } injectionListeners.add(injectionListener); diff --git a/core/src/main/java/org/elasticsearch/common/inject/InheritingState.java b/core/src/main/java/org/elasticsearch/common/inject/InheritingState.java index fb14444fa9a..38b8494d3ef 100644 --- a/core/src/main/java/org/elasticsearch/common/inject/InheritingState.java +++ b/core/src/main/java/org/elasticsearch/common/inject/InheritingState.java @@ -17,9 +17,13 @@ package org.elasticsearch.common.inject; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import org.elasticsearch.common.inject.internal.*; +import org.elasticsearch.common.inject.internal.BindingImpl; +import org.elasticsearch.common.inject.internal.Errors; +import org.elasticsearch.common.inject.internal.InstanceBindingImpl; +import org.elasticsearch.common.inject.internal.InternalFactory; +import org.elasticsearch.common.inject.internal.MatcherAndConverter; +import org.elasticsearch.common.inject.internal.SourceProvider; import org.elasticsearch.common.inject.spi.InjectionPoint; import org.elasticsearch.common.inject.spi.TypeListenerBinding; @@ -43,8 +47,8 @@ class InheritingState implements State { private final Map, Binding> explicitBindings = Collections.unmodifiableMap(explicitBindingsMutable); private final Map, Scope> scopes = Maps.newHashMap(); - private final List converters = Lists.newArrayList(); - private final List listenerBindings = Lists.newArrayList(); + private final List converters = new ArrayList<>(); + private final List listenerBindings = new ArrayList<>(); private WeakKeySet blacklistedKeys = new WeakKeySet(); private final Object lock; diff --git a/core/src/main/java/org/elasticsearch/common/inject/Initializer.java b/core/src/main/java/org/elasticsearch/common/inject/Initializer.java index 038f9b6a997..6ee855bb673 100644 --- a/core/src/main/java/org/elasticsearch/common/inject/Initializer.java +++ b/core/src/main/java/org/elasticsearch/common/inject/Initializer.java @@ -16,12 +16,12 @@ package org.elasticsearch.common.inject; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import org.elasticsearch.common.inject.internal.Errors; import org.elasticsearch.common.inject.internal.ErrorsException; import org.elasticsearch.common.inject.spi.InjectionPoint; +import java.util.ArrayList; import java.util.Map; import java.util.Set; import java.util.concurrent.CountDownLatch; @@ -95,7 +95,7 @@ class Initializer { void injectAll(final Errors errors) { // loop over a defensive copy since ensureInjected() mutates the set. Unfortunately, that copy // is made complicated by a bug in IBM's JDK, wherein entrySet().toArray(Object[]) doesn't work - for (InjectableReference reference : Lists.newArrayList(pendingInjection.values())) { + for (InjectableReference reference : new ArrayList<>(pendingInjection.values())) { try { reference.get(errors); } catch (ErrorsException e) { diff --git a/core/src/main/java/org/elasticsearch/common/inject/InjectionRequestProcessor.java b/core/src/main/java/org/elasticsearch/common/inject/InjectionRequestProcessor.java index 35e69d33195..b645f41c3b8 100644 --- a/core/src/main/java/org/elasticsearch/common/inject/InjectionRequestProcessor.java +++ b/core/src/main/java/org/elasticsearch/common/inject/InjectionRequestProcessor.java @@ -17,7 +17,6 @@ package org.elasticsearch.common.inject; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; import org.elasticsearch.common.inject.internal.Errors; import org.elasticsearch.common.inject.internal.ErrorsException; import org.elasticsearch.common.inject.internal.InternalContext; @@ -25,6 +24,7 @@ import org.elasticsearch.common.inject.spi.InjectionPoint; import org.elasticsearch.common.inject.spi.InjectionRequest; import org.elasticsearch.common.inject.spi.StaticInjectionRequest; +import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -37,7 +37,7 @@ import java.util.Set; */ class InjectionRequestProcessor extends AbstractProcessor { - private final List staticInjections = Lists.newArrayList(); + private final List staticInjections = new ArrayList<>(); private final Initializer initializer; InjectionRequestProcessor(Errors errors, Initializer initializer) { diff --git a/core/src/main/java/org/elasticsearch/common/inject/InjectorImpl.java b/core/src/main/java/org/elasticsearch/common/inject/InjectorImpl.java index 6f2540c97be..a8048513055 100644 --- a/core/src/main/java/org/elasticsearch/common/inject/InjectorImpl.java +++ b/core/src/main/java/org/elasticsearch/common/inject/InjectorImpl.java @@ -18,15 +18,37 @@ package org.elasticsearch.common.inject; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import org.elasticsearch.common.Classes; -import org.elasticsearch.common.inject.internal.*; -import org.elasticsearch.common.inject.spi.*; +import org.elasticsearch.common.inject.internal.Annotations; +import org.elasticsearch.common.inject.internal.BindingImpl; +import org.elasticsearch.common.inject.internal.Errors; +import org.elasticsearch.common.inject.internal.ErrorsException; +import org.elasticsearch.common.inject.internal.InstanceBindingImpl; +import org.elasticsearch.common.inject.internal.InternalContext; +import org.elasticsearch.common.inject.internal.InternalFactory; +import org.elasticsearch.common.inject.internal.LinkedBindingImpl; +import org.elasticsearch.common.inject.internal.LinkedProviderBindingImpl; +import org.elasticsearch.common.inject.internal.MatcherAndConverter; +import org.elasticsearch.common.inject.internal.Nullable; +import org.elasticsearch.common.inject.internal.Scoping; +import org.elasticsearch.common.inject.internal.SourceProvider; +import org.elasticsearch.common.inject.internal.ToStringBuilder; +import org.elasticsearch.common.inject.spi.BindingTargetVisitor; +import org.elasticsearch.common.inject.spi.ConvertedConstantBinding; +import org.elasticsearch.common.inject.spi.Dependency; +import org.elasticsearch.common.inject.spi.InjectionPoint; +import org.elasticsearch.common.inject.spi.ProviderBinding; +import org.elasticsearch.common.inject.spi.ProviderKeyBinding; import org.elasticsearch.common.inject.util.Providers; import java.lang.annotation.Annotation; -import java.lang.reflect.*; +import java.lang.reflect.GenericArrayType; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Modifier; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; @@ -681,7 +703,7 @@ class InjectorImpl implements Injector, Lookups { void put(TypeLiteral type, Binding binding) { List> bindingsForType = multimap.get(type); if (bindingsForType == null) { - bindingsForType = Lists.newArrayList(); + bindingsForType = new ArrayList<>(); multimap.put(type, bindingsForType); } bindingsForType.add(binding); diff --git a/core/src/main/java/org/elasticsearch/common/inject/InjectorShell.java b/core/src/main/java/org/elasticsearch/common/inject/InjectorShell.java index f463a24b751..5ac7934fc74 100644 --- a/core/src/main/java/org/elasticsearch/common/inject/InjectorShell.java +++ b/core/src/main/java/org/elasticsearch/common/inject/InjectorShell.java @@ -17,10 +17,23 @@ package org.elasticsearch.common.inject; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; -import org.elasticsearch.common.inject.internal.*; -import org.elasticsearch.common.inject.spi.*; +import org.elasticsearch.common.inject.internal.Errors; +import org.elasticsearch.common.inject.internal.ErrorsException; +import org.elasticsearch.common.inject.internal.InternalContext; +import org.elasticsearch.common.inject.internal.InternalFactory; +import org.elasticsearch.common.inject.internal.PrivateElementsImpl; +import org.elasticsearch.common.inject.internal.ProviderInstanceBindingImpl; +import org.elasticsearch.common.inject.internal.Scoping; +import org.elasticsearch.common.inject.internal.SourceProvider; +import org.elasticsearch.common.inject.internal.Stopwatch; +import org.elasticsearch.common.inject.spi.Dependency; +import org.elasticsearch.common.inject.spi.Element; +import org.elasticsearch.common.inject.spi.Elements; +import org.elasticsearch.common.inject.spi.InjectionPoint; +import org.elasticsearch.common.inject.spi.PrivateElements; +import org.elasticsearch.common.inject.spi.TypeListenerBinding; +import java.util.ArrayList; import java.util.List; import java.util.logging.Logger; @@ -59,8 +72,8 @@ class InjectorShell { } static class Builder { - private final List elements = Lists.newArrayList(); - private final List modules = Lists.newArrayList(); + private final List elements = new ArrayList<>(); + private final List modules = new ArrayList<>(); /** * lazily constructed @@ -148,7 +161,7 @@ class InjectorShell { bindingProcessor.process(injector, elements); stopwatch.resetAndLog("Binding creation"); - List injectorShells = Lists.newArrayList(); + List injectorShells = new ArrayList<>(); injectorShells.add(new InjectorShell(this, elements, injector)); // recursively build child shells diff --git a/core/src/main/java/org/elasticsearch/common/inject/MembersInjectorStore.java b/core/src/main/java/org/elasticsearch/common/inject/MembersInjectorStore.java index 99d0924576d..cd7c168860a 100644 --- a/core/src/main/java/org/elasticsearch/common/inject/MembersInjectorStore.java +++ b/core/src/main/java/org/elasticsearch/common/inject/MembersInjectorStore.java @@ -17,7 +17,6 @@ package org.elasticsearch.common.inject; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; import org.elasticsearch.common.inject.internal.Errors; import org.elasticsearch.common.inject.internal.ErrorsException; import org.elasticsearch.common.inject.internal.FailableCache; @@ -25,6 +24,7 @@ import org.elasticsearch.common.inject.spi.InjectionPoint; import org.elasticsearch.common.inject.spi.TypeListenerBinding; import java.lang.reflect.Field; +import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -106,7 +106,7 @@ class MembersInjectorStore { */ ImmutableList getInjectors( Set injectionPoints, Errors errors) { - List injectors = Lists.newArrayList(); + List injectors = new ArrayList<>(); for (InjectionPoint injectionPoint : injectionPoints) { try { Errors errorsForMember = injectionPoint.isOptional() diff --git a/core/src/main/java/org/elasticsearch/common/inject/ModulesBuilder.java b/core/src/main/java/org/elasticsearch/common/inject/ModulesBuilder.java index c65a07dcfbc..41cdecfbcad 100644 --- a/core/src/main/java/org/elasticsearch/common/inject/ModulesBuilder.java +++ b/core/src/main/java/org/elasticsearch/common/inject/ModulesBuilder.java @@ -19,8 +19,7 @@ package org.elasticsearch.common.inject; -import com.google.common.collect.Lists; - +import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -29,7 +28,7 @@ import java.util.List; */ public class ModulesBuilder implements Iterable { - private final List modules = Lists.newArrayList(); + private final List modules = new ArrayList<>(); public ModulesBuilder add(Module... newModules) { for (Module module : newModules) { diff --git a/core/src/main/java/org/elasticsearch/common/inject/PrivateElementProcessor.java b/core/src/main/java/org/elasticsearch/common/inject/PrivateElementProcessor.java index 9b0fd3d7e07..2b7dc692996 100644 --- a/core/src/main/java/org/elasticsearch/common/inject/PrivateElementProcessor.java +++ b/core/src/main/java/org/elasticsearch/common/inject/PrivateElementProcessor.java @@ -16,10 +16,10 @@ package org.elasticsearch.common.inject; -import com.google.common.collect.Lists; import org.elasticsearch.common.inject.internal.Errors; import org.elasticsearch.common.inject.spi.PrivateElements; +import java.util.ArrayList; import java.util.List; /** @@ -30,7 +30,7 @@ import java.util.List; class PrivateElementProcessor extends AbstractProcessor { private final Stage stage; - private final List injectorShellBuilders = Lists.newArrayList(); + private final List injectorShellBuilders = new ArrayList<>(); PrivateElementProcessor(Errors errors, Stage stage) { super(errors); diff --git a/core/src/main/java/org/elasticsearch/common/inject/assistedinject/AssistedConstructor.java b/core/src/main/java/org/elasticsearch/common/inject/assistedinject/AssistedConstructor.java index 173abae910e..3973d9eb7e8 100644 --- a/core/src/main/java/org/elasticsearch/common/inject/assistedinject/AssistedConstructor.java +++ b/core/src/main/java/org/elasticsearch/common/inject/assistedinject/AssistedConstructor.java @@ -16,7 +16,6 @@ package org.elasticsearch.common.inject.assistedinject; -import com.google.common.collect.Lists; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.TypeLiteral; @@ -24,7 +23,11 @@ import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Type; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; /** * Internal respresentation of a constructor annotated with @@ -45,7 +48,7 @@ class AssistedConstructor { Annotation[][] annotations = constructor.getParameterAnnotations(); - List typeList = Lists.newArrayList(); + List typeList = new ArrayList<>(); allParameters = new ArrayList<>(); // categorize params as @Assisted or @Injected diff --git a/core/src/main/java/org/elasticsearch/common/inject/assistedinject/FactoryProvider.java b/core/src/main/java/org/elasticsearch/common/inject/assistedinject/FactoryProvider.java index e36fabb9000..cee76821edb 100644 --- a/core/src/main/java/org/elasticsearch/common/inject/assistedinject/FactoryProvider.java +++ b/core/src/main/java/org/elasticsearch/common/inject/assistedinject/FactoryProvider.java @@ -18,16 +18,25 @@ package org.elasticsearch.common.inject.assistedinject; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import org.elasticsearch.common.inject.*; +import org.elasticsearch.common.inject.ConfigurationException; +import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.inject.Injector; +import org.elasticsearch.common.inject.Key; +import org.elasticsearch.common.inject.Provider; +import org.elasticsearch.common.inject.TypeLiteral; import org.elasticsearch.common.inject.internal.Errors; import org.elasticsearch.common.inject.spi.Dependency; import org.elasticsearch.common.inject.spi.HasDependencies; import org.elasticsearch.common.inject.spi.Message; import java.lang.annotation.Annotation; -import java.lang.reflect.*; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.lang.reflect.Type; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; @@ -209,7 +218,7 @@ public class FactoryProvider implements Provider, HasDependencies { private static Map> createMethodMapping( TypeLiteral factoryType, TypeLiteral implementationType) { - List> constructors = Lists.newArrayList(); + List> constructors = new ArrayList<>(); for (Constructor constructor : implementationType.getRawType().getDeclaredConstructors()) { if (constructor.getAnnotation(AssistedInject.class) != null) { @@ -248,7 +257,7 @@ public class FactoryProvider implements Provider, HasDependencies { method, implementationType); } - List parameterTypes = Lists.newArrayList(); + List parameterTypes = new ArrayList<>(); for (TypeLiteral parameterType : factoryType.getParameterTypes(method)) { parameterTypes.add(parameterType.getType()); } @@ -281,7 +290,7 @@ public class FactoryProvider implements Provider, HasDependencies { @Override public Set> getDependencies() { - List> dependencies = Lists.newArrayList(); + List> dependencies = new ArrayList<>(); for (AssistedConstructor constructor : factoryMethodToConstructor.values()) { for (Parameter parameter : constructor.getAllParameters()) { if (!parameter.isProvidedByFactory()) { diff --git a/core/src/main/java/org/elasticsearch/common/inject/assistedinject/FactoryProvider2.java b/core/src/main/java/org/elasticsearch/common/inject/assistedinject/FactoryProvider2.java index 2bfbcefe6b7..03b194816ea 100644 --- a/core/src/main/java/org/elasticsearch/common/inject/assistedinject/FactoryProvider2.java +++ b/core/src/main/java/org/elasticsearch/common/inject/assistedinject/FactoryProvider2.java @@ -19,8 +19,17 @@ package org.elasticsearch.common.inject.assistedinject; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import org.elasticsearch.common.inject.*; +import org.elasticsearch.common.inject.AbstractModule; +import org.elasticsearch.common.inject.Binder; +import org.elasticsearch.common.inject.Binding; +import org.elasticsearch.common.inject.ConfigurationException; +import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.inject.Injector; +import org.elasticsearch.common.inject.Key; +import org.elasticsearch.common.inject.Module; +import org.elasticsearch.common.inject.Provider; +import org.elasticsearch.common.inject.ProvisionException; +import org.elasticsearch.common.inject.TypeLiteral; import org.elasticsearch.common.inject.internal.Errors; import org.elasticsearch.common.inject.internal.ErrorsException; import org.elasticsearch.common.inject.spi.Message; @@ -30,6 +39,7 @@ import java.lang.annotation.Annotation; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -118,7 +128,7 @@ final class FactoryProvider2 implements InvocationHandler, Provider { List> params = factoryType.getParameterTypes(method); Annotation[][] paramAnnotations = method.getParameterAnnotations(); int p = 0; - List> keys = Lists.newArrayList(); + List> keys = new ArrayList<>(); for (TypeLiteral param : params) { Key paramKey = getKey(param, method, paramAnnotations[p++], errors); keys.add(assistKey(method, paramKey, errors)); diff --git a/core/src/main/java/org/elasticsearch/common/inject/internal/Errors.java b/core/src/main/java/org/elasticsearch/common/inject/internal/Errors.java index e898007231c..d3a73b3c326 100644 --- a/core/src/main/java/org/elasticsearch/common/inject/internal/Errors.java +++ b/core/src/main/java/org/elasticsearch/common/inject/internal/Errors.java @@ -18,10 +18,20 @@ package org.elasticsearch.common.inject.internal; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; import org.apache.lucene.util.CollectionUtil; -import org.elasticsearch.common.inject.*; -import org.elasticsearch.common.inject.spi.*; +import org.elasticsearch.common.inject.ConfigurationException; +import org.elasticsearch.common.inject.CreationException; +import org.elasticsearch.common.inject.Key; +import org.elasticsearch.common.inject.MembersInjector; +import org.elasticsearch.common.inject.Provider; +import org.elasticsearch.common.inject.ProvisionException; +import org.elasticsearch.common.inject.Scope; +import org.elasticsearch.common.inject.TypeLiteral; +import org.elasticsearch.common.inject.spi.Dependency; +import org.elasticsearch.common.inject.spi.InjectionListener; +import org.elasticsearch.common.inject.spi.InjectionPoint; +import org.elasticsearch.common.inject.spi.Message; +import org.elasticsearch.common.inject.spi.TypeListenerBinding; import java.io.PrintWriter; import java.io.Serializable; @@ -31,7 +41,12 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Member; import java.lang.reflect.Type; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Comparator; +import java.util.Formatter; +import java.util.List; +import java.util.Locale; /** * A collection of error messages. If this type is passed as a method parameter, the method is @@ -361,7 +376,7 @@ public final class Errors implements Serializable { } private Message merge(Message message) { - List sources = Lists.newArrayList(); + List sources = new ArrayList<>(); sources.addAll(getSources()); sources.addAll(message.getSources()); return new Message(sources, message.getMessage(), message.getCause()); @@ -384,7 +399,7 @@ public final class Errors implements Serializable { } public List getSources() { - List sources = Lists.newArrayList(); + List sources = new ArrayList<>(); for (Errors e = this; e != null; e = e.parent) { if (e.source != SourceProvider.UNKNOWN_SOURCE) { sources.add(0, e.source); @@ -421,7 +436,7 @@ public final class Errors implements Serializable { public Errors addMessage(Message message) { if (root.errors == null) { - root.errors = Lists.newArrayList(); + root.errors = new ArrayList<>(); } root.errors.add(message); return this; @@ -439,7 +454,7 @@ public final class Errors implements Serializable { return ImmutableList.of(); } - List result = Lists.newArrayList(root.errors); + List result = new ArrayList<>(root.errors); CollectionUtil.timSort(result, new Comparator() { @Override public int compare(Message a, Message b) { diff --git a/core/src/main/java/org/elasticsearch/common/inject/internal/Join.java b/core/src/main/java/org/elasticsearch/common/inject/internal/Join.java index fd8348d8f34..65005992438 100644 --- a/core/src/main/java/org/elasticsearch/common/inject/internal/Join.java +++ b/core/src/main/java/org/elasticsearch/common/inject/internal/Join.java @@ -16,7 +16,7 @@ package org.elasticsearch.common.inject.internal; -import com.google.common.collect.Lists; +import org.elasticsearch.common.util.CollectionUtils; import java.io.IOException; import java.util.Arrays; @@ -98,7 +98,7 @@ public final class Join { public static String join( String delimiter, @Nullable Object firstToken, Object... otherTokens) { checkNotNull(otherTokens); - return join(delimiter, Lists.newArrayList(firstToken, otherTokens)); + return join(delimiter, CollectionUtils.asArrayList(firstToken, otherTokens)); } /** @@ -208,7 +208,7 @@ public final class Join { public static T join(T appendable, String delimiter, @Nullable Object firstToken, Object... otherTokens) { checkNotNull(otherTokens); - return join(appendable, delimiter, Lists.newArrayList(firstToken, otherTokens)); + return join(appendable, delimiter, CollectionUtils.asArrayList(firstToken, otherTokens)); } /** diff --git a/core/src/main/java/org/elasticsearch/common/inject/internal/PrivateElementsImpl.java b/core/src/main/java/org/elasticsearch/common/inject/internal/PrivateElementsImpl.java index 0e6a33f199f..59b5aaa0e7d 100644 --- a/core/src/main/java/org/elasticsearch/common/inject/internal/PrivateElementsImpl.java +++ b/core/src/main/java/org/elasticsearch/common/inject/internal/PrivateElementsImpl.java @@ -18,7 +18,6 @@ package org.elasticsearch.common.inject.internal; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import org.elasticsearch.common.inject.Binder; import org.elasticsearch.common.inject.Injector; @@ -28,6 +27,7 @@ import org.elasticsearch.common.inject.spi.Element; import org.elasticsearch.common.inject.spi.ElementVisitor; import org.elasticsearch.common.inject.spi.PrivateElements; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; @@ -47,8 +47,8 @@ public final class PrivateElementsImpl implements PrivateElements { private final Object source; - private List elementsMutable = Lists.newArrayList(); - private List> exposureBuilders = Lists.newArrayList(); + private List elementsMutable = new ArrayList<>(); + private List> exposureBuilders = new ArrayList<>(); /** * lazily instantiated diff --git a/core/src/main/java/org/elasticsearch/common/inject/internal/ProviderMethodsModule.java b/core/src/main/java/org/elasticsearch/common/inject/internal/ProviderMethodsModule.java index 46705306c01..9884b88f43a 100644 --- a/core/src/main/java/org/elasticsearch/common/inject/internal/ProviderMethodsModule.java +++ b/core/src/main/java/org/elasticsearch/common/inject/internal/ProviderMethodsModule.java @@ -17,8 +17,12 @@ package org.elasticsearch.common.inject.internal; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; -import org.elasticsearch.common.inject.*; +import org.elasticsearch.common.inject.Binder; +import org.elasticsearch.common.inject.Key; +import org.elasticsearch.common.inject.Module; +import org.elasticsearch.common.inject.Provider; +import org.elasticsearch.common.inject.Provides; +import org.elasticsearch.common.inject.TypeLiteral; import org.elasticsearch.common.inject.spi.Dependency; import org.elasticsearch.common.inject.spi.Message; import org.elasticsearch.common.inject.util.Modules; @@ -26,6 +30,7 @@ import org.elasticsearch.common.inject.util.Modules; import java.lang.annotation.Annotation; import java.lang.reflect.Member; import java.lang.reflect.Method; +import java.util.ArrayList; import java.util.List; import static com.google.common.base.Preconditions.checkNotNull; @@ -74,7 +79,7 @@ public final class ProviderMethodsModule implements Module { } public List> getProviderMethods(Binder binder) { - List> result = Lists.newArrayList(); + List> result = new ArrayList<>(); for (Class c = delegate.getClass(); c != Object.class; c = c.getSuperclass()) { for (Method method : c.getDeclaredMethods()) { if (method.getAnnotation(Provides.class) != null) { @@ -90,8 +95,8 @@ public final class ProviderMethodsModule implements Module { Errors errors = new Errors(method); // prepare the parameter providers - List> dependencies = Lists.newArrayList(); - List> parameterProviders = Lists.newArrayList(); + List> dependencies = new ArrayList<>(); + List> parameterProviders = new ArrayList<>(); List> parameterTypes = typeLiteral.getParameterTypes(method); Annotation[][] parameterAnnotations = method.getParameterAnnotations(); for (int i = 0; i < parameterTypes.size(); i++) { diff --git a/core/src/main/java/org/elasticsearch/common/inject/internal/SourceProvider.java b/core/src/main/java/org/elasticsearch/common/inject/internal/SourceProvider.java index 4c34be0d415..f0fa05c66dd 100644 --- a/core/src/main/java/org/elasticsearch/common/inject/internal/SourceProvider.java +++ b/core/src/main/java/org/elasticsearch/common/inject/internal/SourceProvider.java @@ -18,8 +18,8 @@ package org.elasticsearch.common.inject.internal; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; +import java.util.ArrayList; import java.util.List; /** @@ -58,7 +58,7 @@ public class SourceProvider { * Returns the class names as Strings */ private static List asStrings(Class... classes) { - List strings = Lists.newArrayList(); + List strings = new ArrayList<>(); for (Class c : classes) { strings.add(c.getName()); } diff --git a/core/src/main/java/org/elasticsearch/common/inject/multibindings/Multibinder.java b/core/src/main/java/org/elasticsearch/common/inject/multibindings/Multibinder.java index fac73d3ef57..0fb64a4e6d1 100644 --- a/core/src/main/java/org/elasticsearch/common/inject/multibindings/Multibinder.java +++ b/core/src/main/java/org/elasticsearch/common/inject/multibindings/Multibinder.java @@ -18,8 +18,15 @@ package org.elasticsearch.common.inject.multibindings; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; -import org.elasticsearch.common.inject.*; +import org.elasticsearch.common.inject.Binder; +import org.elasticsearch.common.inject.Binding; +import org.elasticsearch.common.inject.ConfigurationException; +import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.inject.Injector; +import org.elasticsearch.common.inject.Key; +import org.elasticsearch.common.inject.Module; +import org.elasticsearch.common.inject.Provider; +import org.elasticsearch.common.inject.TypeLiteral; import org.elasticsearch.common.inject.binder.LinkedBindingBuilder; import org.elasticsearch.common.inject.internal.Errors; import org.elasticsearch.common.inject.spi.Dependency; @@ -29,6 +36,7 @@ import org.elasticsearch.common.inject.util.Types; import java.lang.annotation.Annotation; import java.lang.reflect.Type; +import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashSet; import java.util.List; @@ -229,8 +237,8 @@ public abstract class Multibinder { */ @Inject void initialize(Injector injector) { - providers = Lists.newArrayList(); - List> dependencies = Lists.newArrayList(); + providers = new ArrayList<>(); + List> dependencies = new ArrayList<>(); for (Binding entry : injector.findBindingsByType(elementType)) { if (keyMatches(entry.getKey())) { diff --git a/core/src/main/java/org/elasticsearch/common/inject/spi/Dependency.java b/core/src/main/java/org/elasticsearch/common/inject/spi/Dependency.java index f0891f5b456..8f1ce52b116 100644 --- a/core/src/main/java/org/elasticsearch/common/inject/spi/Dependency.java +++ b/core/src/main/java/org/elasticsearch/common/inject/spi/Dependency.java @@ -18,9 +18,9 @@ package org.elasticsearch.common.inject.spi; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; import org.elasticsearch.common.inject.Key; +import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -60,7 +60,7 @@ public final class Dependency { * Returns the dependencies from the given injection points. */ public static Set> forInjectionPoints(Set injectionPoints) { - List> dependencies = Lists.newArrayList(); + List> dependencies = new ArrayList<>(); for (InjectionPoint injectionPoint : injectionPoints) { dependencies.addAll(injectionPoint.getDependencies()); } diff --git a/core/src/main/java/org/elasticsearch/common/inject/spi/Elements.java b/core/src/main/java/org/elasticsearch/common/inject/spi/Elements.java index c6dc1e4ef4b..965223604b5 100644 --- a/core/src/main/java/org/elasticsearch/common/inject/spi/Elements.java +++ b/core/src/main/java/org/elasticsearch/common/inject/spi/Elements.java @@ -17,19 +17,41 @@ package org.elasticsearch.common.inject.spi; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; import com.google.common.collect.Sets; -import org.elasticsearch.common.inject.*; +import org.elasticsearch.common.inject.AbstractModule; +import org.elasticsearch.common.inject.Binder; +import org.elasticsearch.common.inject.Binding; +import org.elasticsearch.common.inject.Key; +import org.elasticsearch.common.inject.MembersInjector; +import org.elasticsearch.common.inject.Module; +import org.elasticsearch.common.inject.PrivateBinder; +import org.elasticsearch.common.inject.PrivateModule; +import org.elasticsearch.common.inject.Provider; +import org.elasticsearch.common.inject.Scope; +import org.elasticsearch.common.inject.Stage; +import org.elasticsearch.common.inject.TypeLiteral; import org.elasticsearch.common.inject.binder.AnnotatedBindingBuilder; import org.elasticsearch.common.inject.binder.AnnotatedConstantBindingBuilder; import org.elasticsearch.common.inject.binder.AnnotatedElementBuilder; -import org.elasticsearch.common.inject.internal.*; +import org.elasticsearch.common.inject.internal.AbstractBindingBuilder; +import org.elasticsearch.common.inject.internal.BindingBuilder; +import org.elasticsearch.common.inject.internal.ConstantBindingBuilderImpl; +import org.elasticsearch.common.inject.internal.Errors; +import org.elasticsearch.common.inject.internal.ExposureBuilder; +import org.elasticsearch.common.inject.internal.PrivateElementsImpl; +import org.elasticsearch.common.inject.internal.ProviderMethodsModule; +import org.elasticsearch.common.inject.internal.SourceProvider; import org.elasticsearch.common.inject.matcher.Matcher; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import java.lang.annotation.Annotation; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Set; import static com.google.common.base.Preconditions.checkArgument; @@ -121,7 +143,7 @@ public final class Elements { private RecordingBinder(Stage stage) { this.stage = stage; this.modules = Sets.newHashSet(); - this.elements = Lists.newArrayList(); + this.elements = new ArrayList<>(); this.source = null; this.sourceProvider = new SourceProvider().plusSkippedClasses( Elements.class, RecordingBinder.class, AbstractModule.class, diff --git a/core/src/main/java/org/elasticsearch/common/inject/spi/InjectionPoint.java b/core/src/main/java/org/elasticsearch/common/inject/spi/InjectionPoint.java index 8aef647f994..aa7e0793838 100644 --- a/core/src/main/java/org/elasticsearch/common/inject/spi/InjectionPoint.java +++ b/core/src/main/java/org/elasticsearch/common/inject/spi/InjectionPoint.java @@ -18,16 +18,29 @@ package org.elasticsearch.common.inject.spi; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; import org.elasticsearch.common.inject.ConfigurationException; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Key; import org.elasticsearch.common.inject.TypeLiteral; -import org.elasticsearch.common.inject.internal.*; +import org.elasticsearch.common.inject.internal.Annotations; +import org.elasticsearch.common.inject.internal.Errors; +import org.elasticsearch.common.inject.internal.ErrorsException; +import org.elasticsearch.common.inject.internal.MoreTypes; +import org.elasticsearch.common.inject.internal.Nullability; import java.lang.annotation.Annotation; -import java.lang.reflect.*; -import java.util.*; +import java.lang.reflect.AnnotatedElement; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Member; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Set; import static org.elasticsearch.common.inject.internal.MoreTypes.getRawType; @@ -93,7 +106,7 @@ public final class InjectionPoint { Errors errors = new Errors(member); Iterator annotationsIterator = Arrays.asList(parameterAnnotations).iterator(); - List> dependencies = Lists.newArrayList(); + List> dependencies = new ArrayList<>(); int index = 0; for (TypeLiteral parameterType : type.getParameterTypes(member)) { @@ -240,7 +253,7 @@ public final class InjectionPoint { * of the valid injection points. */ public static Set forStaticMethodsAndFields(TypeLiteral type) { - List sink = Lists.newArrayList(); + List sink = new ArrayList<>(); Errors errors = new Errors(); addInjectionPoints(type, Factory.FIELDS, true, sink, errors); @@ -280,7 +293,7 @@ public final class InjectionPoint { * of the valid injection points. */ public static Set forInstanceMethodsAndFields(TypeLiteral type) { - List sink = Lists.newArrayList(); + List sink = new ArrayList<>(); Errors errors = new Errors(); // TODO (crazybob): Filter out overridden members. diff --git a/core/src/main/java/org/elasticsearch/common/inject/util/Modules.java b/core/src/main/java/org/elasticsearch/common/inject/util/Modules.java index ae2205836bc..2849cc45b40 100644 --- a/core/src/main/java/org/elasticsearch/common/inject/util/Modules.java +++ b/core/src/main/java/org/elasticsearch/common/inject/util/Modules.java @@ -17,13 +17,24 @@ package org.elasticsearch.common.inject.util; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; -import org.elasticsearch.common.inject.*; -import org.elasticsearch.common.inject.spi.*; +import org.elasticsearch.common.inject.AbstractModule; +import org.elasticsearch.common.inject.Binder; +import org.elasticsearch.common.inject.Binding; +import org.elasticsearch.common.inject.Key; +import org.elasticsearch.common.inject.Module; +import org.elasticsearch.common.inject.PrivateBinder; +import org.elasticsearch.common.inject.Scope; +import org.elasticsearch.common.inject.spi.DefaultBindingScopingVisitor; +import org.elasticsearch.common.inject.spi.DefaultElementVisitor; +import org.elasticsearch.common.inject.spi.Element; +import org.elasticsearch.common.inject.spi.Elements; +import org.elasticsearch.common.inject.spi.PrivateElements; +import org.elasticsearch.common.inject.spi.ScopeBinding; import java.lang.annotation.Annotation; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -168,7 +179,7 @@ public final class Modules { // overridden binding once so things still blow up if the module binds the same thing // multiple times. final Map scopeInstancesInUse = Maps.newHashMap(); - final List scopeBindings = Lists.newArrayList(); + final List scopeBindings = new ArrayList<>(); new ModuleWriter(binder()) { @Override public Void visit(Binding binding) { diff --git a/core/src/main/java/org/elasticsearch/common/io/Streams.java b/core/src/main/java/org/elasticsearch/common/io/Streams.java index 166e7960b3c..e6265ab01ed 100644 --- a/core/src/main/java/org/elasticsearch/common/io/Streams.java +++ b/core/src/main/java/org/elasticsearch/common/io/Streams.java @@ -21,10 +21,17 @@ package org.elasticsearch.common.io; import com.google.common.base.Charsets; import com.google.common.base.Preconditions; -import com.google.common.collect.Lists; import org.elasticsearch.common.util.Callback; -import java.io.*; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.Reader; +import java.io.StringWriter; +import java.io.Writer; +import java.util.ArrayList; import java.util.List; /** @@ -216,7 +223,7 @@ public abstract class Streams { } public static List readAllLines(InputStream input) throws IOException { - final List lines = Lists.newArrayList(); + final List lines = new ArrayList<>(); readAllLines(input, new Callback() { @Override public void handle(String line) { diff --git a/core/src/main/java/org/elasticsearch/common/logging/Loggers.java b/core/src/main/java/org/elasticsearch/common/logging/Loggers.java index 93d4cc3d111..1dafcff62d3 100644 --- a/core/src/main/java/org/elasticsearch/common/logging/Loggers.java +++ b/core/src/main/java/org/elasticsearch/common/logging/Loggers.java @@ -19,7 +19,6 @@ package org.elasticsearch.common.logging; -import com.google.common.collect.Lists; import org.apache.lucene.util.SuppressForbidden; import org.elasticsearch.common.Classes; import org.elasticsearch.common.settings.Settings; @@ -28,10 +27,11 @@ import org.elasticsearch.index.shard.ShardId; import java.net.InetAddress; import java.net.UnknownHostException; +import java.util.ArrayList; import java.util.List; -import static com.google.common.collect.Lists.newArrayList; import static java.util.Arrays.asList; +import static org.elasticsearch.common.util.CollectionUtils.asArrayList; /** * A set of utilities around Logging. @@ -59,16 +59,16 @@ public class Loggers { } public static ESLogger getLogger(Class clazz, Settings settings, ShardId shardId, String... prefixes) { - return getLogger(clazz, settings, shardId.index(), Lists.asList(Integer.toString(shardId.id()), prefixes).toArray(new String[0])); + return getLogger(clazz, settings, shardId.index(), asArrayList(Integer.toString(shardId.id()), prefixes).toArray(new String[0])); } /** Just like {@link #getLogger(Class, org.elasticsearch.common.settings.Settings,ShardId,String...)} but String loggerName instead of Class. */ public static ESLogger getLogger(String loggerName, Settings settings, ShardId shardId, String... prefixes) { - return getLogger(loggerName, settings, Lists.asList(shardId.index().name(), Integer.toString(shardId.id()), prefixes).toArray(new String[0])); + return getLogger(loggerName, settings, asArrayList(shardId.index().name(), Integer.toString(shardId.id()), prefixes).toArray(new String[0])); } public static ESLogger getLogger(Class clazz, Settings settings, Index index, String... prefixes) { - return getLogger(clazz, settings, Lists.asList(SPACE, index.name(), prefixes).toArray(new String[0])); + return getLogger(clazz, settings, asArrayList(SPACE, index.name(), prefixes).toArray(new String[0])); } public static ESLogger getLogger(Class clazz, Settings settings, String... prefixes) { @@ -86,7 +86,7 @@ public class Loggers { @SuppressForbidden(reason = "do not know what this method does") public static ESLogger getLogger(String loggerName, Settings settings, String... prefixes) { - List prefixesList = newArrayList(); + List prefixesList = new ArrayList<>(); if (settings.getAsBoolean("logger.logHostAddress", false)) { final InetAddress addr = getHostAddress(); if (addr != null) { diff --git a/core/src/main/java/org/elasticsearch/common/lucene/all/AllEntries.java b/core/src/main/java/org/elasticsearch/common/lucene/all/AllEntries.java index fb6ebc28e1c..5106cdaf979 100644 --- a/core/src/main/java/org/elasticsearch/common/lucene/all/AllEntries.java +++ b/core/src/main/java/org/elasticsearch/common/lucene/all/AllEntries.java @@ -19,12 +19,12 @@ package org.elasticsearch.common.lucene.all; -import com.google.common.collect.Lists; import org.elasticsearch.common.io.FastCharArrayWriter; import org.elasticsearch.common.io.FastStringReader; import java.io.IOException; import java.io.Reader; +import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Set; @@ -66,7 +66,7 @@ public class AllEntries extends Reader { } } - private final List entries = Lists.newArrayList(); + private final List entries = new ArrayList<>(); private Entry current; diff --git a/core/src/main/java/org/elasticsearch/common/lucene/index/FilterableTermsEnum.java b/core/src/main/java/org/elasticsearch/common/lucene/index/FilterableTermsEnum.java index 52b102ed5b3..8e8c47c4614 100644 --- a/core/src/main/java/org/elasticsearch/common/lucene/index/FilterableTermsEnum.java +++ b/core/src/main/java/org/elasticsearch/common/lucene/index/FilterableTermsEnum.java @@ -19,8 +19,6 @@ package org.elasticsearch.common.lucene.index; -import com.google.common.collect.Lists; - import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.PostingsEnum; @@ -37,6 +35,7 @@ import org.apache.lucene.util.BytesRef; import org.elasticsearch.common.Nullable; import java.io.IOException; +import java.util.ArrayList; import java.util.List; /** @@ -79,7 +78,7 @@ public class FilterableTermsEnum extends TermsEnum { numDocs = reader.maxDoc(); } List leaves = reader.leaves(); - List enums = Lists.newArrayListWithExpectedSize(leaves.size()); + List enums = new ArrayList<>(leaves.size()); final Weight weight; if (filter == null) { weight = null; diff --git a/core/src/main/java/org/elasticsearch/common/settings/Settings.java b/core/src/main/java/org/elasticsearch/common/settings/Settings.java index 13383d68468..096432dd789 100644 --- a/core/src/main/java/org/elasticsearch/common/settings/Settings.java +++ b/core/src/main/java/org/elasticsearch/common/settings/Settings.java @@ -24,7 +24,6 @@ import com.google.common.base.Predicate; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import org.elasticsearch.Version; import org.elasticsearch.common.Booleans; @@ -35,17 +34,31 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.property.PropertyPlaceholder; import org.elasticsearch.common.settings.loader.SettingsLoader; import org.elasticsearch.common.settings.loader.SettingsLoaderFactory; -import org.elasticsearch.common.unit.*; +import org.elasticsearch.common.unit.ByteSizeUnit; +import org.elasticsearch.common.unit.ByteSizeValue; +import org.elasticsearch.common.unit.MemorySizeValue; +import org.elasticsearch.common.unit.RatioValue; +import org.elasticsearch.common.unit.SizeValue; +import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.net.URL; import java.nio.file.Files; import java.nio.file.Path; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -180,7 +193,7 @@ public final class Settings implements ToXContent { } } if (isArray && (maxIndex + 1) == map.size()) { - ArrayList newValue = Lists.newArrayListWithExpectedSize(maxIndex + 1); + ArrayList newValue = new ArrayList<>(maxIndex + 1); for (int i = 0; i <= maxIndex; i++) { Object obj = map.get(Integer.toString(i)); if (obj == null) { @@ -558,7 +571,7 @@ public final class Settings implements ToXContent { * @throws org.elasticsearch.common.settings.SettingsException */ public String[] getAsArray(String settingPrefix, String[] defaultArray, Boolean commaDelimited) throws SettingsException { - List result = Lists.newArrayList(); + List result = new ArrayList<>(); if (get(settingPrefix) != null) { if (commaDelimited) { diff --git a/core/src/main/java/org/elasticsearch/common/settings/SettingsFilter.java b/core/src/main/java/org/elasticsearch/common/settings/SettingsFilter.java index 56739c0f19f..d2bde251330 100644 --- a/core/src/main/java/org/elasticsearch/common/settings/SettingsFilter.java +++ b/core/src/main/java/org/elasticsearch/common/settings/SettingsFilter.java @@ -25,14 +25,13 @@ import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.xcontent.ToXContent.Params; import org.elasticsearch.rest.RestRequest; +import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.CopyOnWriteArrayList; -import static com.google.common.collect.Lists.newArrayList; - /** * */ @@ -89,7 +88,7 @@ public class SettingsFilter extends AbstractComponent { public static Settings filterSettings(String patterns, Settings settings) { String[] patternArray = Strings.delimitedListToStringArray(patterns, ","); Settings.Builder builder = Settings.settingsBuilder().put(settings); - List simpleMatchPatternList = newArrayList(); + List simpleMatchPatternList = new ArrayList<>(); for (String pattern : patternArray) { if (Regex.isSimpleMatchPattern(pattern)) { simpleMatchPatternList.add(pattern); diff --git a/core/src/main/java/org/elasticsearch/common/settings/loader/SettingsLoader.java b/core/src/main/java/org/elasticsearch/common/settings/loader/SettingsLoader.java index 86e905e9f52..3760f3f87d5 100644 --- a/core/src/main/java/org/elasticsearch/common/settings/loader/SettingsLoader.java +++ b/core/src/main/java/org/elasticsearch/common/settings/loader/SettingsLoader.java @@ -22,10 +22,10 @@ package org.elasticsearch.common.settings.loader; import org.elasticsearch.common.Nullable; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Map; -import static com.google.common.collect.Lists.newArrayList; import static com.google.common.collect.Maps.newHashMap; /** @@ -42,7 +42,7 @@ public interface SettingsLoader { return settings; } StringBuilder sb = new StringBuilder(); - List path = newArrayList(); + List path = new ArrayList<>(); serializeMap(settings, sb, path, map); return settings; } diff --git a/core/src/main/java/org/elasticsearch/common/settings/loader/XContentSettingsLoader.java b/core/src/main/java/org/elasticsearch/common/settings/loader/XContentSettingsLoader.java index 23c5d447582..945e8298138 100644 --- a/core/src/main/java/org/elasticsearch/common/settings/loader/XContentSettingsLoader.java +++ b/core/src/main/java/org/elasticsearch/common/settings/loader/XContentSettingsLoader.java @@ -25,10 +25,10 @@ import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentType; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Map; -import static com.google.common.collect.Lists.newArrayList; import static com.google.common.collect.Maps.newHashMap; /** @@ -56,7 +56,7 @@ public abstract class XContentSettingsLoader implements SettingsLoader { public Map load(XContentParser jp) throws IOException { StringBuilder sb = new StringBuilder(); Map settings = newHashMap(); - List path = newArrayList(); + List path = new ArrayList<>(); XContentParser.Token token = jp.nextToken(); if (token == null) { return settings; diff --git a/core/src/main/java/org/elasticsearch/common/util/CollectionUtils.java b/core/src/main/java/org/elasticsearch/common/util/CollectionUtils.java index 48150c704f7..17d78dc56b1 100644 --- a/core/src/main/java/org/elasticsearch/common/util/CollectionUtils.java +++ b/core/src/main/java/org/elasticsearch/common/util/CollectionUtils.java @@ -23,14 +23,25 @@ import com.carrotsearch.hppc.DoubleArrayList; import com.carrotsearch.hppc.FloatArrayList; import com.carrotsearch.hppc.LongArrayList; import com.carrotsearch.hppc.ObjectArrayList; +import com.google.common.base.Function; import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterators; -import com.google.common.collect.Lists; -import org.apache.lucene.util.*; -import org.elasticsearch.common.inject.Module; +import org.apache.lucene.util.BytesRef; +import org.apache.lucene.util.BytesRefArray; +import org.apache.lucene.util.BytesRefBuilder; +import org.apache.lucene.util.InPlaceMergeSorter; +import org.apache.lucene.util.IntroSorter; -import java.util.*; +import java.util.AbstractList; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.RandomAccess; /** Collections-related utility methods. */ public enum CollectionUtils { @@ -368,8 +379,102 @@ public enum CollectionUtils { return Iterators.concat(iterators); } - public static ArrayList newArrayList(E... elements) { - return Lists.newArrayList(elements); + public static ArrayList iterableAsArrayList(Iterable elements) { + if (elements == null) { + throw new NullPointerException("elements"); + } + if (elements instanceof Collection) { + return new ArrayList<>((Collection)elements); + } else { + ArrayList list = new ArrayList<>(); + for (E element : elements) { + list.add(element); + } + return list; + } } + public static List eagerTransform(List list, Function transform) { + if (list == null) { + throw new NullPointerException("list"); + } + if (transform == null) { + throw new NullPointerException("transform"); + } + List result = new ArrayList<>(list.size()); + for (E element : list) { + result.add(transform.apply(element)); + } + return result; + } + + public static ArrayList arrayAsArrayList(E... elements) { + if (elements == null) { + throw new NullPointerException("elements"); + } + return new ArrayList<>(Arrays.asList(elements)); + } + + public static ArrayList asArrayList(E first, E... other) { + if (other == null) { + throw new NullPointerException("other"); + } + ArrayList list = new ArrayList<>(1 + other.length); + list.add(first); + list.addAll(Arrays.asList(other)); + return list; + } + + public static ArrayList asArrayList(E first, E second, E... other) { + if (other == null) { + throw new NullPointerException("other"); + } + ArrayList list = new ArrayList<>(1 + 1 + other.length); + list.add(first); + list.add(second); + list.addAll(Arrays.asList(other)); + return list; + } + + public static ArrayList newSingletonArrayList(E element) { + return new ArrayList<>(Collections.singletonList(element)); + } + + public static LinkedList newLinkedList(Iterable elements) { + if (elements == null) { + throw new NullPointerException("elements"); + } + LinkedList linkedList = new LinkedList<>(); + for (E element : elements) { + linkedList.add(element); + } + return linkedList; + } + + public static List> eagerPartition(List list, int size) { + if (list == null) { + throw new NullPointerException("list"); + } + if (size <= 0) { + throw new IllegalArgumentException("size <= 0"); + } + List> result = new ArrayList<>((int) Math.ceil(list.size() / size)); + + List accumulator = new ArrayList<>(size); + int count = 0; + for (E element : list) { + if (count == size) { + result.add(accumulator); + accumulator = new ArrayList<>(size); + count = 0; + } + accumulator.add(element); + count++; + } + if (count > 0) { + result.add(accumulator); + } + + return result; + } } diff --git a/core/src/main/java/org/elasticsearch/common/util/concurrent/PrioritizedEsThreadPoolExecutor.java b/core/src/main/java/org/elasticsearch/common/util/concurrent/PrioritizedEsThreadPoolExecutor.java index 38c0cb23234..aad6cee12fe 100644 --- a/core/src/main/java/org/elasticsearch/common/util/concurrent/PrioritizedEsThreadPoolExecutor.java +++ b/core/src/main/java/org/elasticsearch/common/util/concurrent/PrioritizedEsThreadPoolExecutor.java @@ -18,14 +18,20 @@ */ package org.elasticsearch.common.util.concurrent; -import com.google.common.collect.Lists; - import org.elasticsearch.common.Priority; import org.elasticsearch.common.unit.TimeValue; +import java.util.ArrayList; import java.util.List; import java.util.Queue; -import java.util.concurrent.*; +import java.util.concurrent.Callable; +import java.util.concurrent.FutureTask; +import java.util.concurrent.PriorityBlockingQueue; +import java.util.concurrent.RunnableFuture; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; /** @@ -46,9 +52,9 @@ public class PrioritizedEsThreadPoolExecutor extends EsThreadPoolExecutor { } public Pending[] getPending() { - List pending = Lists.newArrayList(); - addPending(Lists.newArrayList(current), pending, true); - addPending(Lists.newArrayList(getQueue()), pending, false); + List pending = new ArrayList<>(); + addPending(new ArrayList<>(current), pending, true); + addPending(new ArrayList<>(getQueue()), pending, false); return pending.toArray(new Pending[pending.size()]); } diff --git a/core/src/main/java/org/elasticsearch/common/xcontent/support/XContentMapValues.java b/core/src/main/java/org/elasticsearch/common/xcontent/support/XContentMapValues.java index 1067d597334..fc10ab4b92a 100644 --- a/core/src/main/java/org/elasticsearch/common/xcontent/support/XContentMapValues.java +++ b/core/src/main/java/org/elasticsearch/common/xcontent/support/XContentMapValues.java @@ -19,7 +19,6 @@ package org.elasticsearch.common.xcontent.support; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.common.Strings; @@ -40,7 +39,7 @@ public class XContentMapValues { * as a single list. */ public static List extractRawValues(String path, Map map) { - List values = Lists.newArrayList(); + List values = new ArrayList<>(); String[] pathElements = Strings.splitStringToArray(path, '.'); if (pathElements.length == 0) { return values; diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java b/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java index d1b790672ee..2780cefa062 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java @@ -20,11 +20,17 @@ package org.elasticsearch.discovery.zen; import com.google.common.base.Objects; -import com.google.common.collect.Lists; import com.google.common.collect.Sets; import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.Version; -import org.elasticsearch.cluster.*; +import org.elasticsearch.cluster.ClusterChangedEvent; +import org.elasticsearch.cluster.ClusterName; +import org.elasticsearch.cluster.ClusterService; +import org.elasticsearch.cluster.ClusterState; +import org.elasticsearch.cluster.ClusterStateNonMasterUpdateTask; +import org.elasticsearch.cluster.ClusterStateUpdateTask; +import org.elasticsearch.cluster.ProcessedClusterStateNonMasterUpdateTask; +import org.elasticsearch.cluster.ProcessedClusterStateUpdateTask; import org.elasticsearch.cluster.block.ClusterBlocks; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.MetaData; @@ -33,9 +39,6 @@ import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.routing.RoutingService; import org.elasticsearch.cluster.routing.allocation.RoutingAllocation; import org.elasticsearch.cluster.service.InternalClusterService; -import org.elasticsearch.cluster.settings.ClusterDynamicSettings; -import org.elasticsearch.cluster.settings.DynamicSettings; -import org.elasticsearch.cluster.settings.Validator; import org.elasticsearch.common.Priority; import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.component.Lifecycle; @@ -61,7 +64,13 @@ import org.elasticsearch.discovery.zen.publish.PublishClusterStateAction; import org.elasticsearch.node.service.NodeService; import org.elasticsearch.node.settings.NodeSettingsService; import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.*; +import org.elasticsearch.transport.EmptyTransportResponseHandler; +import org.elasticsearch.transport.TransportChannel; +import org.elasticsearch.transport.TransportException; +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.ArrayList; @@ -75,7 +84,6 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; -import static com.google.common.collect.Lists.newArrayList; import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; /** @@ -903,7 +911,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen } // filter responses - List pingResponses = Lists.newArrayList(); + List pingResponses = new ArrayList<>(); for (ZenPing.PingResponse pingResponse : fullPingResponses) { DiscoveryNode node = pingResponse.node(); if (masterElectionFilterClientNodes && (node.clientNode() || (!node.masterNode() && !node.dataNode()))) { @@ -928,7 +936,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen } final DiscoveryNode localNode = clusterService.localNode(); - List pingMasters = newArrayList(); + List pingMasters = new ArrayList<>(); for (ZenPing.PingResponse pingResponse : pingResponses) { if (pingResponse.master() != null) { // We can't include the local node in pingMasters list, otherwise we may up electing ourselves without diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/elect/ElectMasterService.java b/core/src/main/java/org/elasticsearch/discovery/zen/elect/ElectMasterService.java index ce65861df61..80b3ec0f4e6 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/elect/ElectMasterService.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/elect/ElectMasterService.java @@ -20,7 +20,6 @@ package org.elasticsearch.discovery.zen.elect; import com.carrotsearch.hppc.ObjectContainer; -import com.google.common.collect.Lists; import org.apache.lucene.util.CollectionUtil; import org.elasticsearch.Version; import org.elasticsearch.cluster.ClusterState; @@ -29,8 +28,13 @@ import org.elasticsearch.cluster.settings.Validator; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.util.CollectionUtils; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.Iterator; +import java.util.List; /** * @@ -98,7 +102,7 @@ public class ElectMasterService extends AbstractComponent { * @return */ public List sortByMasterLikelihood(Iterable nodes) { - ArrayList sortedNodes = Lists.newArrayList(nodes); + ArrayList sortedNodes = CollectionUtils.iterableAsArrayList(nodes); CollectionUtil.introSort(sortedNodes, nodeComparator); return sortedNodes; } @@ -111,7 +115,7 @@ public class ElectMasterService extends AbstractComponent { if (sortedNodes == null) { return new DiscoveryNode[0]; } - List nextPossibleMasters = Lists.newArrayListWithCapacity(numberOfPossibleMasters); + List nextPossibleMasters = new ArrayList<>(numberOfPossibleMasters); int counter = 0; for (DiscoveryNode nextPossibleMaster : sortedNodes) { if (++counter >= numberOfPossibleMasters) { @@ -142,7 +146,7 @@ public class ElectMasterService extends AbstractComponent { } private List sortedMasterNodes(Iterable nodes) { - List possibleNodes = Lists.newArrayList(nodes); + List possibleNodes = CollectionUtils.iterableAsArrayList(nodes); if (possibleNodes.isEmpty()) { return null; } diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java b/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java index 06820a9f066..741f877a55c 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java @@ -20,7 +20,6 @@ package org.elasticsearch.discovery.zen.ping.unicast; import com.carrotsearch.hppc.cursors.ObjectCursor; -import com.google.common.collect.Lists; import org.apache.lucene.util.IOUtils; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.Version; @@ -35,6 +34,7 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.common.unit.TimeValue; +import org.elasticsearch.common.util.CollectionUtils; import org.elasticsearch.common.util.concurrent.AbstractRunnable; import org.elasticsearch.common.util.concurrent.ConcurrentCollections; import org.elasticsearch.common.util.concurrent.EsExecutors; @@ -43,17 +43,36 @@ import org.elasticsearch.discovery.zen.elect.ElectMasterService; import org.elasticsearch.discovery.zen.ping.PingContextProvider; import org.elasticsearch.discovery.zen.ping.ZenPing; import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.*; +import org.elasticsearch.transport.BaseTransportResponseHandler; +import org.elasticsearch.transport.ConnectTransportException; +import org.elasticsearch.transport.RemoteTransportException; +import org.elasticsearch.transport.TransportChannel; +import org.elasticsearch.transport.TransportException; +import org.elasticsearch.transport.TransportRequest; +import org.elasticsearch.transport.TransportRequestHandler; +import org.elasticsearch.transport.TransportRequestOptions; +import org.elasticsearch.transport.TransportResponse; +import org.elasticsearch.transport.TransportService; import java.io.Closeable; import java.io.IOException; -import java.util.*; -import java.util.concurrent.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Queue; +import java.util.Set; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.RejectedExecutionException; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; -import static com.google.common.collect.Lists.newArrayList; import static org.elasticsearch.common.unit.TimeValue.readTimeValue; import static org.elasticsearch.common.util.concurrent.ConcurrentCollections.newConcurrentMap; import static org.elasticsearch.discovery.zen.ping.ZenPing.PingResponse.readPingResponse; @@ -122,7 +141,7 @@ public class UnicastZenPing extends AbstractLifecycleComponent implemen for (int i = 0; i < hostArr.length; i++) { hostArr[i] = hostArr[i].trim(); } - List hosts = Lists.newArrayList(hostArr); + List hosts = CollectionUtils.arrayAsArrayList(hostArr); final int limitPortCounts; if (hosts.isEmpty()) { // if unicast hosts are not specified, fill with simple defaults on the local machine @@ -135,7 +154,7 @@ public class UnicastZenPing extends AbstractLifecycleComponent implemen logger.debug("using initial hosts {}, with concurrent_connects [{}]", hosts, concurrentConnects); - List configuredTargetNodes = Lists.newArrayList(); + List configuredTargetNodes = new ArrayList<>(); for (String host : hosts) { try { TransportAddress[] addresses = transportService.addressesFromString(host, limitPortCounts); @@ -325,7 +344,7 @@ public class UnicastZenPing extends AbstractLifecycleComponent implemen List sortedNodesToPing = electMasterService.sortByMasterLikelihood(nodesToPingSet); // new add the the unicast targets first - ArrayList nodesToPing = Lists.newArrayList(configuredTargetNodes); + List nodesToPing = CollectionUtils.arrayAsArrayList(configuredTargetNodes); nodesToPing.addAll(sortedNodesToPing); final CountDownLatch latch = new CountDownLatch(nodesToPing.size()); @@ -485,7 +504,7 @@ public class UnicastZenPing extends AbstractLifecycleComponent implemen } }); - List pingResponses = newArrayList(temporalResponses); + List pingResponses = CollectionUtils.iterableAsArrayList(temporalResponses); pingResponses.add(createPingResponse(contextProvider.nodes())); diff --git a/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java b/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java index b927cbbde84..43398c55917 100644 --- a/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java +++ b/core/src/main/java/org/elasticsearch/gateway/GatewayMetaState.java @@ -41,9 +41,11 @@ import org.elasticsearch.env.NodeEnvironment; import java.nio.file.DirectoryStream; import java.nio.file.Files; import java.nio.file.Path; -import java.util.*; - -import static com.google.common.collect.Lists.newArrayList; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; /** * @@ -221,7 +223,7 @@ public class GatewayMetaState extends AbstractComponent implements ClusterStateL */ private void pre20Upgrade() throws Exception { MetaData metaData = loadMetaState(); - List updateIndexMetaData = newArrayList(); + List updateIndexMetaData = new ArrayList<>(); for (IndexMetaData indexMetaData : metaData) { IndexMetaData newMetaData = metaDataIndexUpgradeService.upgradeIndexMetaData(indexMetaData); if (indexMetaData != newMetaData) { diff --git a/core/src/main/java/org/elasticsearch/gateway/PrimaryShardAllocator.java b/core/src/main/java/org/elasticsearch/gateway/PrimaryShardAllocator.java index b4bf6367f13..695de267894 100644 --- a/core/src/main/java/org/elasticsearch/gateway/PrimaryShardAllocator.java +++ b/core/src/main/java/org/elasticsearch/gateway/PrimaryShardAllocator.java @@ -19,7 +19,6 @@ package org.elasticsearch.gateway; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import org.apache.lucene.util.CollectionUtil; import org.elasticsearch.cluster.metadata.IndexMetaData; @@ -34,7 +33,12 @@ import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.settings.IndexSettings; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.Set; /** * The primary shard allocator allocates primary shard that were not created as @@ -234,7 +238,7 @@ public abstract class PrimaryShardAllocator extends AbstractComponent { // Now that we have a map of nodes to versions along with the // number of allocations found (and not ignored), we need to sort // it so the node with the highest version is at the beginning - List nodesWithHighestVersion = Lists.newArrayList(); + List nodesWithHighestVersion = new ArrayList<>(); nodesWithHighestVersion.addAll(nodesWithVersion.keySet()); CollectionUtil.timSort(nodesWithHighestVersion, new Comparator() { @Override diff --git a/core/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayMetaState.java b/core/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayMetaState.java index a9362a56fe9..accccc4616c 100644 --- a/core/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayMetaState.java +++ b/core/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayMetaState.java @@ -19,12 +19,15 @@ package org.elasticsearch.gateway; -import com.google.common.collect.Lists; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.action.support.ActionFilters; -import org.elasticsearch.action.support.nodes.*; +import org.elasticsearch.action.support.nodes.BaseNodeRequest; +import org.elasticsearch.action.support.nodes.BaseNodeResponse; +import org.elasticsearch.action.support.nodes.BaseNodesRequest; +import org.elasticsearch.action.support.nodes.BaseNodesResponse; +import org.elasticsearch.action.support.nodes.TransportNodesAction; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; @@ -40,6 +43,7 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicReferenceArray; @@ -86,8 +90,8 @@ public class TransportNodesListGatewayMetaState extends TransportNodesAction nodesList = Lists.newArrayList(); - final List failures = Lists.newArrayList(); + final List nodesList = new ArrayList<>(); + final List failures = new ArrayList<>(); for (int i = 0; i < responses.length(); i++) { Object resp = responses.get(i); if (resp instanceof NodeGatewayMetaState) { // will also filter out null response for unallocated ones diff --git a/core/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayStartedShards.java b/core/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayStartedShards.java index f431fcdfeb7..11cbbef9eba 100644 --- a/core/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayStartedShards.java +++ b/core/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayStartedShards.java @@ -19,13 +19,15 @@ package org.elasticsearch.gateway; -import com.google.common.collect.Lists; import org.elasticsearch.ElasticsearchException; -import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.action.support.ActionFilters; -import org.elasticsearch.action.support.nodes.*; +import org.elasticsearch.action.support.nodes.BaseNodeRequest; +import org.elasticsearch.action.support.nodes.BaseNodeResponse; +import org.elasticsearch.action.support.nodes.BaseNodesRequest; +import org.elasticsearch.action.support.nodes.BaseNodesResponse; +import org.elasticsearch.action.support.nodes.TransportNodesAction; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.ClusterState; @@ -45,6 +47,7 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicReferenceArray; @@ -97,8 +100,8 @@ public class TransportNodesListGatewayStartedShards extends TransportNodesAction @Override protected NodesGatewayStartedShards newResponse(Request request, AtomicReferenceArray responses) { - final List nodesList = Lists.newArrayList(); - final List failures = Lists.newArrayList(); + final List nodesList = new ArrayList<>(); + final List failures = new ArrayList<>(); for (int i = 0; i < responses.length(); i++) { Object resp = responses.get(i); if (resp instanceof NodeGatewayStartedShards) { // will also filter out null response for unallocated ones diff --git a/core/src/main/java/org/elasticsearch/index/analysis/AnalysisModule.java b/core/src/main/java/org/elasticsearch/index/analysis/AnalysisModule.java index 38f846a57f4..21667cf6128 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/AnalysisModule.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/AnalysisModule.java @@ -19,15 +19,12 @@ package org.elasticsearch.index.analysis; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.Scopes; import org.elasticsearch.common.inject.assistedinject.FactoryProvider; import org.elasticsearch.common.inject.multibindings.MapBinder; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.settings.NoClassSettingsException; import org.elasticsearch.index.analysis.compound.DictionaryCompoundWordTokenFilterFactory; import org.elasticsearch.index.analysis.compound.HyphenationCompoundWordTokenFilterFactory; import org.elasticsearch.indices.analysis.IndicesAnalysisService; @@ -108,7 +105,7 @@ public class AnalysisModule extends AbstractModule { private final IndicesAnalysisService indicesAnalysisService; - private final LinkedList processors = Lists.newLinkedList(); + private final LinkedList processors = new LinkedList<>(); private final Map> charFilters = Maps.newHashMap(); private final Map> tokenFilters = Maps.newHashMap(); diff --git a/core/src/main/java/org/elasticsearch/index/analysis/CustomAnalyzerProvider.java b/core/src/main/java/org/elasticsearch/index/analysis/CustomAnalyzerProvider.java index 1c54e2cef8c..43f0008d61c 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/CustomAnalyzerProvider.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/CustomAnalyzerProvider.java @@ -27,10 +27,9 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.mapper.core.StringFieldMapper; import org.elasticsearch.index.settings.IndexSettings; +import java.util.ArrayList; import java.util.List; -import static com.google.common.collect.Lists.newArrayList; - /** * A custom analyzer that is built out of a single {@link org.apache.lucene.analysis.Tokenizer} and a list * of {@link org.apache.lucene.analysis.TokenFilter}s. @@ -59,7 +58,7 @@ public class CustomAnalyzerProvider extends AbstractIndexAnalyzerProvider charFilters = newArrayList(); + List charFilters = new ArrayList<>(); String[] charFilterNames = analyzerSettings.getAsArray("char_filter"); for (String charFilterName : charFilterNames) { CharFilterFactory charFilter = analysisService.charFilter(charFilterName); @@ -69,7 +68,7 @@ public class CustomAnalyzerProvider extends AbstractIndexAnalyzerProvider tokenFilters = newArrayList(); + List tokenFilters = new ArrayList<>(); String[] tokenFilterNames = analyzerSettings.getAsArray("filter"); for (String tokenFilterName : tokenFilterNames) { TokenFilterFactory tokenFilter = analysisService.tokenFilter(tokenFilterName); diff --git a/core/src/main/java/org/elasticsearch/index/engine/InternalEngine.java b/core/src/main/java/org/elasticsearch/index/engine/InternalEngine.java index 597cf9b8a05..5bd733c48f1 100644 --- a/core/src/main/java/org/elasticsearch/index/engine/InternalEngine.java +++ b/core/src/main/java/org/elasticsearch/index/engine/InternalEngine.java @@ -19,11 +19,25 @@ package org.elasticsearch.index.engine; -import com.google.common.collect.Lists; -import org.apache.lucene.index.*; +import org.apache.lucene.index.DirectoryReader; +import org.apache.lucene.index.IndexReader; +import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriter.IndexReaderWarmer; +import org.apache.lucene.index.IndexWriterConfig; +import org.apache.lucene.index.LeafReader; +import org.apache.lucene.index.LeafReaderContext; +import org.apache.lucene.index.LiveIndexWriterConfig; +import org.apache.lucene.index.MergePolicy; +import org.apache.lucene.index.MultiReader; +import org.apache.lucene.index.SegmentCommitInfo; +import org.apache.lucene.index.SegmentInfos; +import org.apache.lucene.index.Term; import org.apache.lucene.search.BooleanClause.Occur; -import org.apache.lucene.search.*; +import org.apache.lucene.search.BooleanQuery; +import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.Query; +import org.apache.lucene.search.SearcherFactory; +import org.apache.lucene.search.SearcherManager; import org.apache.lucene.store.AlreadyClosedException; import org.apache.lucene.store.Directory; import org.apache.lucene.store.LockObtainFailedException; @@ -49,8 +63,11 @@ import org.elasticsearch.index.indexing.ShardIndexingService; import org.elasticsearch.index.mapper.Uid; import org.elasticsearch.index.merge.MergeStats; import org.elasticsearch.index.merge.OnGoingMerge; -import org.elasticsearch.index.shard.*; import org.elasticsearch.index.search.nested.IncludeNestedDocsQuery; +import org.elasticsearch.index.shard.ElasticsearchMergePolicy; +import org.elasticsearch.index.shard.MergeSchedulerConfig; +import org.elasticsearch.index.shard.ShardId; +import org.elasticsearch.index.shard.TranslogRecoveryPerformer; import org.elasticsearch.index.translog.Translog; import org.elasticsearch.index.translog.TranslogConfig; import org.elasticsearch.index.translog.TranslogCorruptedException; @@ -59,7 +76,12 @@ import org.elasticsearch.rest.RestStatus; import org.elasticsearch.threadpool.ThreadPool; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.Lock; @@ -1085,7 +1107,7 @@ public class InternalEngine extends Engine { newSearcher = searcher; } else { // figure out the newSearcher, with only the new readers that are relevant for us - List readers = Lists.newArrayList(); + List readers = new ArrayList<>(); for (LeafReaderContext newReaderContext : reader.leaves()) { if (isMergedSegment(newReaderContext.reader())) { // merged segments are already handled by IndexWriterConfig.setMergedSegmentWarmer diff --git a/core/src/main/java/org/elasticsearch/index/get/GetResult.java b/core/src/main/java/org/elasticsearch/index/get/GetResult.java index 996de8cf1bf..7bee6e4b824 100644 --- a/core/src/main/java/org/elasticsearch/index/get/GetResult.java +++ b/core/src/main/java/org/elasticsearch/index/get/GetResult.java @@ -20,7 +20,6 @@ package org.elasticsearch.index.get; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Lists; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.compress.CompressorFactory; @@ -34,6 +33,7 @@ import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.search.lookup.SourceLookup; import java.io.IOException; +import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -208,8 +208,8 @@ public class GetResult implements Streamable, Iterable, ToXContent { } public XContentBuilder toXContentEmbedded(XContentBuilder builder, Params params) throws IOException { - List metaFields = Lists.newArrayList(); - List otherFields = Lists.newArrayList(); + List metaFields = new ArrayList<>(); + List otherFields = new ArrayList<>(); if (fields != null && !fields.isEmpty()) { for (GetField field : fields.values()) { if (field.getValues().isEmpty()) { diff --git a/core/src/main/java/org/elasticsearch/index/mapper/ParseContext.java b/core/src/main/java/org/elasticsearch/index/mapper/ParseContext.java index 5c07e8a9192..edf75621c1e 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/ParseContext.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/ParseContext.java @@ -19,10 +19,8 @@ package org.elasticsearch.index.mapper; -import com.carrotsearch.hppc.ObjectObjectMap; import com.carrotsearch.hppc.ObjectObjectHashMap; -import com.google.common.collect.Lists; - +import com.carrotsearch.hppc.ObjectObjectMap; import org.apache.lucene.document.Field; import org.apache.lucene.index.IndexOptions; import org.apache.lucene.index.IndexableField; @@ -56,7 +54,7 @@ public abstract class ParseContext { private ObjectObjectMap keyedFields; private Document(String path, Document parent) { - fields = Lists.newArrayList(); + fields = new ArrayList<>(); this.path = path; this.prefix = path.isEmpty() ? "" : path + "."; this.parent = parent; @@ -378,7 +376,7 @@ public abstract class ParseContext { private Document document; - private List documents = Lists.newArrayList(); + private List documents = new ArrayList<>(); @Nullable private final Settings indexSettings; @@ -411,7 +409,7 @@ public abstract class ParseContext { this.parser = parser; this.document = document; if (document != null) { - this.documents = Lists.newArrayList(); + this.documents = new ArrayList<>(); this.documents.add(document); } else { this.documents = null; diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/CompletionFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/core/CompletionFieldMapper.java index 6297c6a2a78..dab41b4a78a 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/core/CompletionFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/core/CompletionFieldMapper.java @@ -18,7 +18,6 @@ */ package org.elasticsearch.index.mapper.core; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import org.apache.lucene.analysis.Analyzer; @@ -53,6 +52,7 @@ import org.elasticsearch.search.suggest.context.ContextMapping; import org.elasticsearch.search.suggest.context.ContextMapping.ContextConfig; import java.io.IOException; +import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Locale; @@ -334,7 +334,7 @@ public class CompletionFieldMapper extends FieldMapper { String surfaceForm = null; BytesRef payload = null; long weight = -1; - List inputs = Lists.newArrayListWithExpectedSize(4); + List inputs = new ArrayList<>(4); SortedMap contextConfig = null; diff --git a/core/src/main/java/org/elasticsearch/index/mapper/object/ObjectMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/object/ObjectMapper.java index 70c3276a56f..3ff0611fca0 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/object/ObjectMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/object/ObjectMapper.java @@ -58,7 +58,6 @@ import java.util.List; import java.util.Locale; import java.util.Map; -import static com.google.common.collect.Lists.newArrayList; import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeBooleanValue; import static org.elasticsearch.index.mapper.MapperBuilders.object; import static org.elasticsearch.index.mapper.core.TypeParsers.parsePathType; @@ -129,7 +128,7 @@ public class ObjectMapper extends Mapper implements AllFieldMapper.IncludeInAll, protected Boolean includeInAll; - protected final List mappersBuilders = newArrayList(); + protected final List mappersBuilders = new ArrayList<>(); public Builder(String name) { super(name); diff --git a/core/src/main/java/org/elasticsearch/index/mapper/object/RootObjectMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/object/RootObjectMapper.java index 2ba2ada1570..cb0815aaee1 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/object/RootObjectMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/object/RootObjectMapper.java @@ -19,9 +19,7 @@ package org.elasticsearch.index.mapper.object; -import com.google.common.collect.Lists; import com.google.common.collect.Sets; - import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Strings; import org.elasticsearch.common.joda.FormatDateTimeFormatter; @@ -29,14 +27,22 @@ import org.elasticsearch.common.joda.Joda; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.index.mapper.*; +import org.elasticsearch.index.mapper.ContentPath; +import org.elasticsearch.index.mapper.Mapper; +import org.elasticsearch.index.mapper.MapperParsingException; +import org.elasticsearch.index.mapper.MergeResult; +import org.elasticsearch.index.mapper.ParseContext; import org.elasticsearch.index.mapper.core.DateFieldMapper; import org.elasticsearch.index.settings.IndexSettings; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; -import static com.google.common.collect.Lists.newArrayList; import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeBooleanValue; import static org.elasticsearch.index.mapper.core.TypeParsers.parseDateTimeFormatter; @@ -57,11 +63,11 @@ public class RootObjectMapper extends ObjectMapper { public static class Builder extends ObjectMapper.Builder { - protected final List dynamicTemplates = newArrayList(); + protected final List dynamicTemplates = new ArrayList<>(); // we use this to filter out seen date formats, because we might get duplicates during merging protected Set seenDateFormats = Sets.newHashSet(); - protected List dynamicDateTimeFormatters = newArrayList(); + protected List dynamicDateTimeFormatters = new ArrayList<>(); protected boolean dateDetection = Defaults.DATE_DETECTION; protected boolean numericDetection = Defaults.NUMERIC_DETECTION; @@ -144,7 +150,7 @@ public class RootObjectMapper extends ObjectMapper { protected boolean processField(ObjectMapper.Builder builder, String fieldName, Object fieldNode) { if (fieldName.equals("date_formats") || fieldName.equals("dynamic_date_formats")) { - List dateTimeFormatters = newArrayList(); + List dateTimeFormatters = new ArrayList<>(); if (fieldNode instanceof List) { for (Object node1 : (List) fieldNode) { if (node1.toString().startsWith("epoch_")) { @@ -262,7 +268,7 @@ public class RootObjectMapper extends ObjectMapper { RootObjectMapper mergeWithObject = (RootObjectMapper) mergeWith; if (!mergeResult.simulate()) { // merge them - List mergedTemplates = Lists.newArrayList(Arrays.asList(this.dynamicTemplates)); + List mergedTemplates = new ArrayList<>(Arrays.asList(this.dynamicTemplates)); for (DynamicTemplate template : mergeWithObject.dynamicTemplates) { boolean replaced = false; for (int i = 0; i < mergedTemplates.size(); i++) { diff --git a/core/src/main/java/org/elasticsearch/index/query/AndQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/AndQueryBuilder.java index e0ecafca285..1d556635103 100644 --- a/core/src/main/java/org/elasticsearch/index/query/AndQueryBuilder.java +++ b/core/src/main/java/org/elasticsearch/index/query/AndQueryBuilder.java @@ -19,7 +19,6 @@ package org.elasticsearch.index.query; -import com.google.common.collect.Lists; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; @@ -32,7 +31,7 @@ import java.util.ArrayList; @Deprecated public class AndQueryBuilder extends QueryBuilder { - private ArrayList filters = Lists.newArrayList(); + private ArrayList filters = new ArrayList<>(); private String queryName; diff --git a/core/src/main/java/org/elasticsearch/index/query/AndQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/AndQueryParser.java index 8c1969de561..bb0e1cbbcd5 100644 --- a/core/src/main/java/org/elasticsearch/index/query/AndQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/AndQueryParser.java @@ -28,8 +28,6 @@ import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; import java.util.ArrayList; -import static com.google.common.collect.Lists.newArrayList; - /** * */ @@ -51,7 +49,7 @@ public class AndQueryParser implements QueryParser { public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); - ArrayList queries = newArrayList(); + ArrayList queries = new ArrayList<>(); boolean queriesFound = false; String queryName = null; diff --git a/core/src/main/java/org/elasticsearch/index/query/BoolQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/BoolQueryParser.java index 6fa7faa85db..66ea85eb818 100644 --- a/core/src/main/java/org/elasticsearch/index/query/BoolQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/BoolQueryParser.java @@ -29,9 +29,9 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; +import java.util.ArrayList; import java.util.List; -import static com.google.common.collect.Lists.newArrayList; import static org.elasticsearch.common.lucene.search.Queries.fixNegativeQueryIfNeeded; /** @@ -59,7 +59,7 @@ public class BoolQueryParser implements QueryParser { float boost = 1.0f; String minimumShouldMatch = null; - List clauses = newArrayList(); + List clauses = new ArrayList<>(); boolean adjustPureNegative = true; String queryName = null; diff --git a/core/src/main/java/org/elasticsearch/index/query/DisMaxQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/DisMaxQueryBuilder.java index ddf9d95d166..3724a05df9a 100644 --- a/core/src/main/java/org/elasticsearch/index/query/DisMaxQueryBuilder.java +++ b/core/src/main/java/org/elasticsearch/index/query/DisMaxQueryBuilder.java @@ -24,8 +24,6 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; import java.util.ArrayList; -import static com.google.common.collect.Lists.newArrayList; - /** * A query that generates the union of documents produced by its sub-queries, and that scores each document * with the maximum score for that document as produced by any sub-query, plus a tie breaking increment for any @@ -33,7 +31,7 @@ import static com.google.common.collect.Lists.newArrayList; */ public class DisMaxQueryBuilder extends QueryBuilder implements BoostableQueryBuilder { - private ArrayList queries = newArrayList(); + private ArrayList queries = new ArrayList<>(); private float boost = -1; diff --git a/core/src/main/java/org/elasticsearch/index/query/DisMaxQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/DisMaxQueryParser.java index 2747387fbd7..dc901d66f83 100644 --- a/core/src/main/java/org/elasticsearch/index/query/DisMaxQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/DisMaxQueryParser.java @@ -26,10 +26,9 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; +import java.util.ArrayList; import java.util.List; -import static com.google.common.collect.Lists.newArrayList; - /** * */ @@ -53,7 +52,7 @@ public class DisMaxQueryParser implements QueryParser { float boost = 1.0f; float tieBreaker = 0.0f; - List queries = newArrayList(); + List queries = new ArrayList<>(); boolean queriesFound = false; String queryName = null; diff --git a/core/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryBuilder.java index 27d14ecb137..400384bdd21 100644 --- a/core/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryBuilder.java +++ b/core/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryBuilder.java @@ -19,13 +19,12 @@ package org.elasticsearch.index.query; -import com.google.common.collect.Lists; - import org.elasticsearch.common.geo.GeoHashUtils; import org.elasticsearch.common.geo.GeoPoint; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; +import java.util.ArrayList; import java.util.List; public class GeoPolygonQueryBuilder extends QueryBuilder { @@ -34,7 +33,7 @@ public class GeoPolygonQueryBuilder extends QueryBuilder { private final String name; - private final List shell = Lists.newArrayList(); + private final List shell = new ArrayList<>(); private String queryName; diff --git a/core/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryParser.java index 00401bc8ca8..e4cf677954b 100644 --- a/core/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryParser.java @@ -19,8 +19,6 @@ package org.elasticsearch.index.query; -import com.google.common.collect.Lists; - import org.apache.lucene.search.Query; import org.elasticsearch.Version; import org.elasticsearch.common.geo.GeoPoint; @@ -34,6 +32,7 @@ import org.elasticsearch.index.mapper.geo.GeoPointFieldMapper; import org.elasticsearch.index.search.geo.GeoPolygonQuery; import java.io.IOException; +import java.util.ArrayList; import java.util.List; /** @@ -68,7 +67,7 @@ public class GeoPolygonQueryParser implements QueryParser { String fieldName = null; - List shell = Lists.newArrayList(); + List shell = new ArrayList<>(); final boolean indexCreatedBeforeV2_0 = parseContext.indexVersionCreated().before(Version.V_2_0_0); boolean coerce = false; diff --git a/core/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryParser.java index d56ce40459b..98c3e2b5bf9 100644 --- a/core/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryParser.java @@ -19,7 +19,6 @@ package org.elasticsearch.index.query; -import com.google.common.collect.Lists; import com.google.common.collect.Sets; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.queries.TermsQuery; @@ -44,7 +43,9 @@ import org.elasticsearch.search.internal.SearchContext; import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import java.util.Set; @@ -163,7 +164,7 @@ public class MoreLikeThisQueryParser implements QueryParser { } mltQuery.setStopWords(stopWords); } else if ("fields".equals(currentFieldName)) { - moreLikeFields = Lists.newLinkedList(); + moreLikeFields = new LinkedList<>(); while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { String field = parser.text(); MappedFieldType fieldType = parseContext.fieldMapper(field); @@ -222,7 +223,7 @@ public class MoreLikeThisQueryParser implements QueryParser { // set like text fields boolean useDefaultField = (moreLikeFields == null); if (useDefaultField) { - moreLikeFields = Lists.newArrayList(parseContext.defaultField()); + moreLikeFields = Collections.singletonList(parseContext.defaultField()); } // possibly remove unsupported fields removeUnsupportedFields(moreLikeFields, analyzer, failOnUnsupportedField); diff --git a/core/src/main/java/org/elasticsearch/index/query/MultiMatchQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/MultiMatchQueryBuilder.java index d9a07514356..9059865bad7 100644 --- a/core/src/main/java/org/elasticsearch/index/query/MultiMatchQueryBuilder.java +++ b/core/src/main/java/org/elasticsearch/index/query/MultiMatchQueryBuilder.java @@ -20,7 +20,6 @@ package org.elasticsearch.index.query; import com.carrotsearch.hppc.ObjectFloatHashMap; -import com.google.common.collect.Lists; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParseFieldMatcher; @@ -29,6 +28,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.index.search.MatchQuery; import java.io.IOException; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Locale; @@ -151,7 +151,7 @@ public class MultiMatchQueryBuilder extends QueryBuilder implements BoostableQue * Constructs a new text query. */ public MultiMatchQueryBuilder(Object text, String... fields) { - this.fields = Lists.newArrayList(); + this.fields = new ArrayList<>(); this.fields.addAll(Arrays.asList(fields)); this.text = text; } diff --git a/core/src/main/java/org/elasticsearch/index/query/OrQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/OrQueryBuilder.java index 19ad3e49eb0..e8ad48b7faf 100644 --- a/core/src/main/java/org/elasticsearch/index/query/OrQueryBuilder.java +++ b/core/src/main/java/org/elasticsearch/index/query/OrQueryBuilder.java @@ -19,7 +19,6 @@ package org.elasticsearch.index.query; -import com.google.common.collect.Lists; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; @@ -33,7 +32,7 @@ import java.util.Collections; @Deprecated public class OrQueryBuilder extends QueryBuilder { - private ArrayList filters = Lists.newArrayList(); + private ArrayList filters = new ArrayList<>(); private String queryName; diff --git a/core/src/main/java/org/elasticsearch/index/query/OrQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/OrQueryParser.java index acc55e5f428..ff2c0b2c432 100644 --- a/core/src/main/java/org/elasticsearch/index/query/OrQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/OrQueryParser.java @@ -28,8 +28,6 @@ import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; import java.util.ArrayList; -import static com.google.common.collect.Lists.newArrayList; - /** * */ @@ -51,7 +49,7 @@ public class OrQueryParser implements QueryParser { public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); - ArrayList queries = newArrayList(); + ArrayList queries = new ArrayList<>(); boolean queriesFound = false; String queryName = null; diff --git a/core/src/main/java/org/elasticsearch/index/query/QueryStringQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/QueryStringQueryBuilder.java index 7959dc1b144..c7a297e319b 100644 --- a/core/src/main/java/org/elasticsearch/index/query/QueryStringQueryBuilder.java +++ b/core/src/main/java/org/elasticsearch/index/query/QueryStringQueryBuilder.java @@ -20,16 +20,14 @@ package org.elasticsearch.index.query; import com.carrotsearch.hppc.ObjectFloatHashMap; - import org.elasticsearch.common.unit.Fuzziness; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Locale; -import static com.google.common.collect.Lists.newArrayList; - /** * A query that parses a query string and runs it. There are two modes that this operates. The first, * when no field is added (using {@link #field(String)}, will run the query once and non prefixed fields @@ -118,7 +116,7 @@ public class QueryStringQueryBuilder extends QueryBuilder implements BoostableQu */ public QueryStringQueryBuilder field(String field) { if (fields == null) { - fields = newArrayList(); + fields = new ArrayList<>(); } fields.add(field); return this; @@ -129,7 +127,7 @@ public class QueryStringQueryBuilder extends QueryBuilder implements BoostableQu */ public QueryStringQueryBuilder field(String field, float boost) { if (fields == null) { - fields = newArrayList(); + fields = new ArrayList<>(); } fields.add(field); if (fieldsBoosts == null) { diff --git a/core/src/main/java/org/elasticsearch/index/query/QueryStringQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/QueryStringQueryParser.java index a198c126026..929f7c16cd9 100644 --- a/core/src/main/java/org/elasticsearch/index/query/QueryStringQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/QueryStringQueryParser.java @@ -20,8 +20,6 @@ package org.elasticsearch.index.query; import com.carrotsearch.hppc.ObjectFloatHashMap; -import com.google.common.collect.Lists; - import org.apache.lucene.queryparser.classic.MapperQueryParser; import org.apache.lucene.queryparser.classic.QueryParserSettings; import org.apache.lucene.search.BooleanQuery; @@ -40,6 +38,7 @@ import org.elasticsearch.index.query.support.QueryParsers; import org.joda.time.DateTimeZone; import java.io.IOException; +import java.util.ArrayList; import java.util.Locale; import static org.elasticsearch.common.lucene.search.Queries.fixNegativeQueryIfNeeded; @@ -102,7 +101,7 @@ public class QueryStringQueryParser implements QueryParser { fField = parser.text(); } if (qpSettings.fields() == null) { - qpSettings.fields(Lists.newArrayList()); + qpSettings.fields(new ArrayList()); } if (Regex.isSimpleMatchPattern(fField)) { diff --git a/core/src/main/java/org/elasticsearch/index/query/SpanNearQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/SpanNearQueryParser.java index 6ecf1b70bea..506bce20274 100644 --- a/core/src/main/java/org/elasticsearch/index/query/SpanNearQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/SpanNearQueryParser.java @@ -27,10 +27,9 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; +import java.util.ArrayList; import java.util.List; -import static com.google.common.collect.Lists.newArrayList; - /** * */ @@ -57,7 +56,7 @@ public class SpanNearQueryParser implements QueryParser { boolean collectPayloads = true; String queryName = null; - List clauses = newArrayList(); + List clauses = new ArrayList<>(); String currentFieldName = null; XContentParser.Token token; diff --git a/core/src/main/java/org/elasticsearch/index/query/SpanOrQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/SpanOrQueryParser.java index db58d4cca82..e28a9ccdccc 100644 --- a/core/src/main/java/org/elasticsearch/index/query/SpanOrQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/SpanOrQueryParser.java @@ -27,10 +27,9 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; +import java.util.ArrayList; import java.util.List; -import static com.google.common.collect.Lists.newArrayList; - /** * */ @@ -54,7 +53,7 @@ public class SpanOrQueryParser implements QueryParser { float boost = 1.0f; String queryName = null; - List clauses = newArrayList(); + List clauses = new ArrayList<>(); String currentFieldName = null; XContentParser.Token token; diff --git a/core/src/main/java/org/elasticsearch/index/query/TermsQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/TermsQueryParser.java index db2fed37226..0d5ae097ab9 100644 --- a/core/src/main/java/org/elasticsearch/index/query/TermsQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/TermsQueryParser.java @@ -19,8 +19,6 @@ package org.elasticsearch.index.query; -import com.google.common.collect.Lists; - import org.apache.lucene.index.Term; import org.apache.lucene.queries.TermsQuery; import org.apache.lucene.search.BooleanClause.Occur; @@ -42,6 +40,7 @@ import org.elasticsearch.indices.cache.query.terms.TermsLookup; import org.elasticsearch.search.internal.SearchContext; import java.io.IOException; +import java.util.ArrayList; import java.util.List; /** @@ -86,7 +85,7 @@ public class TermsQueryParser implements QueryParser { boolean disableCoord = false; XContentParser.Token token; - List terms = Lists.newArrayList(); + List terms = new ArrayList<>(); String fieldName = null; float boost = 1f; while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { diff --git a/core/src/main/java/org/elasticsearch/index/shard/CommitPoints.java b/core/src/main/java/org/elasticsearch/index/shard/CommitPoints.java index a56a0f62c24..ff06850feb6 100644 --- a/core/src/main/java/org/elasticsearch/index/shard/CommitPoints.java +++ b/core/src/main/java/org/elasticsearch/index/shard/CommitPoints.java @@ -20,7 +20,6 @@ package org.elasticsearch.index.shard; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; import org.apache.lucene.util.CollectionUtil; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; @@ -28,6 +27,7 @@ import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentType; import java.io.IOException; +import java.util.ArrayList; import java.util.Comparator; import java.util.Iterator; import java.util.List; @@ -130,8 +130,8 @@ public class CommitPoints implements Iterable { long version = -1; String name = null; CommitPoint.Type type = null; - List indexFiles = Lists.newArrayList(); - List translogFiles = Lists.newArrayList(); + List indexFiles = new ArrayList<>(); + List translogFiles = new ArrayList<>(); while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); diff --git a/core/src/main/java/org/elasticsearch/index/shard/ElasticsearchMergePolicy.java b/core/src/main/java/org/elasticsearch/index/shard/ElasticsearchMergePolicy.java index 7e3435bd185..c8d0379d701 100644 --- a/core/src/main/java/org/elasticsearch/index/shard/ElasticsearchMergePolicy.java +++ b/core/src/main/java/org/elasticsearch/index/shard/ElasticsearchMergePolicy.java @@ -19,8 +19,12 @@ package org.elasticsearch.index.shard; -import com.google.common.collect.Lists; -import org.apache.lucene.index.*; +import org.apache.lucene.index.CodecReader; +import org.apache.lucene.index.IndexWriter; +import org.apache.lucene.index.MergePolicy; +import org.apache.lucene.index.MergeTrigger; +import org.apache.lucene.index.SegmentCommitInfo; +import org.apache.lucene.index.SegmentInfos; import org.apache.lucene.store.Directory; import org.elasticsearch.Version; import org.elasticsearch.common.logging.ESLogger; @@ -28,6 +32,7 @@ import org.elasticsearch.common.logging.Loggers; import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -153,7 +158,7 @@ public final class ElasticsearchMergePolicy extends MergePolicy { // TODO: Use IndexUpgradeMergePolicy instead. We should be comparing codecs, // for now we just assume every minor upgrade has a new format. logger.debug("Adding segment " + info.info.name + " to be upgraded"); - spec.add(new OneMerge(Lists.newArrayList(info))); + spec.add(new OneMerge(Collections.singletonList(info))); } // TODO: we could check IndexWriter.getMergingSegments and avoid adding merges that IW will just reject? diff --git a/core/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardRepository.java b/core/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardRepository.java index 042f3c3f5ef..3730b67e377 100644 --- a/core/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardRepository.java +++ b/core/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardRepository.java @@ -20,8 +20,6 @@ package org.elasticsearch.index.snapshots.blobstore; import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.google.common.io.ByteStreams; import org.apache.lucene.index.CorruptIndexException; import org.apache.lucene.index.IndexFormatTooNewException; import org.apache.lucene.index.IndexFormatTooOldException; @@ -43,7 +41,6 @@ import org.elasticsearch.common.blobstore.BlobContainer; import org.elasticsearch.common.blobstore.BlobMetaData; import org.elasticsearch.common.blobstore.BlobPath; import org.elasticsearch.common.blobstore.BlobStore; -import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; @@ -51,11 +48,14 @@ import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.lucene.store.InputStreamIndexInput; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.ByteSizeValue; -import org.elasticsearch.common.xcontent.*; import org.elasticsearch.index.IndexService; import org.elasticsearch.index.deletionpolicy.SnapshotIndexCommit; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.snapshots.*; +import org.elasticsearch.index.snapshots.IndexShardRepository; +import org.elasticsearch.index.snapshots.IndexShardRestoreFailedException; +import org.elasticsearch.index.snapshots.IndexShardSnapshotException; +import org.elasticsearch.index.snapshots.IndexShardSnapshotFailedException; +import org.elasticsearch.index.snapshots.IndexShardSnapshotStatus; import org.elasticsearch.index.snapshots.blobstore.BlobStoreIndexShardSnapshot.FileInfo; import org.elasticsearch.index.store.Store; import org.elasticsearch.index.store.StoreFileMetaData; @@ -63,15 +63,21 @@ import org.elasticsearch.indices.IndicesService; import org.elasticsearch.indices.recovery.RecoveryState; import org.elasticsearch.repositories.RepositoryName; import org.elasticsearch.repositories.RepositoryVerificationException; -import org.elasticsearch.repositories.blobstore.*; +import org.elasticsearch.repositories.blobstore.BlobStoreFormat; +import org.elasticsearch.repositories.blobstore.BlobStoreRepository; +import org.elasticsearch.repositories.blobstore.ChecksumBlobStoreFormat; +import org.elasticsearch.repositories.blobstore.LegacyBlobStoreFormat; import java.io.FilterInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; -import static com.google.common.collect.Lists.newArrayList; import static org.elasticsearch.repositories.blobstore.BlobStoreRepository.testBlobPrefix; /** @@ -318,7 +324,7 @@ public class BlobStoreIndexShardRepository extends AbstractComponent implements } // Build a list of snapshots that should be preserved - List newSnapshotsList = Lists.newArrayList(); + List newSnapshotsList = new ArrayList<>(); for (SnapshotFiles point : snapshots) { if (!point.snapshot().equals(snapshotId.getSnapshot())) { newSnapshotsList.add(point); @@ -352,7 +358,7 @@ public class BlobStoreIndexShardRepository extends AbstractComponent implements */ protected void finalize(List snapshots, int fileListGeneration, Map blobs) { BlobStoreIndexShardSnapshots newSnapshots = new BlobStoreIndexShardSnapshots(snapshots); - List blobsToDelete = newArrayList(); + List blobsToDelete = new ArrayList<>(); // delete old index files first for (String blobName : blobs.keySet()) { // delete old file lists @@ -369,7 +375,7 @@ public class BlobStoreIndexShardRepository extends AbstractComponent implements throw new IndexShardSnapshotFailedException(shardId, "error deleting index files during cleanup, reason: " + e.getMessage(), e); } - blobsToDelete = newArrayList(); + blobsToDelete = new ArrayList<>(); // now go over all the blobs, and if they don't exists in a snapshot, delete them for (String blobName : blobs.keySet()) { // delete unused files @@ -459,7 +465,7 @@ public class BlobStoreIndexShardRepository extends AbstractComponent implements } // We couldn't load the index file - falling back to loading individual snapshots - List snapshots = Lists.newArrayList(); + List snapshots = new ArrayList<>(); for (String name : blobs.keySet()) { try { BlobStoreIndexShardSnapshot snapshot = null; @@ -524,11 +530,11 @@ public class BlobStoreIndexShardRepository extends AbstractComponent implements BlobStoreIndexShardSnapshots snapshots = tuple.v1(); int fileListGeneration = tuple.v2(); - final List indexCommitPointFiles = newArrayList(); + final List indexCommitPointFiles = new ArrayList<>(); int indexNumberOfFiles = 0; long indexTotalFilesSize = 0; - ArrayList filesToSnapshot = newArrayList(); + ArrayList filesToSnapshot = new ArrayList<>(); final Store.MetadataSnapshot metadata; // TODO apparently we don't use the MetadataSnapshot#.recoveryDiff(...) here but we should try { @@ -611,7 +617,7 @@ public class BlobStoreIndexShardRepository extends AbstractComponent implements // delete all files that are not referenced by any commit point // build a new BlobStoreIndexShardSnapshot, that includes this one and all the saved ones - List newSnapshotsList = Lists.newArrayList(); + List newSnapshotsList = new ArrayList<>(); newSnapshotsList.add(new SnapshotFiles(snapshot.snapshot(), snapshot.indexFiles())); for (SnapshotFiles point : snapshots) { newSnapshotsList.add(point); @@ -807,7 +813,7 @@ public class BlobStoreIndexShardRepository extends AbstractComponent implements throw new IndexShardRestoreFailedException(shardId, "Can't restore corrupted shard", e); } - final List filesToRecover = Lists.newArrayList(); + final List filesToRecover = new ArrayList<>(); final Map snapshotMetaData = new HashMap<>(); final Map fileInfos = new HashMap<>(); for (final FileInfo fileInfo : snapshot.indexFiles()) { diff --git a/core/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshot.java b/core/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshot.java index 0e997c14ec0..2c413c48ecd 100644 --- a/core/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshot.java +++ b/core/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshot.java @@ -29,14 +29,17 @@ import org.elasticsearch.common.ParseFieldMatcher; import org.elasticsearch.common.Strings; import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.unit.ByteSizeValue; -import org.elasticsearch.common.xcontent.*; +import org.elasticsearch.common.xcontent.FromXContentBuilder; +import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.common.xcontent.XContentBuilderString; +import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.store.StoreFileMetaData; import java.io.IOException; +import java.util.ArrayList; import java.util.List; -import static com.google.common.collect.Lists.newArrayList; - /** * Shard snapshot metadata */ @@ -477,7 +480,7 @@ public class BlobStoreIndexShardSnapshot implements ToXContent, FromXContentBuil int numberOfFiles = 0; long totalSize = 0; - List indexFiles = newArrayList(); + List indexFiles = new ArrayList<>(); if (parser.currentToken() == null) { // fresh parser? move to the first token parser.nextToken(); } diff --git a/core/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshots.java b/core/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshots.java index 19bf4ee3932..0a22b1ec553 100644 --- a/core/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshots.java +++ b/core/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshots.java @@ -24,15 +24,19 @@ import com.google.common.collect.ImmutableMap; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParseFieldMatcher; -import org.elasticsearch.common.xcontent.*; +import org.elasticsearch.common.xcontent.FromXContentBuilder; +import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.common.xcontent.XContentBuilderString; +import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.snapshots.blobstore.BlobStoreIndexShardSnapshot.FileInfo; import java.io.IOException; +import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; -import static com.google.common.collect.Lists.newArrayList; import static com.google.common.collect.Maps.newHashMap; /** @@ -68,7 +72,7 @@ public class BlobStoreIndexShardSnapshots implements Iterable, To for (FileInfo fileInfo : snapshot.indexFiles()) { List physicalFileList = physicalFiles.get(fileInfo.physicalName()); if (physicalFileList == null) { - physicalFileList = newArrayList(); + physicalFileList = new ArrayList<>(); physicalFiles.put(fileInfo.physicalName(), physicalFileList); } physicalFileList.add(newFiles.get(fileInfo.name())); @@ -90,7 +94,7 @@ public class BlobStoreIndexShardSnapshots implements Iterable, To for (FileInfo fileInfo : snapshot.indexFiles()) { List physicalFileList = physicalFiles.get(fileInfo.physicalName()); if (physicalFileList == null) { - physicalFileList = newArrayList(); + physicalFileList = new ArrayList<>(); physicalFiles.put(fileInfo.physicalName(), physicalFileList); } physicalFileList.add(files.get(fileInfo.name())); @@ -269,7 +273,7 @@ public class BlobStoreIndexShardSnapshots implements Iterable, To if (parseFieldMatcher.match(currentFieldName, ParseFields.FILES) == false) { throw new ElasticsearchParseException("unknown array [{}]", currentFieldName); } - List fileNames = newArrayList(); + List fileNames = new ArrayList<>(); while (parser.nextToken() != XContentParser.Token.END_ARRAY) { fileNames.add(parser.text()); } diff --git a/core/src/main/java/org/elasticsearch/indices/IndicesService.java b/core/src/main/java/org/elasticsearch/indices/IndicesService.java index 229fdbc50cf..4c3b1f5e6a4 100644 --- a/core/src/main/java/org/elasticsearch/indices/IndicesService.java +++ b/core/src/main/java/org/elasticsearch/indices/IndicesService.java @@ -20,7 +20,11 @@ package org.elasticsearch.indices; import com.google.common.base.Function; -import com.google.common.collect.*; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import com.google.common.collect.Iterators; +import com.google.common.collect.Maps; import org.apache.lucene.store.LockObtainFailedException; import org.apache.lucene.util.CollectionUtil; import org.apache.lucene.util.IOUtils; @@ -34,7 +38,12 @@ import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.component.AbstractLifecycleComponent; -import org.elasticsearch.common.inject.*; +import org.elasticsearch.common.inject.CreationException; +import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.inject.Injector; +import org.elasticsearch.common.inject.Injectors; +import org.elasticsearch.common.inject.Module; +import org.elasticsearch.common.inject.ModulesBuilder; import org.elasticsearch.common.io.FileSystemUtils; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; @@ -42,7 +51,12 @@ import org.elasticsearch.common.util.concurrent.EsExecutors; import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.env.ShardLock; import org.elasticsearch.gateway.MetaDataStateFormat; -import org.elasticsearch.index.*; +import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexModule; +import org.elasticsearch.index.IndexNameModule; +import org.elasticsearch.index.IndexNotFoundException; +import org.elasticsearch.index.IndexService; +import org.elasticsearch.index.LocalNodeIdModule; import org.elasticsearch.index.aliases.IndexAliasesServiceModule; import org.elasticsearch.index.analysis.AnalysisModule; import org.elasticsearch.index.analysis.AnalysisService; @@ -75,7 +89,11 @@ import org.elasticsearch.plugins.PluginsService; import java.io.Closeable; import java.io.IOException; import java.nio.file.Files; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -86,6 +104,7 @@ import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; import static org.elasticsearch.common.collect.MapBuilder.newMapBuilder; import static org.elasticsearch.common.settings.Settings.settingsBuilder; +import static org.elasticsearch.common.util.CollectionUtils.arrayAsArrayList; /** * @@ -237,7 +256,7 @@ public class IndicesService extends AbstractLifecycleComponent i } IndexShardStats indexShardStats = new IndexShardStats(indexShard.shardId(), new ShardStats[] { new ShardStats(indexShard, flags) }); if (!statsByShard.containsKey(indexService.index())) { - statsByShard.put(indexService.index(), Lists.newArrayList(indexShardStats)); + statsByShard.put(indexService.index(), arrayAsArrayList(indexShardStats)); } else { statsByShard.get(indexService.index()).add(indexShardStats); } diff --git a/core/src/main/java/org/elasticsearch/indices/IndicesWarmer.java b/core/src/main/java/org/elasticsearch/indices/IndicesWarmer.java index 2b28842698d..9ee45b21def 100644 --- a/core/src/main/java/org/elasticsearch/indices/IndicesWarmer.java +++ b/core/src/main/java/org/elasticsearch/indices/IndicesWarmer.java @@ -19,7 +19,6 @@ package org.elasticsearch.indices; -import com.google.common.collect.Lists; import org.apache.lucene.index.IndexReader; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.metadata.IndexMetaData; @@ -29,10 +28,11 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.index.IndexService; import org.elasticsearch.index.engine.Engine; -import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.index.shard.IndexShard; +import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.threadpool.ThreadPool; +import java.util.ArrayList; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.TimeUnit; @@ -100,7 +100,7 @@ public final class IndicesWarmer extends AbstractComponent { } indexShard.warmerService().onPreWarm(); long time = System.nanoTime(); - final List terminationHandles = Lists.newArrayList(); + final List terminationHandles = new ArrayList<>(); // get a handle on pending tasks for (final Listener listener : listeners) { if (topReader) { diff --git a/core/src/main/java/org/elasticsearch/indices/NodeIndicesStats.java b/core/src/main/java/org/elasticsearch/indices/NodeIndicesStats.java index d7d625090aa..a184f0a0888 100644 --- a/core/src/main/java/org/elasticsearch/indices/NodeIndicesStats.java +++ b/core/src/main/java/org/elasticsearch/indices/NodeIndicesStats.java @@ -19,9 +19,7 @@ package org.elasticsearch.indices; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; - import org.elasticsearch.action.admin.indices.stats.CommonStats; import org.elasticsearch.action.admin.indices.stats.IndexShardStats; import org.elasticsearch.action.admin.indices.stats.ShardStats; @@ -51,6 +49,7 @@ import org.elasticsearch.index.suggest.stats.SuggestStats; import org.elasticsearch.search.suggest.completion.CompletionStats; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -175,7 +174,7 @@ public class NodeIndicesStats implements Streamable, ToXContent { for (int i = 0; i < entries; i++) { Index index = Index.readIndexName(in); int indexShardListSize = in.readVInt(); - List indexShardStats = Lists.newArrayListWithCapacity(indexShardListSize); + List indexShardStats = new ArrayList<>(indexShardListSize); for (int j = 0; j < indexShardListSize; j++) { indexShardStats.add(IndexShardStats.readIndexShardStats(in)); } diff --git a/core/src/main/java/org/elasticsearch/indices/breaker/HierarchyCircuitBreakerService.java b/core/src/main/java/org/elasticsearch/indices/breaker/HierarchyCircuitBreakerService.java index 73877a2f631..b6422864fc5 100644 --- a/core/src/main/java/org/elasticsearch/indices/breaker/HierarchyCircuitBreakerService.java +++ b/core/src/main/java/org/elasticsearch/indices/breaker/HierarchyCircuitBreakerService.java @@ -28,13 +28,12 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.node.settings.NodeSettingsService; +import java.util.ArrayList; import java.util.List; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicLong; -import static com.google.common.collect.Lists.newArrayList; - /** * CircuitBreakerService that attempts to redistribute space between breakers * if tripped @@ -186,7 +185,7 @@ public class HierarchyCircuitBreakerService extends CircuitBreakerService { @Override public AllCircuitBreakerStats stats() { long parentEstimated = 0; - List allStats = newArrayList(); + List allStats = new ArrayList<>(); // Gather the "estimated" count for the parent breaker by adding the // estimations for each individual breaker for (CircuitBreaker breaker : this.breakers.values()) { diff --git a/core/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java b/core/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java index c669a9d6d59..30cab946d2e 100644 --- a/core/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java +++ b/core/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java @@ -22,7 +22,6 @@ package org.elasticsearch.indices.cluster; import com.carrotsearch.hppc.IntHashSet; import com.carrotsearch.hppc.cursors.ObjectCursor; import com.google.common.base.Predicate; -import com.google.common.collect.Lists; import org.elasticsearch.cluster.ClusterChangedEvent; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.ClusterState; @@ -34,7 +33,11 @@ import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.MappingMetaData; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodes; -import org.elasticsearch.cluster.routing.*; +import org.elasticsearch.cluster.routing.IndexRoutingTable; +import org.elasticsearch.cluster.routing.IndexShardRoutingTable; +import org.elasticsearch.cluster.routing.RoutingNodes; +import org.elasticsearch.cluster.routing.RoutingTable; +import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.component.AbstractLifecycleComponent; @@ -50,7 +53,12 @@ import org.elasticsearch.index.engine.Engine; import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.settings.IndexSettingsService; -import org.elasticsearch.index.shard.*; +import org.elasticsearch.index.shard.IndexShard; +import org.elasticsearch.index.shard.IndexShardRecoveryException; +import org.elasticsearch.index.shard.IndexShardState; +import org.elasticsearch.index.shard.ShardId; +import org.elasticsearch.index.shard.ShardNotFoundException; +import org.elasticsearch.index.shard.StoreRecoveryService; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.indices.recovery.RecoveryFailedException; import org.elasticsearch.indices.recovery.RecoveryState; @@ -58,6 +66,7 @@ import org.elasticsearch.indices.recovery.RecoveryStatus; import org.elasticsearch.indices.recovery.RecoveryTarget; import org.elasticsearch.threadpool.ThreadPool; +import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -335,7 +344,7 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent typesToRefresh = Lists.newArrayList(); + List typesToRefresh = new ArrayList<>(); String index = indexMetaData.index(); IndexService indexService = indicesService.indexService(index); if (indexService == null) { diff --git a/core/src/main/java/org/elasticsearch/indices/memory/IndexingMemoryController.java b/core/src/main/java/org/elasticsearch/indices/memory/IndexingMemoryController.java index 430b7634672..67d3e8eadfc 100644 --- a/core/src/main/java/org/elasticsearch/indices/memory/IndexingMemoryController.java +++ b/core/src/main/java/org/elasticsearch/indices/memory/IndexingMemoryController.java @@ -19,7 +19,6 @@ package org.elasticsearch.indices.memory; -import com.google.common.collect.Lists; import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -39,7 +38,12 @@ import org.elasticsearch.indices.IndicesService; import org.elasticsearch.monitor.jvm.JvmInfo; import org.elasticsearch.threadpool.ThreadPool; -import java.util.*; +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import java.util.concurrent.ScheduledFuture; /** @@ -158,7 +162,7 @@ public class IndexingMemoryController extends AbstractLifecycleComponent activeToInactiveIndexingShards = Lists.newArrayList(); + final List activeToInactiveIndexingShards = new ArrayList<>(); final int activeShards = updateShardStatuses(changes, activeToInactiveIndexingShards); for (IndexShard indexShard : activeToInactiveIndexingShards) { // update inactive indexing buffer size diff --git a/core/src/main/java/org/elasticsearch/indices/recovery/RecoveryResponse.java b/core/src/main/java/org/elasticsearch/indices/recovery/RecoveryResponse.java index b360130d271..7ec59a76ed8 100644 --- a/core/src/main/java/org/elasticsearch/indices/recovery/RecoveryResponse.java +++ b/core/src/main/java/org/elasticsearch/indices/recovery/RecoveryResponse.java @@ -19,12 +19,12 @@ package org.elasticsearch.indices.recovery; -import com.google.common.collect.Lists; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.transport.TransportResponse; import java.io.IOException; +import java.util.ArrayList; import java.util.List; /** @@ -32,10 +32,10 @@ import java.util.List; */ class RecoveryResponse extends TransportResponse { - List phase1FileNames = Lists.newArrayList(); - List phase1FileSizes = Lists.newArrayList(); - List phase1ExistingFileNames = Lists.newArrayList(); - List phase1ExistingFileSizes = Lists.newArrayList(); + List phase1FileNames = new ArrayList<>(); + List phase1FileSizes = new ArrayList<>(); + List phase1ExistingFileNames = new ArrayList<>(); + List phase1ExistingFileSizes = new ArrayList<>(); long phase1TotalSize; long phase1ExistingTotalSize; long phase1Time; @@ -53,23 +53,23 @@ class RecoveryResponse extends TransportResponse { public void readFrom(StreamInput in) throws IOException { super.readFrom(in); int size = in.readVInt(); - phase1FileNames = Lists.newArrayListWithCapacity(size); + phase1FileNames = new ArrayList<>(size); for (int i = 0; i < size; i++) { phase1FileNames.add(in.readString()); } size = in.readVInt(); - phase1FileSizes = Lists.newArrayListWithCapacity(size); + phase1FileSizes = new ArrayList<>(size); for (int i = 0; i < size; i++) { phase1FileSizes.add(in.readVLong()); } size = in.readVInt(); - phase1ExistingFileNames = Lists.newArrayListWithCapacity(size); + phase1ExistingFileNames = new ArrayList<>(size); for (int i = 0; i < size; i++) { phase1ExistingFileNames.add(in.readString()); } size = in.readVInt(); - phase1ExistingFileSizes = Lists.newArrayListWithCapacity(size); + phase1ExistingFileSizes = new ArrayList<>(size); for (int i = 0; i < size; i++) { phase1ExistingFileSizes.add(in.readVLong()); } diff --git a/core/src/main/java/org/elasticsearch/indices/recovery/RecoverySourceHandler.java b/core/src/main/java/org/elasticsearch/indices/recovery/RecoverySourceHandler.java index 9d0439dc167..8d913c6937f 100644 --- a/core/src/main/java/org/elasticsearch/indices/recovery/RecoverySourceHandler.java +++ b/core/src/main/java/org/elasticsearch/indices/recovery/RecoverySourceHandler.java @@ -20,7 +20,6 @@ package org.elasticsearch.indices.recovery; import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; import org.apache.lucene.index.CorruptIndexException; import org.apache.lucene.index.IndexFormatTooNewException; import org.apache.lucene.index.IndexFormatTooOldException; @@ -57,6 +56,7 @@ import org.elasticsearch.transport.TransportRequestOptions; import org.elasticsearch.transport.TransportService; import java.io.IOException; +import java.util.ArrayList; import java.util.Comparator; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; @@ -558,7 +558,7 @@ public class RecoverySourceHandler { int ops = 0; long size = 0; int totalOperations = 0; - final List operations = Lists.newArrayList(); + final List operations = new ArrayList<>(); Translog.Operation operation; try { operation = snapshot.next(); // this ex should bubble up diff --git a/core/src/main/java/org/elasticsearch/indices/recovery/RecoveryTranslogOperationsRequest.java b/core/src/main/java/org/elasticsearch/indices/recovery/RecoveryTranslogOperationsRequest.java index b320c98568a..345c179bc3b 100644 --- a/core/src/main/java/org/elasticsearch/indices/recovery/RecoveryTranslogOperationsRequest.java +++ b/core/src/main/java/org/elasticsearch/indices/recovery/RecoveryTranslogOperationsRequest.java @@ -19,7 +19,6 @@ package org.elasticsearch.indices.recovery; -import com.google.common.collect.Lists; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.index.shard.ShardId; diff --git a/core/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetaData.java b/core/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetaData.java index 1d4eefdcb05..d72e145d526 100644 --- a/core/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetaData.java +++ b/core/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetaData.java @@ -19,12 +19,15 @@ package org.elasticsearch.indices.store; -import com.google.common.collect.Lists; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.action.support.ActionFilters; -import org.elasticsearch.action.support.nodes.*; +import org.elasticsearch.action.support.nodes.BaseNodeRequest; +import org.elasticsearch.action.support.nodes.BaseNodeResponse; +import org.elasticsearch.action.support.nodes.BaseNodesRequest; +import org.elasticsearch.action.support.nodes.BaseNodesResponse; +import org.elasticsearch.action.support.nodes.TransportNodesAction; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.ClusterState; @@ -51,6 +54,7 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import java.io.IOException; +import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Set; @@ -103,8 +107,8 @@ public class TransportNodesListShardStoreMetaData extends TransportNodesAction nodeStoreFilesMetaDatas = Lists.newArrayList(); - final List failures = Lists.newArrayList(); + final List nodeStoreFilesMetaDatas = new ArrayList<>(); + final List failures = new ArrayList<>(); for (int i = 0; i < responses.length(); i++) { Object resp = responses.get(i); if (resp instanceof NodeStoreFilesMetaData) { // will also filter out null response for unallocated ones diff --git a/core/src/main/java/org/elasticsearch/percolator/PercolatorService.java b/core/src/main/java/org/elasticsearch/percolator/PercolatorService.java index 2781efc9309..6096f29262f 100644 --- a/core/src/main/java/org/elasticsearch/percolator/PercolatorService.java +++ b/core/src/main/java/org/elasticsearch/percolator/PercolatorService.java @@ -19,12 +19,17 @@ package org.elasticsearch.percolator; import com.carrotsearch.hppc.IntObjectHashMap; -import com.google.common.collect.Lists; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.ReaderUtil; import org.apache.lucene.index.memory.ExtendedMemoryIndex; import org.apache.lucene.index.memory.MemoryIndex; -import org.apache.lucene.search.*; +import org.apache.lucene.search.BooleanClause; +import org.apache.lucene.search.BooleanQuery; +import org.apache.lucene.search.ConstantScoreQuery; +import org.apache.lucene.search.MatchAllDocsQuery; +import org.apache.lucene.search.Query; +import org.apache.lucene.search.ScoreDoc; +import org.apache.lucene.search.TopDocs; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.CloseableThreadLocal; import org.elasticsearch.ElasticsearchParseException; @@ -58,7 +63,11 @@ import org.elasticsearch.index.IndexService; import org.elasticsearch.index.engine.Engine; import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.SortedBinaryDocValues; -import org.elasticsearch.index.mapper.*; +import org.elasticsearch.index.mapper.DocumentMapperForType; +import org.elasticsearch.index.mapper.MappedFieldType; +import org.elasticsearch.index.mapper.MapperService; +import org.elasticsearch.index.mapper.ParsedDocument; +import org.elasticsearch.index.mapper.Uid; import org.elasticsearch.index.mapper.internal.UidFieldMapper; import org.elasticsearch.index.percolator.stats.ShardPercolateService; import org.elasticsearch.index.query.ParsedQuery; @@ -84,6 +93,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import static org.elasticsearch.common.util.CollectionUtils.eagerTransform; import static org.elasticsearch.index.mapper.SourceToParse.source; import static org.elasticsearch.percolator.QueryCollector.*; @@ -846,7 +856,7 @@ public class PercolatorService extends AbstractComponent { if (aggregations != null) { List pipelineAggregators = shardResults.get(0).pipelineAggregators(); if (pipelineAggregators != null) { - List newAggs = new ArrayList<>(Lists.transform(aggregations.asList(), PipelineAggregator.AGGREGATION_TRANFORM_FUNCTION)); + List newAggs = new ArrayList<>(eagerTransform(aggregations.asList(), PipelineAggregator.AGGREGATION_TRANFORM_FUNCTION)); for (SiblingPipelineAggregator pipelineAggregator : pipelineAggregators) { InternalAggregation newAgg = pipelineAggregator.doReduce(new InternalAggregations(newAggs), new ReduceContext(bigArrays, scriptService)); diff --git a/core/src/main/java/org/elasticsearch/repositories/VerifyNodeRepositoryAction.java b/core/src/main/java/org/elasticsearch/repositories/VerifyNodeRepositoryAction.java index 35a168428bf..11b898d85f7 100644 --- a/core/src/main/java/org/elasticsearch/repositories/VerifyNodeRepositoryAction.java +++ b/core/src/main/java/org/elasticsearch/repositories/VerifyNodeRepositoryAction.java @@ -31,17 +31,22 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.snapshots.IndexShardRepository; -import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.*; import org.elasticsearch.repositories.RepositoriesService.VerifyResponse; +import org.elasticsearch.threadpool.ThreadPool; +import org.elasticsearch.transport.EmptyTransportResponseHandler; +import org.elasticsearch.transport.TransportChannel; +import org.elasticsearch.transport.TransportException; +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.ArrayList; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicInteger; -import static com.google.common.collect.Lists.newArrayList; - public class VerifyNodeRepositoryAction extends AbstractComponent { public static final String ACTION_NAME = "internal:admin/repository/verify"; @@ -68,7 +73,7 @@ public class VerifyNodeRepositoryAction extends AbstractComponent { final DiscoveryNode localNode = discoNodes.localNode(); final ObjectContainer masterAndDataNodes = discoNodes.masterAndDataNodes().values(); - final List nodes = newArrayList(); + final List nodes = new ArrayList<>(); for (ObjectCursor cursor : masterAndDataNodes) { DiscoveryNode node = cursor.value; nodes.add(node); diff --git a/core/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java b/core/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java index 44ccb945d3d..fd712bff928 100644 --- a/core/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java +++ b/core/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java @@ -56,7 +56,12 @@ import org.elasticsearch.repositories.Repository; import org.elasticsearch.repositories.RepositoryException; import org.elasticsearch.repositories.RepositorySettings; import org.elasticsearch.repositories.RepositoryVerificationException; -import org.elasticsearch.snapshots.*; +import org.elasticsearch.snapshots.InvalidSnapshotNameException; +import org.elasticsearch.snapshots.Snapshot; +import org.elasticsearch.snapshots.SnapshotCreationException; +import org.elasticsearch.snapshots.SnapshotException; +import org.elasticsearch.snapshots.SnapshotMissingException; +import org.elasticsearch.snapshots.SnapshotShardFailure; import java.io.FileNotFoundException; import java.io.IOException; @@ -68,8 +73,6 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import static com.google.common.collect.Lists.newArrayList; - /** * BlobStore - based implementation of Snapshot Repository *

@@ -389,7 +392,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent snapshots() { try { - List snapshots = newArrayList(); + List snapshots = new ArrayList<>(); Map blobs; try { blobs = snapshotsBlobContainer.listBlobsByPrefix(COMMON_SNAPSHOT_PREFIX); diff --git a/core/src/main/java/org/elasticsearch/rest/RestModule.java b/core/src/main/java/org/elasticsearch/rest/RestModule.java index a5d6e1be7c5..e7949172d0a 100644 --- a/core/src/main/java/org/elasticsearch/rest/RestModule.java +++ b/core/src/main/java/org/elasticsearch/rest/RestModule.java @@ -19,11 +19,11 @@ package org.elasticsearch.rest; -import com.google.common.collect.Lists; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.action.RestActionModule; +import java.util.ArrayList; import java.util.List; /** @@ -32,7 +32,7 @@ import java.util.List; public class RestModule extends AbstractModule { private final Settings settings; - private List> restPluginsActions = Lists.newArrayList(); + private List> restPluginsActions = new ArrayList<>(); public void addRestAction(Class restAction) { restPluginsActions.add(restAction); diff --git a/core/src/main/java/org/elasticsearch/rest/RestResponse.java b/core/src/main/java/org/elasticsearch/rest/RestResponse.java index 80ad0e16a37..7946785bc97 100644 --- a/core/src/main/java/org/elasticsearch/rest/RestResponse.java +++ b/core/src/main/java/org/elasticsearch/rest/RestResponse.java @@ -19,12 +19,15 @@ package org.elasticsearch.rest; -import com.google.common.collect.Lists; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.bytes.BytesReference; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; /** * @@ -58,7 +61,7 @@ public abstract class RestResponse { for (String key : headerKeySet) { List values = customHeaders.get(key); if (values == null) { - values = Lists.newArrayList(); + values = new ArrayList<>(); customHeaders.put(key, values); } values.addAll(ex.getHeader(key)); diff --git a/core/src/main/java/org/elasticsearch/rest/action/RestActionModule.java b/core/src/main/java/org/elasticsearch/rest/action/RestActionModule.java index 0764ca2f536..02bde5f74d5 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/RestActionModule.java +++ b/core/src/main/java/org/elasticsearch/rest/action/RestActionModule.java @@ -19,8 +19,6 @@ package org.elasticsearch.rest.action; -import com.google.common.collect.Lists; - import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.multibindings.Multibinder; import org.elasticsearch.rest.BaseRestHandler; @@ -67,10 +65,10 @@ import org.elasticsearch.rest.action.admin.indices.open.RestOpenIndexAction; import org.elasticsearch.rest.action.admin.indices.optimize.RestOptimizeAction; import org.elasticsearch.rest.action.admin.indices.recovery.RestRecoveryAction; import org.elasticsearch.rest.action.admin.indices.refresh.RestRefreshAction; -import org.elasticsearch.rest.action.admin.indices.shards.RestIndicesShardStoresAction; import org.elasticsearch.rest.action.admin.indices.segments.RestIndicesSegmentsAction; import org.elasticsearch.rest.action.admin.indices.settings.RestGetSettingsAction; import org.elasticsearch.rest.action.admin.indices.settings.RestUpdateSettingsAction; +import org.elasticsearch.rest.action.admin.indices.shards.RestIndicesShardStoresAction; import org.elasticsearch.rest.action.admin.indices.stats.RestIndicesStatsAction; import org.elasticsearch.rest.action.admin.indices.template.delete.RestDeleteIndexTemplateAction; import org.elasticsearch.rest.action.admin.indices.template.get.RestGetIndexTemplateAction; @@ -83,7 +81,20 @@ import org.elasticsearch.rest.action.admin.indices.warmer.delete.RestDeleteWarme import org.elasticsearch.rest.action.admin.indices.warmer.get.RestGetWarmerAction; import org.elasticsearch.rest.action.admin.indices.warmer.put.RestPutWarmerAction; import org.elasticsearch.rest.action.bulk.RestBulkAction; -import org.elasticsearch.rest.action.cat.*; +import org.elasticsearch.rest.action.cat.AbstractCatAction; +import org.elasticsearch.rest.action.cat.RestAliasAction; +import org.elasticsearch.rest.action.cat.RestAllocationAction; +import org.elasticsearch.rest.action.cat.RestCatAction; +import org.elasticsearch.rest.action.cat.RestFielddataAction; +import org.elasticsearch.rest.action.cat.RestHealthAction; +import org.elasticsearch.rest.action.cat.RestIndicesAction; +import org.elasticsearch.rest.action.cat.RestMasterAction; +import org.elasticsearch.rest.action.cat.RestNodeAttrsAction; +import org.elasticsearch.rest.action.cat.RestNodesAction; +import org.elasticsearch.rest.action.cat.RestPluginsAction; +import org.elasticsearch.rest.action.cat.RestSegmentsAction; +import org.elasticsearch.rest.action.cat.RestShardsAction; +import org.elasticsearch.rest.action.cat.RestThreadPoolAction; import org.elasticsearch.rest.action.delete.RestDeleteAction; import org.elasticsearch.rest.action.explain.RestExplainAction; import org.elasticsearch.rest.action.fieldstats.RestFieldStatsAction; @@ -110,13 +121,14 @@ import org.elasticsearch.rest.action.termvectors.RestMultiTermVectorsAction; import org.elasticsearch.rest.action.termvectors.RestTermVectorsAction; import org.elasticsearch.rest.action.update.RestUpdateAction; +import java.util.ArrayList; import java.util.List; /** * */ public class RestActionModule extends AbstractModule { - private List> restPluginsActions = Lists.newArrayList(); + private List> restPluginsActions = new ArrayList<>(); public RestActionModule(List> restPluginsActions) { this.restPluginsActions = restPluginsActions; diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/analyze/RestAnalyzeAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/analyze/RestAnalyzeAction.java index edfab2da1c1..57ceb21f41e 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/analyze/RestAnalyzeAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/analyze/RestAnalyzeAction.java @@ -18,7 +18,6 @@ */ package org.elasticsearch.rest.action.admin.indices.analyze; -import com.google.common.collect.Lists; import org.elasticsearch.action.admin.indices.analyze.AnalyzeRequest; import org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse; import org.elasticsearch.client.Client; @@ -29,11 +28,15 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentType; -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.RestActions; import org.elasticsearch.rest.action.support.RestToXContentListener; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import static org.elasticsearch.rest.RestRequest.Method.GET; @@ -95,7 +98,7 @@ public class RestAnalyzeAction extends BaseRestHandler { } else if ("text".equals(currentFieldName) && token == XContentParser.Token.VALUE_STRING) { analyzeRequest.text(parser.text()); } else if ("text".equals(currentFieldName) && token == XContentParser.Token.START_ARRAY) { - List texts = Lists.newArrayList(); + List texts = new ArrayList<>(); while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { if (token.isValue() == false) { throw new IllegalArgumentException(currentFieldName + " array element should only contain text"); @@ -110,7 +113,7 @@ public class RestAnalyzeAction extends BaseRestHandler { } else if ("tokenizer".equals(currentFieldName) && token == XContentParser.Token.VALUE_STRING) { analyzeRequest.tokenizer(parser.text()); } else if (("token_filters".equals(currentFieldName) || "filters".equals(currentFieldName)) && token == XContentParser.Token.START_ARRAY) { - List filters = Lists.newArrayList(); + List filters = new ArrayList<>(); while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { if (token.isValue() == false) { throw new IllegalArgumentException(currentFieldName + " array element should only contain token filter's name"); @@ -119,7 +122,7 @@ public class RestAnalyzeAction extends BaseRestHandler { } analyzeRequest.tokenFilters(filters.toArray(Strings.EMPTY_ARRAY)); } else if ("char_filters".equals(currentFieldName) && token == XContentParser.Token.START_ARRAY) { - List charFilters = Lists.newArrayList(); + List charFilters = new ArrayList<>(); while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { if (token.isValue() == false) { throw new IllegalArgumentException(currentFieldName + " array element should only contain char filter's name"); diff --git a/core/src/main/java/org/elasticsearch/script/ScriptModule.java b/core/src/main/java/org/elasticsearch/script/ScriptModule.java index f5de92f67d7..1f06d9713e3 100644 --- a/core/src/main/java/org/elasticsearch/script/ScriptModule.java +++ b/core/src/main/java/org/elasticsearch/script/ScriptModule.java @@ -19,7 +19,6 @@ package org.elasticsearch.script; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.multibindings.MapBinder; @@ -30,6 +29,7 @@ import org.elasticsearch.script.expression.ExpressionScriptEngineService; import org.elasticsearch.script.groovy.GroovyScriptEngineService; import org.elasticsearch.script.mustache.MustacheScriptEngineService; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -41,11 +41,11 @@ public class ScriptModule extends AbstractModule { private final Settings settings; - private final List> scriptEngines = Lists.newArrayList(); + private final List> scriptEngines = new ArrayList<>(); private final Map> scripts = Maps.newHashMap(); - private final List customScriptContexts = Lists.newArrayList(); + private final List customScriptContexts = new ArrayList<>(); public ScriptModule(Settings settings) { this.settings = settings; diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/AggregationBuilder.java b/core/src/main/java/org/elasticsearch/search/aggregations/AggregationBuilder.java index b94f657de94..ed1ba6cb9ec 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/AggregationBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/AggregationBuilder.java @@ -19,8 +19,6 @@ package org.elasticsearch.search.aggregations; -import com.google.common.collect.Lists; - import org.elasticsearch.ElasticsearchGenerationException; import org.elasticsearch.client.Requests; import org.elasticsearch.common.bytes.BytesArray; @@ -29,6 +27,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -54,7 +53,7 @@ public abstract class AggregationBuilder> extend @SuppressWarnings("unchecked") public B subAggregation(AbstractAggregationBuilder aggregation) { if (aggregations == null) { - aggregations = Lists.newArrayList(); + aggregations = new ArrayList<>(); } aggregations.add(aggregation); return (B) this; diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/InternalAggregation.java b/core/src/main/java/org/elasticsearch/search/aggregations/InternalAggregation.java index 1f32c0a1687..90c1dee9e50 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/InternalAggregation.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/InternalAggregation.java @@ -19,8 +19,6 @@ package org.elasticsearch.search.aggregations; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; - import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.io.stream.StreamInput; @@ -36,6 +34,7 @@ import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorStreams; import org.elasticsearch.search.aggregations.support.AggregationPath; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -228,7 +227,7 @@ public abstract class InternalAggregation implements Aggregation, ToXContent, St if (size == 0) { pipelineAggregators = ImmutableList.of(); } else { - pipelineAggregators = Lists.newArrayListWithCapacity(size); + pipelineAggregators = new ArrayList<>(size); for (int i = 0; i < size; i++) { BytesReference type = in.readBytesReference(); PipelineAggregator pipelineAggregator = PipelineAggregatorStreams.stream(type).readResult(in); diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/InternalAggregations.java b/core/src/main/java/org/elasticsearch/search/aggregations/InternalAggregations.java index ceefcae41b6..e90547eddf4 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/InternalAggregations.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/InternalAggregations.java @@ -22,9 +22,7 @@ import com.google.common.base.Function; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterators; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; - import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -43,6 +41,7 @@ import java.util.List; import java.util.Map; import static com.google.common.collect.Maps.newHashMap; +import static org.elasticsearch.common.util.CollectionUtils.eagerTransform; /** * An internal implementation of {@link Aggregations}. @@ -84,7 +83,7 @@ public class InternalAggregations implements Aggregations, ToXContent, Streamabl */ @Override public List asList() { - return Lists.transform(aggregations, SUPERTYPE_CAST); + return eagerTransform(aggregations, SUPERTYPE_CAST); } /** @@ -215,7 +214,7 @@ public class InternalAggregations implements Aggregations, ToXContent, Streamabl aggregations = ImmutableList.of(); aggregationsAsMap = ImmutableMap.of(); } else { - aggregations = Lists.newArrayListWithCapacity(size); + aggregations = new ArrayList<>(size); for (int i = 0; i < size; i++) { BytesReference type = in.readBytesReference(); InternalAggregation aggregation = AggregationStreams.stream(type).readResult(in); diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/filters/FiltersAggregator.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/filters/FiltersAggregator.java index 625ef0bdc68..781d47f68eb 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/filters/FiltersAggregator.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/filters/FiltersAggregator.java @@ -19,8 +19,6 @@ package org.elasticsearch.search.aggregations.bucket.filters; -import com.google.common.collect.Lists; - import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.search.Query; import org.apache.lucene.search.Weight; @@ -38,6 +36,7 @@ import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -113,7 +112,7 @@ public class FiltersAggregator extends BucketsAggregator { @Override public InternalAggregation buildAggregation(long owningBucketOrdinal) throws IOException { - List buckets = Lists.newArrayListWithCapacity(filters.length); + List buckets = new ArrayList<>(filters.length); for (int i = 0; i < keys.length; i++) { long bucketOrd = bucketOrd(owningBucketOrdinal, i); InternalFilters.Bucket bucket = new InternalFilters.Bucket(keys[i], bucketDocCount(bucketOrd), bucketAggregations(bucketOrd), keyed); @@ -132,7 +131,7 @@ public class FiltersAggregator extends BucketsAggregator { @Override public InternalAggregation buildEmptyAggregation() { InternalAggregations subAggs = buildEmptySubAggregations(); - List buckets = Lists.newArrayListWithCapacity(filters.length); + List buckets = new ArrayList<>(filters.length); for (int i = 0; i < keys.length; i++) { InternalFilters.Bucket bucket = new InternalFilters.Bucket(keys[i], 0, subAggs, keyed); buckets.add(bucket); diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/filters/InternalFilters.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/filters/InternalFilters.java index f5209330009..e415a025a4c 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/filters/InternalFilters.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/filters/InternalFilters.java @@ -19,8 +19,6 @@ package org.elasticsearch.search.aggregations.bucket.filters; -import com.google.common.collect.Lists; - import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -118,7 +116,7 @@ public class InternalFilters extends InternalMultiBucketAggregation buckets, ReduceContext context) { Bucket reduced = null; - List aggregationsList = Lists.newArrayListWithCapacity(buckets.size()); + List aggregationsList = new ArrayList<>(buckets.size()); for (Bucket bucket : buckets) { if (reduced == null) { reduced = new Bucket(bucket.key, bucket.docCount, bucket.aggregations, bucket.keyed); @@ -233,7 +231,7 @@ public class InternalFilters extends InternalMultiBucketAggregation buckets = Lists.newArrayListWithCapacity(size); + List buckets = new ArrayList<>(size); for (int i = 0; i < size; i++) { Bucket bucket = new Bucket(keyed); bucket.readFrom(in); diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalHistogram.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalHistogram.java index d7d3993508d..da3bc286ff9 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalHistogram.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalHistogram.java @@ -18,8 +18,6 @@ */ package org.elasticsearch.search.aggregations.bucket.histogram; -import com.google.common.collect.Lists; - import org.apache.lucene.util.CollectionUtil; import org.apache.lucene.util.PriorityQueue; import org.elasticsearch.common.io.stream.StreamInput; @@ -42,6 +40,7 @@ import org.elasticsearch.search.aggregations.support.format.ValueFormatterStream import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.ListIterator; @@ -464,7 +463,9 @@ public class InternalHistogram extends Inter // maintains order } else if (order == InternalOrder.KEY_DESC) { // we just need to reverse here... - reducedBuckets = Lists.reverse(reducedBuckets); + List reverse = new ArrayList<>(reducedBuckets); + Collections.reverse(reverse); + reducedBuckets = reverse; } else { // sorted by sub-aggregation, need to fall back to a costly n*log(n) sort CollectionUtil.introSort(reducedBuckets, order.comparator()); diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/range/AbstractRangeBuilder.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/range/AbstractRangeBuilder.java index e15aa57538d..c4f0c7600e7 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/range/AbstractRangeBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/range/AbstractRangeBuilder.java @@ -19,13 +19,13 @@ package org.elasticsearch.search.aggregations.bucket.range; -import com.google.common.collect.Lists; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.search.aggregations.ValuesSourceAggregationBuilder; import org.elasticsearch.search.builder.SearchSourceBuilderException; import java.io.IOException; +import java.util.ArrayList; import java.util.List; /** @@ -61,7 +61,7 @@ public abstract class AbstractRangeBuilder> ex } } - protected List ranges = Lists.newArrayList(); + protected List ranges = new ArrayList<>(); protected AbstractRangeBuilder(String name, String type) { super(name, type); diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalRange.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalRange.java index 73567183414..5303d7f3247 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalRange.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalRange.java @@ -18,8 +18,6 @@ */ package org.elasticsearch.search.aggregations.bucket.range; -import com.google.common.collect.Lists; - import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -167,7 +165,7 @@ public class InternalRange ranges, ReduceContext context) { long docCount = 0; - List aggregationsList = Lists.newArrayListWithCapacity(ranges.size()); + List aggregationsList = new ArrayList<>(ranges.size()); for (Bucket range : ranges) { docCount += range.docCount; aggregationsList.add(range.aggregations); @@ -315,7 +313,7 @@ public class InternalRange ranges = Lists.newArrayListWithCapacity(size); + List ranges = new ArrayList<>(size); for (int i = 0; i < size; i++) { String key = in.readOptionalString(); ranges.add(getFactory().createBucket(key, in.readDouble(), in.readDouble(), in.readVLong(), InternalAggregations.readAggregations(in), keyed, formatter)); diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/range/RangeAggregator.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/range/RangeAggregator.java index f8e5782b757..125fca43500 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/range/RangeAggregator.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/range/RangeAggregator.java @@ -18,8 +18,6 @@ */ package org.elasticsearch.search.aggregations.bucket.range; -import com.google.common.collect.Lists; - import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.util.InPlaceMergeSorter; import org.elasticsearch.index.fielddata.SortedNumericDoubleValues; @@ -198,7 +196,7 @@ public class RangeAggregator extends BucketsAggregator { @Override public InternalAggregation buildAggregation(long owningBucketOrdinal) throws IOException { - List buckets = Lists.newArrayListWithCapacity(ranges.length); + List buckets = new ArrayList<>(ranges.length); for (int i = 0; i < ranges.length; i++) { Range range = ranges[i]; final long bucketOrd = subBucketOrdinal(owningBucketOrdinal, i); @@ -213,7 +211,7 @@ public class RangeAggregator extends BucketsAggregator { @Override public InternalAggregation buildEmptyAggregation() { InternalAggregations subAggs = buildEmptySubAggregations(); - List buckets = Lists.newArrayListWithCapacity(ranges.length); + List buckets = new ArrayList<>(ranges.length); for (int i = 0; i < ranges.length; i++) { Range range = ranges[i]; org.elasticsearch.search.aggregations.bucket.range.Range.Bucket bucket = diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/range/geodistance/GeoDistanceBuilder.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/range/geodistance/GeoDistanceBuilder.java index 2b03503d0ee..e6649fa6a90 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/range/geodistance/GeoDistanceBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/range/geodistance/GeoDistanceBuilder.java @@ -19,7 +19,6 @@ package org.elasticsearch.search.aggregations.bucket.range.geodistance; -import com.google.common.collect.Lists; import org.elasticsearch.common.geo.GeoDistance; import org.elasticsearch.common.geo.GeoPoint; import org.elasticsearch.common.unit.DistanceUnit; @@ -29,6 +28,7 @@ import org.elasticsearch.search.aggregations.AggregationBuilder; import org.elasticsearch.search.builder.SearchSourceBuilderException; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -80,7 +80,7 @@ public class GeoDistanceBuilder extends AggregationBuilder { private GeoDistance distanceType; private GeoPoint point; - private List ranges = Lists.newArrayList(); + private List ranges = new ArrayList<>(); /** * Sole constructor. diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/SiblingPipelineAggregator.java b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/SiblingPipelineAggregator.java index cb14b0df4c2..fcccba073c9 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/SiblingPipelineAggregator.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/SiblingPipelineAggregator.java @@ -19,8 +19,6 @@ package org.elasticsearch.search.aggregations.pipeline; -import com.google.common.collect.Lists; - import org.elasticsearch.search.aggregations.Aggregations; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.InternalAggregation.ReduceContext; @@ -33,6 +31,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import static org.elasticsearch.common.util.CollectionUtils.eagerTransform; + public abstract class SiblingPipelineAggregator extends PipelineAggregator { protected SiblingPipelineAggregator() { // for Serialisation @@ -54,7 +54,7 @@ public abstract class SiblingPipelineAggregator extends PipelineAggregator { for (int i = 0; i < buckets.size(); i++) { InternalMultiBucketAggregation.InternalBucket bucket = (InternalMultiBucketAggregation.InternalBucket) buckets.get(i); InternalAggregation aggToAdd = doReduce(bucket.getAggregations(), reduceContext); - List aggs = new ArrayList<>(Lists.transform(bucket.getAggregations().asList(), + List aggs = new ArrayList<>(eagerTransform(bucket.getAggregations().asList(), AGGREGATION_TRANFORM_FUNCTION)); aggs.add(aggToAdd); InternalMultiBucketAggregation.InternalBucket newBucket = multiBucketsAgg.createBucket(new InternalAggregations(aggs), @@ -66,7 +66,7 @@ public abstract class SiblingPipelineAggregator extends PipelineAggregator { } else if (aggregation instanceof InternalSingleBucketAggregation) { InternalSingleBucketAggregation singleBucketAgg = (InternalSingleBucketAggregation) aggregation; InternalAggregation aggToAdd = doReduce(singleBucketAgg.getAggregations(), reduceContext); - List aggs = new ArrayList<>(Lists.transform(singleBucketAgg.getAggregations().asList(), + List aggs = new ArrayList<>(eagerTransform(singleBucketAgg.getAggregations().asList(), AGGREGATION_TRANFORM_FUNCTION)); aggs.add(aggToAdd); return singleBucketAgg.create(new InternalAggregations(aggs)); diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketscript/BucketScriptPipelineAggregator.java b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketscript/BucketScriptPipelineAggregator.java index 3b2a4a5a09b..06559645821 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketscript/BucketScriptPipelineAggregator.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketscript/BucketScriptPipelineAggregator.java @@ -20,8 +20,6 @@ package org.elasticsearch.search.aggregations.pipeline.bucketscript; import com.google.common.base.Function; -import com.google.common.collect.Lists; - import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.script.CompiledScript; @@ -50,6 +48,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import static org.elasticsearch.common.util.CollectionUtils.eagerTransform; import static org.elasticsearch.search.aggregations.pipeline.BucketHelpers.resolveBucketValue; public class BucketScriptPipelineAggregator extends PipelineAggregator { @@ -135,7 +134,7 @@ public class BucketScriptPipelineAggregator extends PipelineAggregator { throw new AggregationExecutionException("series_arithmetic script for reducer [" + name() + "] must return a Number"); } - List aggs = new ArrayList<>(Lists.transform(bucket.getAggregations().asList(), FUNCTION)); + List aggs = new ArrayList<>(eagerTransform(bucket.getAggregations().asList(), FUNCTION)); aggs.add(new InternalSimpleValue(name(), ((Number) returned).doubleValue(), formatter, new ArrayList(), metaData())); InternalMultiBucketAggregation.InternalBucket newBucket = originalAgg.createBucket(new InternalAggregations(aggs), diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/cumulativesum/CumulativeSumPipelineAggregator.java b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/cumulativesum/CumulativeSumPipelineAggregator.java index 9070cc6aafb..cafefdba2fe 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/cumulativesum/CumulativeSumPipelineAggregator.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/cumulativesum/CumulativeSumPipelineAggregator.java @@ -19,8 +19,6 @@ package org.elasticsearch.search.aggregations.pipeline.cumulativesum; -import com.google.common.collect.Lists; - import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.search.aggregations.AggregatorFactory; @@ -43,6 +41,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import static org.elasticsearch.common.util.CollectionUtils.eagerTransform; import static org.elasticsearch.search.aggregations.pipeline.BucketHelpers.resolveBucketValue; public class CumulativeSumPipelineAggregator extends PipelineAggregator { @@ -89,7 +88,7 @@ public class CumulativeSumPipelineAggregator extends PipelineAggregator { for (InternalHistogram.Bucket bucket : buckets) { Double thisBucketValue = resolveBucketValue(histo, bucket, bucketsPaths()[0], GapPolicy.INSERT_ZEROS); sum += thisBucketValue; - List aggs = new ArrayList<>(Lists.transform(bucket.getAggregations().asList(), + List aggs = new ArrayList<>(eagerTransform(bucket.getAggregations().asList(), AGGREGATION_TRANFORM_FUNCTION)); aggs.add(new InternalSimpleValue(name(), sum, formatter, new ArrayList(), metaData())); InternalHistogram.Bucket newBucket = factory.createBucket(bucket.getKey(), bucket.getDocCount(), diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/DerivativePipelineAggregator.java b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/DerivativePipelineAggregator.java index eeb3192598e..41b904fef88 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/DerivativePipelineAggregator.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/DerivativePipelineAggregator.java @@ -19,8 +19,6 @@ package org.elasticsearch.search.aggregations.pipeline.derivative; -import com.google.common.collect.Lists; - import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.search.aggregations.AggregationExecutionException; @@ -44,6 +42,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import static org.elasticsearch.common.util.CollectionUtils.eagerTransform; import static org.elasticsearch.search.aggregations.pipeline.BucketHelpers.resolveBucketValue; public class DerivativePipelineAggregator extends PipelineAggregator { @@ -101,7 +100,7 @@ public class DerivativePipelineAggregator extends PipelineAggregator { if (xAxisUnits != null) { xDiff = (thisBucketKey - lastBucketKey) / xAxisUnits; } - List aggs = new ArrayList<>(Lists.transform(bucket.getAggregations().asList(), + List aggs = new ArrayList<>(eagerTransform(bucket.getAggregations().asList(), AGGREGATION_TRANFORM_FUNCTION)); aggs.add(new InternalDerivative(name(), gradient, xDiff, formatter, new ArrayList(), metaData())); InternalHistogram.Bucket newBucket = factory.createBucket(bucket.getKey(), bucket.getDocCount(), new InternalAggregations( diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/MovAvgPipelineAggregator.java b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/MovAvgPipelineAggregator.java index 5b7a8675540..b1dd92d2122 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/MovAvgPipelineAggregator.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/MovAvgPipelineAggregator.java @@ -21,8 +21,6 @@ package org.elasticsearch.search.aggregations.pipeline.movavg; import com.google.common.base.Function; import com.google.common.collect.EvictingQueue; -import com.google.common.collect.Lists; - import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.search.aggregations.Aggregation; @@ -51,6 +49,7 @@ import java.util.List; import java.util.ListIterator; import java.util.Map; +import static org.elasticsearch.common.util.CollectionUtils.eagerTransform; import static org.elasticsearch.search.aggregations.pipeline.BucketHelpers.resolveBucketValue; public class MovAvgPipelineAggregator extends PipelineAggregator { @@ -135,7 +134,7 @@ public class MovAvgPipelineAggregator extends PipelineAggregator { if (model.hasValue(values.size())) { double movavg = model.next(values); - List aggs = new ArrayList<>(Lists.transform(bucket.getAggregations().asList(), AGGREGATION_TRANFORM_FUNCTION)); + List aggs = new ArrayList<>(eagerTransform(bucket.getAggregations().asList(), AGGREGATION_TRANFORM_FUNCTION)); aggs.add(new InternalSimpleValue(name(), movavg, formatter, new ArrayList(), metaData())); newBucket = factory.createBucket(bucket.getKey(), bucket.getDocCount(), new InternalAggregations( aggs), bucket.getKeyed(), bucket.getFormatter()); @@ -176,7 +175,7 @@ public class MovAvgPipelineAggregator extends PipelineAggregator { InternalHistogram.Bucket bucket = (InternalHistogram.Bucket) newBuckets.get(lastValidPosition + i + 1); // Get the existing aggs in the bucket so we don't clobber data - aggs = new ArrayList<>(Lists.transform(bucket.getAggregations().asList(), AGGREGATION_TRANFORM_FUNCTION)); + aggs = new ArrayList<>(eagerTransform(bucket.getAggregations().asList(), AGGREGATION_TRANFORM_FUNCTION)); aggs.add(new InternalSimpleValue(name(), predictions[i], formatter, new ArrayList(), metaData())); InternalHistogram.Bucket newBucket = factory.createBucket(newKey, 0, new InternalAggregations( diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/serialdiff/SerialDiffPipelineAggregator.java b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/serialdiff/SerialDiffPipelineAggregator.java index 3517a621427..e89813caabb 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/serialdiff/SerialDiffPipelineAggregator.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/serialdiff/SerialDiffPipelineAggregator.java @@ -20,7 +20,6 @@ package org.elasticsearch.search.aggregations.pipeline.serialdiff; import com.google.common.collect.EvictingQueue; -import com.google.common.collect.Lists; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -29,7 +28,10 @@ import org.elasticsearch.search.aggregations.InternalAggregation.ReduceContext; import org.elasticsearch.search.aggregations.InternalAggregation.Type; import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.bucket.histogram.InternalHistogram; -import org.elasticsearch.search.aggregations.pipeline.*; +import org.elasticsearch.search.aggregations.pipeline.InternalSimpleValue; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorStreams; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import org.elasticsearch.search.aggregations.support.format.ValueFormatterStreams; @@ -38,8 +40,9 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import static org.elasticsearch.search.aggregations.pipeline.BucketHelpers.resolveBucketValue; +import static org.elasticsearch.common.util.CollectionUtils.eagerTransform; import static org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy; +import static org.elasticsearch.search.aggregations.pipeline.BucketHelpers.resolveBucketValue; public class SerialDiffPipelineAggregator extends PipelineAggregator { @@ -111,7 +114,7 @@ public class SerialDiffPipelineAggregator extends PipelineAggregator { if (!Double.isNaN(thisBucketValue) && !Double.isNaN(lagValue)) { double diff = thisBucketValue - lagValue; - List aggs = new ArrayList<>(Lists.transform(bucket.getAggregations().asList(), AGGREGATION_TRANFORM_FUNCTION)); + List aggs = new ArrayList<>(eagerTransform(bucket.getAggregations().asList(), AGGREGATION_TRANFORM_FUNCTION)); aggs.add(new InternalSimpleValue(name(), diff, formatter, new ArrayList(), metaData())); newBucket = factory.createBucket(bucket.getKey(), bucket.getDocCount(), new InternalAggregations( aggs), bucket.getKeyed(), bucket.getFormatter()); diff --git a/core/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java b/core/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java index 0eb4c5cc882..90ce07b87ff 100644 --- a/core/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java @@ -22,8 +22,6 @@ package org.elasticsearch.search.builder; import com.carrotsearch.hppc.ObjectFloatHashMap; import com.google.common.base.Charsets; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; - import org.elasticsearch.ElasticsearchGenerationException; import org.elasticsearch.action.support.QuerySourceBuilder; import org.elasticsearch.action.support.ToXContentToBytes; @@ -37,7 +35,6 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.script.Script; -import org.elasticsearch.script.ScriptService.ScriptType; import org.elasticsearch.search.aggregations.AbstractAggregationBuilder; import org.elasticsearch.search.fetch.innerhits.InnerHitsBuilder; import org.elasticsearch.search.fetch.source.FetchSourceContext; @@ -50,7 +47,11 @@ import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.search.suggest.SuggestBuilder; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Map; /** * A search source builder allowing to easily build search source. Simple @@ -360,7 +361,7 @@ public class SearchSourceBuilder extends ToXContentToBytes { */ public SearchSourceBuilder sort(SortBuilder sort) { if (sorts == null) { - sorts = Lists.newArrayList(); + sorts = new ArrayList<>(); } sorts.add(sort); return this; @@ -380,7 +381,7 @@ public class SearchSourceBuilder extends ToXContentToBytes { */ public SearchSourceBuilder aggregation(AbstractAggregationBuilder aggregation) { if (aggregations == null) { - aggregations = Lists.newArrayList(); + aggregations = new ArrayList<>(); } aggregations.add(aggregation); return this; @@ -599,7 +600,7 @@ public class SearchSourceBuilder extends ToXContentToBytes { */ public SearchSourceBuilder scriptField(String name, Script script) { if (scriptFields == null) { - scriptFields = Lists.newArrayList(); + scriptFields = new ArrayList<>(); } scriptFields.add(new ScriptField(name, script)); return this; diff --git a/core/src/main/java/org/elasticsearch/search/controller/SearchPhaseController.java b/core/src/main/java/org/elasticsearch/search/controller/SearchPhaseController.java index 7faaea72ef5..74e263220e4 100644 --- a/core/src/main/java/org/elasticsearch/search/controller/SearchPhaseController.java +++ b/core/src/main/java/org/elasticsearch/search/controller/SearchPhaseController.java @@ -21,8 +21,6 @@ package org.elasticsearch.search.controller; import com.carrotsearch.hppc.IntArrayList; import com.carrotsearch.hppc.ObjectObjectHashMap; -import com.google.common.collect.Lists; - import org.apache.lucene.index.Term; import org.apache.lucene.search.CollectionStatistics; import org.apache.lucene.search.FieldDoc; @@ -65,6 +63,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import static org.elasticsearch.common.util.CollectionUtils.eagerTransform; + /** * */ @@ -411,7 +411,7 @@ public class SearchPhaseController extends AbstractComponent { if (aggregations != null) { List pipelineAggregators = firstResult.pipelineAggregators(); if (pipelineAggregators != null) { - List newAggs = new ArrayList<>(Lists.transform(aggregations.asList(), PipelineAggregator.AGGREGATION_TRANFORM_FUNCTION)); + List newAggs = new ArrayList<>(eagerTransform(aggregations.asList(), PipelineAggregator.AGGREGATION_TRANFORM_FUNCTION)); for (SiblingPipelineAggregator pipelineAggregator : pipelineAggregators) { InternalAggregation newAgg = pipelineAggregator.doReduce(new InternalAggregations(newAggs), new ReduceContext(bigArrays, scriptService)); diff --git a/core/src/main/java/org/elasticsearch/search/fetch/FetchPhase.java b/core/src/main/java/org/elasticsearch/search/fetch/FetchPhase.java index 81f13c32727..f9156866200 100644 --- a/core/src/main/java/org/elasticsearch/search/fetch/FetchPhase.java +++ b/core/src/main/java/org/elasticsearch/search/fetch/FetchPhase.java @@ -45,20 +45,12 @@ import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.internal.SourceFieldMapper; import org.elasticsearch.index.mapper.object.ObjectMapper; -import org.elasticsearch.index.query.functionscore.ScoreFunctionParser; import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.SearchHitField; import org.elasticsearch.search.SearchParseElement; import org.elasticsearch.search.SearchPhase; -import org.elasticsearch.search.fetch.explain.ExplainFetchSubPhase; -import org.elasticsearch.search.fetch.fielddata.FieldDataFieldsFetchSubPhase; import org.elasticsearch.search.fetch.innerhits.InnerHitsFetchSubPhase; -import org.elasticsearch.search.fetch.matchedqueries.MatchedQueriesFetchSubPhase; -import org.elasticsearch.search.fetch.script.ScriptFieldsFetchSubPhase; import org.elasticsearch.search.fetch.source.FetchSourceContext; -import org.elasticsearch.search.fetch.source.FetchSourceSubPhase; -import org.elasticsearch.search.fetch.version.VersionFetchSubPhase; -import org.elasticsearch.search.highlight.HighlightPhase; import org.elasticsearch.search.internal.InternalSearchHit; import org.elasticsearch.search.internal.InternalSearchHitField; import org.elasticsearch.search.internal.InternalSearchHits; @@ -73,7 +65,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import static com.google.common.collect.Lists.newArrayList; import static org.elasticsearch.common.xcontent.XContentFactory.contentBuilder; /** @@ -146,7 +137,7 @@ public class FetchPhase implements SearchPhase { fieldNames.add(fieldType.names().indexName()); } else { if (extractFieldNames == null) { - extractFieldNames = newArrayList(); + extractFieldNames = new ArrayList<>(); } extractFieldNames.add(fieldName); } diff --git a/core/src/main/java/org/elasticsearch/search/fetch/fielddata/FieldDataFieldsContext.java b/core/src/main/java/org/elasticsearch/search/fetch/fielddata/FieldDataFieldsContext.java index 9f1bfc08ed7..c352e6a945e 100644 --- a/core/src/main/java/org/elasticsearch/search/fetch/fielddata/FieldDataFieldsContext.java +++ b/core/src/main/java/org/elasticsearch/search/fetch/fielddata/FieldDataFieldsContext.java @@ -18,9 +18,9 @@ */ package org.elasticsearch.search.fetch.fielddata; -import com.google.common.collect.Lists; import org.elasticsearch.search.fetch.FetchSubPhaseContext; +import java.util.ArrayList; import java.util.List; /** @@ -40,7 +40,7 @@ public class FieldDataFieldsContext extends FetchSubPhaseContext { } } - private List fields = Lists.newArrayList(); + private List fields = new ArrayList<>(); public FieldDataFieldsContext() { } diff --git a/core/src/main/java/org/elasticsearch/search/fetch/matchedqueries/MatchedQueriesFetchSubPhase.java b/core/src/main/java/org/elasticsearch/search/fetch/matchedqueries/MatchedQueriesFetchSubPhase.java index ac4dfa5f7e3..75e62d63f9d 100644 --- a/core/src/main/java/org/elasticsearch/search/fetch/matchedqueries/MatchedQueriesFetchSubPhase.java +++ b/core/src/main/java/org/elasticsearch/search/fetch/matchedqueries/MatchedQueriesFetchSubPhase.java @@ -19,8 +19,6 @@ package org.elasticsearch.search.fetch.matchedqueries; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Lists; - import org.apache.lucene.search.Query; import org.apache.lucene.search.Scorer; import org.apache.lucene.search.TwoPhaseIterator; @@ -33,6 +31,7 @@ import org.elasticsearch.search.internal.SearchContext; import org.elasticsearch.search.internal.SearchContext.Lifetime; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -63,7 +62,7 @@ public class MatchedQueriesFetchSubPhase implements FetchSubPhase { @Override public void hitExecute(SearchContext context, HitContext hitContext) { - List matchedQueries = Lists.newArrayListWithCapacity(2); + List matchedQueries = new ArrayList<>(2); try { addMatchedQueries(hitContext, context.parsedQuery().namedFilters(), matchedQueries); diff --git a/core/src/main/java/org/elasticsearch/search/fetch/script/ScriptFieldsContext.java b/core/src/main/java/org/elasticsearch/search/fetch/script/ScriptFieldsContext.java index 27a7b2a125a..9cf680d228a 100644 --- a/core/src/main/java/org/elasticsearch/search/fetch/script/ScriptFieldsContext.java +++ b/core/src/main/java/org/elasticsearch/search/fetch/script/ScriptFieldsContext.java @@ -19,9 +19,9 @@ package org.elasticsearch.search.fetch.script; -import com.google.common.collect.Lists; import org.elasticsearch.script.SearchScript; +import java.util.ArrayList; import java.util.List; /** @@ -53,7 +53,7 @@ public class ScriptFieldsContext { } } - private List fields = Lists.newArrayList(); + private List fields = new ArrayList<>(); public ScriptFieldsContext() { } diff --git a/core/src/main/java/org/elasticsearch/search/highlight/HighlightBuilder.java b/core/src/main/java/org/elasticsearch/search/highlight/HighlightBuilder.java index 79fb54c0ee3..c082859a0ed 100644 --- a/core/src/main/java/org/elasticsearch/search/highlight/HighlightBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/highlight/HighlightBuilder.java @@ -26,11 +26,10 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.index.query.QueryBuilder; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Map; -import static com.google.common.collect.Lists.newArrayList; - /** * A builder for search highlighting. Settings can control how large fields * are summarized to show only selected snippets ("fragments") containing search terms. @@ -87,7 +86,7 @@ public class HighlightBuilder implements ToXContent { */ public HighlightBuilder field(String name) { if (fields == null) { - fields = newArrayList(); + fields = new ArrayList<>(); } fields.add(new Field(name)); return this; @@ -103,7 +102,7 @@ public class HighlightBuilder implements ToXContent { */ public HighlightBuilder field(String name, int fragmentSize) { if (fields == null) { - fields = newArrayList(); + fields = new ArrayList<>(); } fields.add(new Field(name).fragmentSize(fragmentSize)); return this; @@ -120,7 +119,7 @@ public class HighlightBuilder implements ToXContent { */ public HighlightBuilder field(String name, int fragmentSize, int numberOfFragments) { if (fields == null) { - fields = newArrayList(); + fields = new ArrayList<>(); } fields.add(new Field(name).fragmentSize(fragmentSize).numOfFragments(numberOfFragments)); return this; @@ -138,7 +137,7 @@ public class HighlightBuilder implements ToXContent { */ public HighlightBuilder field(String name, int fragmentSize, int numberOfFragments, int fragmentOffset) { if (fields == null) { - fields = newArrayList(); + fields = new ArrayList<>(); } fields.add(new Field(name).fragmentSize(fragmentSize).numOfFragments(numberOfFragments) .fragmentOffset(fragmentOffset)); @@ -147,7 +146,7 @@ public class HighlightBuilder implements ToXContent { public HighlightBuilder field(Field field) { if (fields == null) { - fields = newArrayList(); + fields = new ArrayList<>(); } fields.add(field); return this; diff --git a/core/src/main/java/org/elasticsearch/search/highlight/HighlighterParseElement.java b/core/src/main/java/org/elasticsearch/search/highlight/HighlighterParseElement.java index 802122f648d..74723c7e3f5 100644 --- a/core/src/main/java/org/elasticsearch/search/highlight/HighlighterParseElement.java +++ b/core/src/main/java/org/elasticsearch/search/highlight/HighlighterParseElement.java @@ -19,9 +19,7 @@ package org.elasticsearch.search.highlight; -import com.google.common.collect.Lists; import com.google.common.collect.Sets; - import org.apache.lucene.search.vectorhighlight.SimpleBoundaryScanner; import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.xcontent.XContentParser; @@ -31,11 +29,10 @@ import org.elasticsearch.search.SearchParseException; import org.elasticsearch.search.internal.SearchContext; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Set; -import static com.google.common.collect.Lists.newArrayList; - /** *

  * highlight : {
@@ -78,7 +75,7 @@ public class HighlighterParseElement implements SearchParseElement {
     public SearchContextHighlight parse(XContentParser parser, IndexQueryParserService queryParserService) throws IOException {
         XContentParser.Token token;
         String topLevelFieldName = null;
-        final List> fieldsOptions = newArrayList();
+        final List> fieldsOptions = new ArrayList<>();
 
         final SearchContextHighlight.FieldOptions.Builder globalOptionsBuilder = new SearchContextHighlight.FieldOptions.Builder()
                 .preTags(DEFAULT_PRE_TAGS).postTags(DEFAULT_POST_TAGS).scoreOrdered(false).highlightFilter(false)
@@ -92,13 +89,13 @@ public class HighlighterParseElement implements SearchParseElement {
                 topLevelFieldName = parser.currentName();
             } else if (token == XContentParser.Token.START_ARRAY) {
                 if ("pre_tags".equals(topLevelFieldName) || "preTags".equals(topLevelFieldName)) {
-                    List preTagsList = Lists.newArrayList();
+                    List preTagsList = new ArrayList<>();
                     while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
                         preTagsList.add(parser.text());
                     }
                     globalOptionsBuilder.preTags(preTagsList.toArray(new String[preTagsList.size()]));
                 } else if ("post_tags".equals(topLevelFieldName) || "postTags".equals(topLevelFieldName)) {
-                    List postTagsList = Lists.newArrayList();
+                    List postTagsList = new ArrayList<>();
                     while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
                         postTagsList.add(parser.text());
                     }
@@ -184,7 +181,7 @@ public class HighlighterParseElement implements SearchParseElement {
             throw new IllegalArgumentException("Highlighter global preTags are set, but global postTags are not set");
         }
 
-        final List fields = Lists.newArrayList();
+        final List fields = new ArrayList<>();
         // now, go over and fill all fieldsOptions with default values from the global state
         for (final Tuple tuple : fieldsOptions) {
             fields.add(new SearchContextHighlight.Field(tuple.v1(), tuple.v2().merge(globalOptions).build()));
@@ -202,13 +199,13 @@ public class HighlighterParseElement implements SearchParseElement {
                 fieldName = parser.currentName();
             } else if (token == XContentParser.Token.START_ARRAY) {
                 if ("pre_tags".equals(fieldName) || "preTags".equals(fieldName)) {
-                    List preTagsList = Lists.newArrayList();
+                    List preTagsList = new ArrayList<>();
                     while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
                         preTagsList.add(parser.text());
                     }
                     fieldOptionsBuilder.preTags(preTagsList.toArray(new String[preTagsList.size()]));
                 } else if ("post_tags".equals(fieldName) || "postTags".equals(fieldName)) {
-                    List postTagsList = Lists.newArrayList();
+                    List postTagsList = new ArrayList<>();
                     while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
                         postTagsList.add(parser.text());
                     }
diff --git a/core/src/main/java/org/elasticsearch/search/internal/DefaultSearchContext.java b/core/src/main/java/org/elasticsearch/search/internal/DefaultSearchContext.java
index a3015b94bab..fdaac5e96aa 100644
--- a/core/src/main/java/org/elasticsearch/search/internal/DefaultSearchContext.java
+++ b/core/src/main/java/org/elasticsearch/search/internal/DefaultSearchContext.java
@@ -21,14 +21,21 @@ package org.elasticsearch.search.internal;
 
 import com.carrotsearch.hppc.ObjectObjectAssociativeContainer;
 import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-
 import org.apache.lucene.search.BooleanClause.Occur;
-import org.apache.lucene.search.*;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.Collector;
+import org.apache.lucene.search.ConstantScoreQuery;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.ScoreDoc;
+import org.apache.lucene.search.Sort;
 import org.apache.lucene.util.Counter;
 import org.elasticsearch.action.search.SearchType;
 import org.elasticsearch.cache.recycler.PageCacheRecycler;
-import org.elasticsearch.common.*;
+import org.elasticsearch.common.HasContext;
+import org.elasticsearch.common.HasContextAndHeaders;
+import org.elasticsearch.common.HasHeaders;
+import org.elasticsearch.common.Nullable;
+import org.elasticsearch.common.ParseFieldMatcher;
 import org.elasticsearch.common.collect.ImmutableOpenMap;
 import org.elasticsearch.common.lease.Releasables;
 import org.elasticsearch.common.lucene.search.Queries;
@@ -67,7 +74,12 @@ import org.elasticsearch.search.scan.ScanContext;
 import org.elasticsearch.search.suggest.SuggestionSearchContext;
 
 import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 /**
  *
@@ -567,7 +579,7 @@ public class DefaultSearchContext extends SearchContext {
     @Override
     public List fieldNames() {
         if (fieldNames == null) {
-            fieldNames = Lists.newArrayList();
+            fieldNames = new ArrayList<>();
         }
         return fieldNames;
     }
diff --git a/core/src/main/java/org/elasticsearch/search/internal/InternalSearchHit.java b/core/src/main/java/org/elasticsearch/search/internal/InternalSearchHit.java
index f2ed2676f7c..7a349cfbbb9 100644
--- a/core/src/main/java/org/elasticsearch/search/internal/InternalSearchHit.java
+++ b/core/src/main/java/org/elasticsearch/search/internal/InternalSearchHit.java
@@ -20,7 +20,6 @@
 package org.elasticsearch.search.internal;
 
 import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
 import org.apache.lucene.search.Explanation;
 import org.apache.lucene.util.BytesRef;
 import org.elasticsearch.ElasticsearchParseException;
@@ -47,6 +46,7 @@ import org.elasticsearch.search.internal.InternalSearchHits.StreamContext.ShardT
 import org.elasticsearch.search.lookup.SourceLookup;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -431,8 +431,8 @@ public class InternalSearchHit implements SearchHit {
 
     @Override
     public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
-        List metaFields = Lists.newArrayList();
-        List otherFields = Lists.newArrayList();
+        List metaFields = new ArrayList<>();
+        List otherFields = new ArrayList<>();
         if (fields != null && !fields.isEmpty()) {
             for (SearchHitField field : fields.values()) {
                 if (field.values().isEmpty()) {
diff --git a/core/src/main/java/org/elasticsearch/search/internal/SubSearchContext.java b/core/src/main/java/org/elasticsearch/search/internal/SubSearchContext.java
index a1a6fd0abff..4596375d119 100644
--- a/core/src/main/java/org/elasticsearch/search/internal/SubSearchContext.java
+++ b/core/src/main/java/org/elasticsearch/search/internal/SubSearchContext.java
@@ -19,7 +19,6 @@
 package org.elasticsearch.search.internal;
 
 import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
 import org.apache.lucene.search.Filter;
 import org.apache.lucene.search.Sort;
 import org.apache.lucene.util.Counter;
@@ -36,6 +35,7 @@ import org.elasticsearch.search.query.QuerySearchResult;
 import org.elasticsearch.search.rescore.RescoreSearchContext;
 import org.elasticsearch.search.suggest.SuggestionSearchContext;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -233,7 +233,7 @@ public class SubSearchContext extends FilteredSearchContext {
     @Override
     public List fieldNames() {
         if (fieldNames == null) {
-            fieldNames = Lists.newArrayList();
+            fieldNames = new ArrayList<>();
         }
         return fieldNames;
     }
diff --git a/core/src/main/java/org/elasticsearch/search/sort/SortParseElement.java b/core/src/main/java/org/elasticsearch/search/sort/SortParseElement.java
index 39da982e13f..2f4dcb37acb 100644
--- a/core/src/main/java/org/elasticsearch/search/sort/SortParseElement.java
+++ b/core/src/main/java/org/elasticsearch/search/sort/SortParseElement.java
@@ -20,8 +20,6 @@
 package org.elasticsearch.search.sort;
 
 import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-
 import org.apache.lucene.search.Filter;
 import org.apache.lucene.search.QueryWrapperFilter;
 import org.apache.lucene.search.Sort;
@@ -44,6 +42,7 @@ import org.elasticsearch.search.internal.SearchContext;
 import org.elasticsearch.search.internal.SubSearchContext;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -80,7 +79,7 @@ public class SortParseElement implements SearchParseElement {
     @Override
     public void parse(XContentParser parser, SearchContext context) throws Exception {
         XContentParser.Token token = parser.currentToken();
-        List sortFields = Lists.newArrayListWithCapacity(2);
+        List sortFields = new ArrayList<>(2);
         if (token == XContentParser.Token.START_ARRAY) {
             while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
                 if (token == XContentParser.Token.START_OBJECT) {
diff --git a/core/src/main/java/org/elasticsearch/search/suggest/context/CategoryContextMapping.java b/core/src/main/java/org/elasticsearch/search/suggest/context/CategoryContextMapping.java
index 975b42a0f01..ad075ac9b38 100644
--- a/core/src/main/java/org/elasticsearch/search/suggest/context/CategoryContextMapping.java
+++ b/core/src/main/java/org/elasticsearch/search/suggest/context/CategoryContextMapping.java
@@ -21,7 +21,6 @@ package org.elasticsearch.search.suggest.context;
 
 import com.google.common.base.Joiner;
 import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
 import org.apache.lucene.analysis.PrefixAnalyzer;
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.index.IndexableField;
@@ -36,7 +35,11 @@ import org.elasticsearch.index.mapper.ParseContext;
 import org.elasticsearch.index.mapper.ParseContext.Document;
 
 import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
 
 /**
  * The {@link CategoryContextMapping} is used to define a {@link ContextMapping} that
@@ -165,7 +168,7 @@ public class CategoryContextMapping extends ContextMapping {
         } else if (token == Token.VALUE_BOOLEAN) {
             return new FieldConfig(fieldName, null, Collections.singleton(parser.text()));
         } else if (token == Token.START_ARRAY) {
-            ArrayList values = Lists.newArrayList();
+            ArrayList values = new ArrayList<>();
             while((token = parser.nextToken()) != Token.END_ARRAY) {
                 values.add(parser.text());
             }
diff --git a/core/src/main/java/org/elasticsearch/search/suggest/context/ContextMapping.java b/core/src/main/java/org/elasticsearch/search/suggest/context/ContextMapping.java
index 43956c99dc9..30aaab69153 100644
--- a/core/src/main/java/org/elasticsearch/search/suggest/context/ContextMapping.java
+++ b/core/src/main/java/org/elasticsearch/search/suggest/context/ContextMapping.java
@@ -20,9 +20,7 @@
 package org.elasticsearch.search.suggest.context;
 
 import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
-
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.search.suggest.analyzing.XAnalyzingSuggester;
 import org.apache.lucene.util.automaton.Automata;
@@ -39,7 +37,12 @@ import org.elasticsearch.index.mapper.ParseContext;
 import org.elasticsearch.index.mapper.ParseContext.Document;
 
 import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedMap;
 
 /**
  * A {@link ContextMapping} is used t define a context that may used
@@ -300,7 +303,7 @@ public abstract class ContextMapping implements ToXContent {
                 }
             }
 
-            List queries = Lists.newArrayListWithExpectedSize(mappings.size());
+            List queries = new ArrayList<>(mappings.size());
             for (ContextMapping mapping : mappings.values()) {
                 queries.add(querySet.get(mapping.name));
             }
diff --git a/core/src/main/java/org/elasticsearch/search/suggest/context/GeolocationContextMapping.java b/core/src/main/java/org/elasticsearch/search/suggest/context/GeolocationContextMapping.java
index 22975ff83f3..a02868aa49e 100644
--- a/core/src/main/java/org/elasticsearch/search/suggest/context/GeolocationContextMapping.java
+++ b/core/src/main/java/org/elasticsearch/search/suggest/context/GeolocationContextMapping.java
@@ -20,7 +20,6 @@
 package org.elasticsearch.search.suggest.context;
 
 import com.carrotsearch.hppc.IntHashSet;
-import com.google.common.collect.Lists;
 import org.apache.lucene.analysis.PrefixAnalyzer.PrefixTokenFilter;
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.index.DocValuesType;
@@ -43,7 +42,13 @@ import org.elasticsearch.index.mapper.ParseContext.Document;
 import org.elasticsearch.index.mapper.geo.GeoPointFieldMapper;
 
 import java.io.IOException;
-import java.util.*;
+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.Map;
 
 /**
  * The {@link GeolocationContextMapping} allows to take GeoInfomation into account
@@ -231,7 +236,7 @@ public class GeolocationContextMapping extends ContextMapping {
                 }
             } else {
                 // otherwise it's a list of locations
-                ArrayList result = Lists.newArrayList();
+                ArrayList result = new ArrayList<>();
                 while (token != Token.END_ARRAY) {
                     result.add(GeoUtils.parseGeoPoint(parser).geohash());
                     token = parser.nextToken(); //infinite loop without this line
diff --git a/core/src/main/java/org/elasticsearch/search/warmer/IndexWarmersMetaData.java b/core/src/main/java/org/elasticsearch/search/warmer/IndexWarmersMetaData.java
index f2a996d2566..336f849172a 100644
--- a/core/src/main/java/org/elasticsearch/search/warmer/IndexWarmersMetaData.java
+++ b/core/src/main/java/org/elasticsearch/search/warmer/IndexWarmersMetaData.java
@@ -21,8 +21,6 @@ package org.elasticsearch.search.warmer;
 
 import com.google.common.base.Objects;
 import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-
 import org.elasticsearch.cluster.AbstractDiffable;
 import org.elasticsearch.cluster.metadata.IndexMetaData;
 import org.elasticsearch.common.Nullable;
@@ -31,7 +29,11 @@ import org.elasticsearch.common.bytes.BytesArray;
 import org.elasticsearch.common.bytes.BytesReference;
 import org.elasticsearch.common.io.stream.StreamInput;
 import org.elasticsearch.common.io.stream.StreamOutput;
-import org.elasticsearch.common.xcontent.*;
+import org.elasticsearch.common.xcontent.ToXContent;
+import org.elasticsearch.common.xcontent.XContentBuilder;
+import org.elasticsearch.common.xcontent.XContentFactory;
+import org.elasticsearch.common.xcontent.XContentParser;
+import org.elasticsearch.common.xcontent.XContentType;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -260,7 +262,7 @@ public class IndexWarmersMetaData extends AbstractDiffable
     @Override
     public IndexMetaData.Custom mergeWith(IndexMetaData.Custom other) {
         IndexWarmersMetaData second = (IndexWarmersMetaData) other;
-        List entries = Lists.newArrayList();
+        List entries = new ArrayList<>();
         entries.addAll(entries());
         for (Entry secondEntry : second.entries()) {
             boolean found = false;
diff --git a/core/src/main/java/org/elasticsearch/snapshots/RestoreService.java b/core/src/main/java/org/elasticsearch/snapshots/RestoreService.java
index d8c6fdc8b07..8738de1d948 100644
--- a/core/src/main/java/org/elasticsearch/snapshots/RestoreService.java
+++ b/core/src/main/java/org/elasticsearch/snapshots/RestoreService.java
@@ -25,15 +25,31 @@ import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
 import com.google.common.collect.ImmutableList;
 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.block.ClusterBlocks;
-import org.elasticsearch.cluster.metadata.*;
+import org.elasticsearch.cluster.ClusterChangedEvent;
+import org.elasticsearch.cluster.ClusterService;
+import org.elasticsearch.cluster.ClusterState;
+import org.elasticsearch.cluster.ClusterStateListener;
+import org.elasticsearch.cluster.ProcessedClusterStateUpdateTask;
+import org.elasticsearch.cluster.RestoreInProgress;
 import org.elasticsearch.cluster.RestoreInProgress.ShardRestoreStatus;
-import org.elasticsearch.cluster.routing.*;
+import org.elasticsearch.cluster.TimeoutClusterStateUpdateTask;
+import org.elasticsearch.cluster.block.ClusterBlocks;
+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;
@@ -50,20 +66,28 @@ import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.common.unit.TimeValue;
 import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
 import org.elasticsearch.index.shard.IndexShard;
-import org.elasticsearch.index.shard.StoreRecoveryService;
 import org.elasticsearch.index.shard.ShardId;
+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.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 com.google.common.collect.Lists.newArrayList;
 import static com.google.common.collect.Maps.newHashMap;
 import static com.google.common.collect.Sets.newHashSet;
 import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
@@ -350,7 +374,7 @@ public class RestoreService extends AbstractComponent implements ClusterStateLis
                     Settings normalizedChangeSettings = Settings.settingsBuilder().put(changeSettings).normalizePrefix(IndexMetaData.INDEX_SETTING_PREFIX).build();
                     IndexMetaData.Builder builder = IndexMetaData.builder(indexMetaData);
                     Map settingsMap = newHashMap(indexMetaData.settings().getAsMap());
-                    List simpleMatchPatterns = newArrayList();
+                    List simpleMatchPatterns = new ArrayList<>();
                     for (String ignoredSetting : ignoreSettings) {
                         if (!Regex.isSimpleMatchPattern(ignoredSetting)) {
                             if (UNREMOVABLE_SETTINGS.contains(ignoredSetting)) {
@@ -515,7 +539,7 @@ public class RestoreService extends AbstractComponent implements ClusterStateLis
                 final RestoreInProgress restore = currentState.custom(RestoreInProgress.TYPE);
                 if (restore != null) {
                     int changedCount = 0;
-                    final List entries = newArrayList();
+                    final List entries = new ArrayList<>();
                     for (RestoreInProgress.Entry entry : restore.entries()) {
                         Map shards = null;
 
@@ -577,7 +601,7 @@ public class RestoreService extends AbstractComponent implements ClusterStateLis
                         final RestoreInfo restoreInfo = entry.getValue().v1();
                         final Map shards = entry.getValue().v2();
                         RoutingTable routingTable = newState.getRoutingTable();
-                        final List waitForStarted = newArrayList();
+                        final List waitForStarted = new ArrayList<>();
                         for (Map.Entry shard : shards.entrySet()) {
                             if (shard.getValue().state() == RestoreInProgress.State.SUCCESS ) {
                                 ShardId shardId = shard.getKey();
@@ -711,7 +735,7 @@ public class RestoreService extends AbstractComponent implements ClusterStateLis
                     if (!shard.getValue().state().completed()) {
                         if (!event.state().metaData().hasIndex(shard.getKey().getIndex())) {
                             if (shardsToFail == null) {
-                                shardsToFail = newArrayList();
+                                shardsToFail = new ArrayList<>();
                             }
                             shardsToFail.add(shard.getKey());
                         }
diff --git a/core/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java b/core/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java
index 03b516f7cdc..b6083630f4f 100644
--- a/core/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java
+++ b/core/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java
@@ -21,7 +21,12 @@ package org.elasticsearch.snapshots;
 
 import com.google.common.collect.ImmutableMap;
 import org.elasticsearch.ExceptionsHelper;
-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.SnapshotsInProgress;
 import org.elasticsearch.cluster.metadata.SnapshotId;
 import org.elasticsearch.cluster.node.DiscoveryNode;
 import org.elasticsearch.common.component.AbstractLifecycleComponent;
@@ -43,10 +48,17 @@ import org.elasticsearch.index.snapshots.IndexShardSnapshotFailedException;
 import org.elasticsearch.index.snapshots.IndexShardSnapshotStatus;
 import org.elasticsearch.indices.IndicesService;
 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.List;
+import java.util.Map;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.Executor;
 import java.util.concurrent.TimeUnit;
@@ -54,7 +66,6 @@ import java.util.concurrent.locks.Condition;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
-import static com.google.common.collect.Lists.newArrayList;
 import static com.google.common.collect.Maps.newHashMap;
 import static org.elasticsearch.cluster.SnapshotsInProgress.completed;
 
@@ -506,7 +517,7 @@ public class SnapshotShardsService extends AbstractLifecycleComponent entries = newArrayList();
+                    final List entries = new ArrayList<>();
                     for (SnapshotsInProgress.Entry entry : snapshots.entries()) {
                         final Map shards = newHashMap();
                         boolean updated = false;
diff --git a/core/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java b/core/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java
index da796d1b502..79f6e863f6a 100644
--- a/core/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java
+++ b/core/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java
@@ -25,10 +25,21 @@ import org.apache.lucene.util.CollectionUtil;
 import org.elasticsearch.ExceptionsHelper;
 import org.elasticsearch.action.search.ShardSearchFailure;
 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.ProcessedClusterStateUpdateTask;
+import org.elasticsearch.cluster.SnapshotsInProgress;
 import org.elasticsearch.cluster.SnapshotsInProgress.ShardSnapshotStatus;
 import org.elasticsearch.cluster.SnapshotsInProgress.State;
-import org.elasticsearch.cluster.metadata.*;
+import org.elasticsearch.cluster.TimeoutClusterStateUpdateTask;
+import org.elasticsearch.cluster.metadata.IndexMetaData;
+import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
+import org.elasticsearch.cluster.metadata.MetaData;
+import org.elasticsearch.cluster.metadata.RepositoriesMetaData;
+import org.elasticsearch.cluster.metadata.SnapshotId;
 import org.elasticsearch.cluster.node.DiscoveryNode;
 import org.elasticsearch.cluster.node.DiscoveryNodes;
 import org.elasticsearch.cluster.routing.IndexRoutingTable;
@@ -51,10 +62,13 @@ import org.elasticsearch.search.SearchShardTarget;
 import org.elasticsearch.threadpool.ThreadPool;
 
 import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.CopyOnWriteArrayList;
 
-import static com.google.common.collect.Lists.newArrayList;
 import static com.google.common.collect.Sets.newHashSet;
 import static org.elasticsearch.cluster.SnapshotsInProgress.completed;
 
@@ -134,7 +148,7 @@ public class SnapshotsService extends AbstractLifecycleComponent snapshotList = newArrayList(snapshotSet);
+        ArrayList snapshotList = new ArrayList<>(snapshotSet);
         CollectionUtil.timSort(snapshotList);
         return ImmutableList.copyOf(snapshotList);
     }
@@ -146,7 +160,7 @@ public class SnapshotsService extends AbstractLifecycleComponent currentSnapshots(String repositoryName) {
-        List snapshotList = newArrayList();
+        List snapshotList = new ArrayList<>();
         List entries = currentSnapshots(repositoryName, null);
         for (SnapshotsInProgress.Entry entry : entries) {
             snapshotList.add(inProgressSnapshot(entry));
@@ -524,7 +538,7 @@ public class SnapshotsService extends AbstractLifecycleComponent entries = newArrayList();
+                    ArrayList entries = new ArrayList<>();
                     for (final SnapshotsInProgress.Entry snapshot : snapshots.entries()) {
                         SnapshotsInProgress.Entry updatedSnapshot = snapshot;
                         boolean snapshotChanged = false;
@@ -596,7 +610,7 @@ public class SnapshotsService extends AbstractLifecycleComponent entries = newArrayList();
+                        ArrayList entries = new ArrayList<>();
                         for (final SnapshotsInProgress.Entry snapshot : snapshots.entries()) {
                             SnapshotsInProgress.Entry updatedSnapshot = snapshot;
                             if (snapshot.state() == State.STARTED) {
@@ -763,8 +777,8 @@ public class SnapshotsService extends AbstractLifecycleComponent failures = newArrayList();
-                    ArrayList shardFailures = newArrayList();
+                    ArrayList failures = new ArrayList<>();
+                    ArrayList shardFailures = new ArrayList<>();
                     for (Map.Entry shardStatus : entry.shards().entrySet()) {
                         ShardId shardId = shardStatus.getKey();
                         ShardSnapshotStatus status = shardStatus.getValue();
@@ -797,7 +811,7 @@ public class SnapshotsService extends AbstractLifecycleComponent entries = newArrayList();
+                    ArrayList entries = new ArrayList<>();
                     for (SnapshotsInProgress.Entry entry : snapshots.entries()) {
                         if (entry.snapshotId().equals(snapshotId)) {
                             changed = true;
diff --git a/core/src/main/java/org/elasticsearch/tribe/TribeService.java b/core/src/main/java/org/elasticsearch/tribe/TribeService.java
index f2f21a1d1ca..3cc7b779019 100644
--- a/core/src/main/java/org/elasticsearch/tribe/TribeService.java
+++ b/core/src/main/java/org/elasticsearch/tribe/TribeService.java
@@ -20,11 +20,14 @@
 package org.elasticsearch.tribe;
 
 import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import org.elasticsearch.ElasticsearchException;
 import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
-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.ClusterStateNonMasterUpdateTask;
 import org.elasticsearch.cluster.block.ClusterBlock;
 import org.elasticsearch.cluster.block.ClusterBlockLevel;
 import org.elasticsearch.cluster.block.ClusterBlocks;
@@ -52,6 +55,7 @@ import java.util.EnumSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 /**
  * The tribe service holds a list of node clients connected to a list of tribe members, and uses their
@@ -115,7 +119,7 @@ public class TribeService extends AbstractLifecycleComponent {
     private final String onConflict;
     private final Set droppedIndices = ConcurrentCollections.newConcurrentSet();
 
-    private final List nodes = Lists.newCopyOnWriteArrayList();
+    private final List nodes = new CopyOnWriteArrayList<>();
 
     @Inject
     public TribeService(Settings settings, ClusterService clusterService, DiscoveryService discoveryService) {
diff --git a/core/src/test/java/org/elasticsearch/action/RejectionActionIT.java b/core/src/test/java/org/elasticsearch/action/RejectionActionIT.java
index ff094e09a4c..3c59f677f55 100644
--- a/core/src/test/java/org/elasticsearch/action/RejectionActionIT.java
+++ b/core/src/test/java/org/elasticsearch/action/RejectionActionIT.java
@@ -19,7 +19,6 @@
 
 package org.elasticsearch.action;
 
-import com.google.common.collect.Lists;
 import org.elasticsearch.ExceptionsHelper;
 import org.elasticsearch.action.search.SearchPhaseExecutionException;
 import org.elasticsearch.action.search.SearchResponse;
@@ -65,7 +64,7 @@ public class RejectionActionIT extends ESIntegTestCase {
 
         int numberOfAsyncOps = randomIntBetween(200, 700);
         final CountDownLatch latch = new CountDownLatch(numberOfAsyncOps);
-        final CopyOnWriteArrayList responses = Lists.newCopyOnWriteArrayList();
+        final CopyOnWriteArrayList responses = new CopyOnWriteArrayList<>();
         for (int i = 0; i < numberOfAsyncOps; i++) {
             client().prepareSearch("test")
                     .setSearchType(SearchType.QUERY_THEN_FETCH)
diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/template/put/MetaDataIndexTemplateServiceTests.java b/core/src/test/java/org/elasticsearch/action/admin/indices/template/put/MetaDataIndexTemplateServiceTests.java
index 0966212fe3a..091462897ab 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/indices/template/put/MetaDataIndexTemplateServiceTests.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/indices/template/put/MetaDataIndexTemplateServiceTests.java
@@ -19,7 +19,6 @@
 
 package org.elasticsearch.action.admin.indices.template.put;
 
-import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 import org.elasticsearch.Version;
@@ -33,12 +32,12 @@ import org.elasticsearch.indices.InvalidIndexTemplateException;
 import org.elasticsearch.test.ESTestCase;
 import org.junit.Test;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
 import static org.hamcrest.CoreMatchers.containsString;
 import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.Matchers.contains;
 
 public class MetaDataIndexTemplateServiceTests extends ESTestCase {
     @Test
@@ -89,7 +88,7 @@ public class MetaDataIndexTemplateServiceTests extends ESTestCase {
         );
         MetaDataIndexTemplateService service = new MetaDataIndexTemplateService(Settings.EMPTY, null, createIndexService, null);
 
-        final List throwables = Lists.newArrayList();
+        final List throwables = new ArrayList<>();
         service.putTemplate(request, new MetaDataIndexTemplateService.PutListener() {
             @Override
             public void onResponse(MetaDataIndexTemplateService.PutResponse response) {
diff --git a/core/src/test/java/org/elasticsearch/action/support/TransportActionFilterChainTests.java b/core/src/test/java/org/elasticsearch/action/support/TransportActionFilterChainTests.java
index 41fb1d919b0..b1fd92aa914 100644
--- a/core/src/test/java/org/elasticsearch/action/support/TransportActionFilterChainTests.java
+++ b/core/src/test/java/org/elasticsearch/action/support/TransportActionFilterChainTests.java
@@ -19,7 +19,6 @@
 
 package org.elasticsearch.action.support;
 
-import com.google.common.collect.Lists;
 import org.elasticsearch.ElasticsearchTimeoutException;
 import org.elasticsearch.action.ActionListener;
 import org.elasticsearch.action.ActionRequest;
@@ -30,7 +29,12 @@ import org.elasticsearch.test.ESTestCase;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutionException;
@@ -71,7 +75,7 @@ public class TransportActionFilterChainTests extends ESTestCase {
             }
         };
 
-        ArrayList actionFiltersByOrder = Lists.newArrayList(filters);
+        ArrayList actionFiltersByOrder = new ArrayList<>(filters);
         Collections.sort(actionFiltersByOrder, new Comparator() {
             @Override
             public int compare(ActionFilter o1, ActionFilter o2) {
@@ -79,7 +83,7 @@ public class TransportActionFilterChainTests extends ESTestCase {
             }
         });
 
-        List expectedActionFilters = Lists.newArrayList();
+        List expectedActionFilters = new ArrayList<>();
         boolean errorExpected = false;
         for (ActionFilter filter : actionFiltersByOrder) {
             RequestTestFilter testFilter = (RequestTestFilter) filter;
@@ -101,7 +105,7 @@ public class TransportActionFilterChainTests extends ESTestCase {
             assertThat("shouldn't get here if an error is not expected " + t.getMessage(), errorExpected, equalTo(true));
         }
 
-        List testFiltersByLastExecution = Lists.newArrayList();
+        List testFiltersByLastExecution = new ArrayList<>();
         for (ActionFilter actionFilter : actionFilters.filters()) {
             testFiltersByLastExecution.add((RequestTestFilter) actionFilter);
         }
@@ -112,7 +116,7 @@ public class TransportActionFilterChainTests extends ESTestCase {
             }
         });
 
-        ArrayList finalTestFilters = Lists.newArrayList();
+        ArrayList finalTestFilters = new ArrayList<>();
         for (ActionFilter filter : testFiltersByLastExecution) {
             RequestTestFilter testFilter = (RequestTestFilter) filter;
             finalTestFilters.add(testFilter);
@@ -153,7 +157,7 @@ public class TransportActionFilterChainTests extends ESTestCase {
             }
         };
 
-        ArrayList actionFiltersByOrder = Lists.newArrayList(filters);
+        ArrayList actionFiltersByOrder = new ArrayList<>(filters);
         Collections.sort(actionFiltersByOrder, new Comparator() {
             @Override
             public int compare(ActionFilter o1, ActionFilter o2) {
@@ -161,7 +165,7 @@ public class TransportActionFilterChainTests extends ESTestCase {
             }
         });
 
-        List expectedActionFilters = Lists.newArrayList();
+        List expectedActionFilters = new ArrayList<>();
         boolean errorExpected = false;
         for (ActionFilter filter : actionFiltersByOrder) {
             ResponseTestFilter testFilter = (ResponseTestFilter) filter;
@@ -183,7 +187,7 @@ public class TransportActionFilterChainTests extends ESTestCase {
             assertThat("shouldn't get here if an error is not expected " + t.getMessage(), errorExpected, equalTo(true));
         }
 
-        List testFiltersByLastExecution = Lists.newArrayList();
+        List testFiltersByLastExecution = new ArrayList<>();
         for (ActionFilter actionFilter : actionFilters.filters()) {
             testFiltersByLastExecution.add((ResponseTestFilter) actionFilter);
         }
@@ -194,7 +198,7 @@ public class TransportActionFilterChainTests extends ESTestCase {
             }
         });
 
-        ArrayList finalTestFilters = Lists.newArrayList();
+        ArrayList finalTestFilters = new ArrayList<>();
         for (ActionFilter filter : testFiltersByLastExecution) {
             ResponseTestFilter testFilter = (ResponseTestFilter) filter;
             finalTestFilters.add(testFilter);
diff --git a/core/src/test/java/org/elasticsearch/benchmark/search/aggregations/SubAggregationSearchCollectModeBenchmark.java b/core/src/test/java/org/elasticsearch/benchmark/search/aggregations/SubAggregationSearchCollectModeBenchmark.java
index 464c67ae84d..cd06b7b0579 100644
--- a/core/src/test/java/org/elasticsearch/benchmark/search/aggregations/SubAggregationSearchCollectModeBenchmark.java
+++ b/core/src/test/java/org/elasticsearch/benchmark/search/aggregations/SubAggregationSearchCollectModeBenchmark.java
@@ -20,8 +20,6 @@ package org.elasticsearch.benchmark.search.aggregations;
 
 import com.carrotsearch.hppc.ObjectScatterSet;
 import com.carrotsearch.randomizedtesting.generators.RandomStrings;
-import com.google.common.collect.Lists;
-
 import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
 import org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse;
 import org.elasticsearch.action.bulk.BulkRequestBuilder;
@@ -41,6 +39,7 @@ import org.elasticsearch.node.Node;
 import org.elasticsearch.search.aggregations.AggregationBuilders;
 import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
 import java.util.Random;
@@ -208,7 +207,7 @@ public class SubAggregationSearchCollectModeBenchmark {
         COUNT = client.prepareCount().setQuery(matchAllQuery()).execute().actionGet().getCount();
         System.out.println("--> Number of docs in index: " + COUNT);
 
-        List stats = Lists.newArrayList();
+        List stats = new ArrayList<>();
         stats.add(runTest("0000", new SubAggCollectionMode[] {SubAggCollectionMode.DEPTH_FIRST,SubAggCollectionMode.DEPTH_FIRST, SubAggCollectionMode.DEPTH_FIRST, SubAggCollectionMode.DEPTH_FIRST}));
         stats.add(runTest("0001", new SubAggCollectionMode[] {SubAggCollectionMode.DEPTH_FIRST,SubAggCollectionMode.DEPTH_FIRST, SubAggCollectionMode.DEPTH_FIRST, SubAggCollectionMode.BREADTH_FIRST}));
         stats.add(runTest("0010", new SubAggCollectionMode[] {SubAggCollectionMode.DEPTH_FIRST,SubAggCollectionMode.DEPTH_FIRST, SubAggCollectionMode.BREADTH_FIRST, SubAggCollectionMode.DEPTH_FIRST}));
diff --git a/core/src/test/java/org/elasticsearch/benchmark/search/aggregations/TermsAggregationSearchBenchmark.java b/core/src/test/java/org/elasticsearch/benchmark/search/aggregations/TermsAggregationSearchBenchmark.java
index e278feb3644..7240ee308f2 100644
--- a/core/src/test/java/org/elasticsearch/benchmark/search/aggregations/TermsAggregationSearchBenchmark.java
+++ b/core/src/test/java/org/elasticsearch/benchmark/search/aggregations/TermsAggregationSearchBenchmark.java
@@ -20,8 +20,6 @@ package org.elasticsearch.benchmark.search.aggregations;
 
 import com.carrotsearch.hppc.ObjectScatterSet;
 import com.carrotsearch.randomizedtesting.generators.RandomStrings;
-import com.google.common.collect.Lists;
-
 import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
 import org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse;
 import org.elasticsearch.action.bulk.BulkRequestBuilder;
@@ -42,6 +40,7 @@ import org.elasticsearch.node.Node;
 import org.elasticsearch.search.aggregations.AggregationBuilders;
 import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
 import java.util.Random;
@@ -235,7 +234,7 @@ public class TermsAggregationSearchBenchmark {
         System.out.println("--> Number of docs in index: " + COUNT);
 
 
-        List stats = Lists.newArrayList();
+        List stats = new ArrayList<>();
         stats.add(terms("terms_agg_s", Method.AGGREGATION, "s_value", null));
         stats.add(terms("terms_agg_s_dv", Method.AGGREGATION, "s_value_dv", null));
         stats.add(terms("terms_agg_map_s", Method.AGGREGATION, "s_value", "map"));
diff --git a/core/src/test/java/org/elasticsearch/benchmark/search/aggregations/TimeDataHistogramAggregationBenchmark.java b/core/src/test/java/org/elasticsearch/benchmark/search/aggregations/TimeDataHistogramAggregationBenchmark.java
index 96203ccba19..5b3984d19cb 100644
--- a/core/src/test/java/org/elasticsearch/benchmark/search/aggregations/TimeDataHistogramAggregationBenchmark.java
+++ b/core/src/test/java/org/elasticsearch/benchmark/search/aggregations/TimeDataHistogramAggregationBenchmark.java
@@ -19,8 +19,6 @@
 
 package org.elasticsearch.benchmark.search.aggregations;
 
-import com.google.common.collect.Lists;
-
 import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
 import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse;
 import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags;
@@ -44,6 +42,7 @@ import org.elasticsearch.script.ScriptService.ScriptType;
 import org.elasticsearch.search.aggregations.AggregationBuilders;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
@@ -163,7 +162,7 @@ public class TimeDataHistogramAggregationBenchmark {
         setMapping(ACCEPTABLE_OVERHEAD_RATIO, MEMORY_FORMAT);
         warmUp("hist_l", "l_value", MATCH_PERCENTAGE);
 
-        List stats = Lists.newArrayList();
+        List stats = new ArrayList<>();
         stats.add(measureAgg("hist_l", "l_value", MATCH_PERCENTAGE));
 
         NodesStatsResponse nodeStats = client.admin().cluster().prepareNodesStats(nodes[0].settings().get("name")).clear()
diff --git a/core/src/test/java/org/elasticsearch/bwcompat/RestoreBackwardsCompatIT.java b/core/src/test/java/org/elasticsearch/bwcompat/RestoreBackwardsCompatIT.java
index 2130ea57267..14bcfc79076 100644
--- a/core/src/test/java/org/elasticsearch/bwcompat/RestoreBackwardsCompatIT.java
+++ b/core/src/test/java/org/elasticsearch/bwcompat/RestoreBackwardsCompatIT.java
@@ -43,18 +43,15 @@ import java.net.URISyntaxException;
 import java.nio.file.DirectoryStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
 import java.util.SortedSet;
 import java.util.TreeSet;
 
-import static com.google.common.collect.Lists.newArrayList;
 import static org.elasticsearch.common.settings.Settings.settingsBuilder;
 import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.greaterThan;
-import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.*;
 
 @ClusterScope(scope = Scope.TEST)
 public class RestoreBackwardsCompatIT extends AbstractSnapshotIntegTestCase {
@@ -144,7 +141,7 @@ public class RestoreBackwardsCompatIT extends AbstractSnapshotIntegTestCase {
     }
 
     private List listRepoVersions(String prefix) throws Exception {
-        List repoVersions = newArrayList();
+        List repoVersions = new ArrayList<>();
         Path repoFiles = reposRoot();
         try (DirectoryStream stream = Files.newDirectoryStream(repoFiles, prefix + "-*.zip")) {
             for (Path entry : stream) {
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/AddIncrementallyTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/AddIncrementallyTests.java
index b24744179d6..a35e9f4af43 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/AddIncrementallyTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/AddIncrementallyTests.java
@@ -20,7 +20,6 @@
 package org.elasticsearch.cluster.routing.allocation;
 
 import com.carrotsearch.hppc.cursors.ObjectCursor;
-import com.google.common.collect.Lists;
 import org.elasticsearch.Version;
 import org.elasticsearch.cluster.ClusterState;
 import org.elasticsearch.cluster.metadata.IndexMetaData;
@@ -34,6 +33,7 @@ import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllo
 import org.elasticsearch.common.logging.ESLogger;
 import org.elasticsearch.common.logging.Loggers;
 import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.common.util.CollectionUtils;
 import org.elasticsearch.test.ESAllocationTestCase;
 import org.hamcrest.Matcher;
 import org.hamcrest.Matchers;
@@ -390,7 +390,7 @@ public class AddIncrementallyTests extends ESAllocationTestCase {
     private ClusterState removeNodes(ClusterState clusterState, AllocationService service, int numNodes) {
         logger.info("Removing [{}] nodes", numNodes);
         DiscoveryNodes.Builder nodes = DiscoveryNodes.builder(clusterState.nodes());
-        ArrayList discoveryNodes = Lists.newArrayList(clusterState.nodes());
+        ArrayList discoveryNodes = CollectionUtils.iterableAsArrayList(clusterState.nodes());
         Collections.shuffle(discoveryNodes, getRandom());
         for (DiscoveryNode node : discoveryNodes) {
             nodes.remove(node.id());
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/SingleShardNoReplicasRoutingTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/SingleShardNoReplicasRoutingTests.java
index b2bd29d21b9..a6b0e414f59 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/SingleShardNoReplicasRoutingTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/SingleShardNoReplicasRoutingTests.java
@@ -25,20 +25,20 @@ import org.elasticsearch.cluster.metadata.IndexMetaData;
 import org.elasticsearch.cluster.metadata.MetaData;
 import org.elasticsearch.cluster.node.DiscoveryNode;
 import org.elasticsearch.cluster.node.DiscoveryNodes;
-import org.elasticsearch.cluster.routing.ShardRouting;
 import org.elasticsearch.cluster.routing.RoutingNode;
 import org.elasticsearch.cluster.routing.RoutingNodes;
 import org.elasticsearch.cluster.routing.RoutingTable;
+import org.elasticsearch.cluster.routing.ShardRouting;
 import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllocationDecider;
 import org.elasticsearch.common.logging.ESLogger;
 import org.elasticsearch.common.logging.Loggers;
 import org.elasticsearch.test.ESAllocationTestCase;
 import org.junit.Test;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
 
-import static com.google.common.collect.Lists.newArrayList;
 import static com.google.common.collect.Sets.newHashSet;
 import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
 import static org.elasticsearch.cluster.routing.allocation.RoutingNodesUtils.numberOfShardsOfType;
@@ -239,7 +239,7 @@ public class SingleShardNoReplicasRoutingTests extends ESAllocationTestCase {
 
         logger.info("Adding " + (numberOfIndices / 2) + " nodes");
         DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder();
-        List nodes = newArrayList();
+        List nodes = new ArrayList<>();
         for (int i = 0; i < (numberOfIndices / 2); i++) {
             nodesBuilder.put(newNode("node" + i));
         }
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/MockDiskUsagesIT.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/MockDiskUsagesIT.java
index 35b5ffefae3..e5a14d29a73 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/MockDiskUsagesIT.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/MockDiskUsagesIT.java
@@ -23,7 +23,11 @@ import org.elasticsearch.Version;
 import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
 import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse;
 import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
-import org.elasticsearch.cluster.*;
+import org.elasticsearch.cluster.ClusterInfo;
+import org.elasticsearch.cluster.ClusterInfoService;
+import org.elasticsearch.cluster.DiskUsage;
+import org.elasticsearch.cluster.InternalClusterInfoService;
+import org.elasticsearch.cluster.MockInternalClusterInfoService;
 import org.elasticsearch.cluster.node.DiscoveryNode;
 import org.elasticsearch.cluster.routing.RoutingNode;
 import org.elasticsearch.common.settings.Settings;
@@ -32,16 +36,14 @@ import org.elasticsearch.monitor.fs.FsInfo;
 import org.elasticsearch.test.ESIntegTestCase;
 import org.junit.Test;
 
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
-import static com.google.common.collect.Lists.newArrayList;
 import static com.google.common.collect.Maps.newHashMap;
 import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.greaterThan;
-import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.*;
 
 @ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0)
 public class MockDiskUsagesIT extends ESIntegTestCase {
@@ -100,7 +102,7 @@ public class MockDiskUsagesIT extends ESIntegTestCase {
             }
         });
 
-        final List realNodeNames = newArrayList();
+        final List realNodeNames = new ArrayList<>();
         ClusterStateResponse resp = client().admin().cluster().prepareState().get();
         Iterator iter = resp.getState().getRoutingNodes().iterator();
         while (iter.hasNext()) {
diff --git a/core/src/test/java/org/elasticsearch/cluster/settings/SettingsFilteringIT.java b/core/src/test/java/org/elasticsearch/cluster/settings/SettingsFilteringIT.java
index 32551a4fe58..c4bd92e5084 100644
--- a/core/src/test/java/org/elasticsearch/cluster/settings/SettingsFilteringIT.java
+++ b/core/src/test/java/org/elasticsearch/cluster/settings/SettingsFilteringIT.java
@@ -33,7 +33,6 @@ import org.junit.Test;
 import java.util.Collection;
 import java.util.Collections;
 
-import static com.google.common.collect.Lists.newArrayList;
 import static org.elasticsearch.test.ESIntegTestCase.Scope.SUITE;
 import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
 import static org.hamcrest.Matchers.equalTo;
diff --git a/core/src/test/java/org/elasticsearch/common/lucene/index/FreqTermsEnumTests.java b/core/src/test/java/org/elasticsearch/common/lucene/index/FreqTermsEnumTests.java
index 49ca12e0f84..63e0d50f39b 100644
--- a/core/src/test/java/org/elasticsearch/common/lucene/index/FreqTermsEnumTests.java
+++ b/core/src/test/java/org/elasticsearch/common/lucene/index/FreqTermsEnumTests.java
@@ -19,10 +19,8 @@
 
 package org.elasticsearch.common.lucene.index;
 
-import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
-
 import org.apache.lucene.analysis.core.KeywordAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
@@ -49,13 +47,13 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import static com.carrotsearch.randomizedtesting.RandomizedTest.randomInt;
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.is;
 
@@ -143,7 +141,7 @@ public class FreqTermsEnumTests extends ESTestCase {
 
         // now go over each doc, build the relevant references and filter
         reader = DirectoryReader.open(iw, true);
-        List filterTerms = Lists.newArrayList();
+        List filterTerms = new ArrayList<>();
         for (int docId = 0; docId < reader.maxDoc(); docId++) {
             Document doc = reader.document(docId);
             addFreqs(doc, referenceAll);
@@ -207,7 +205,7 @@ public class FreqTermsEnumTests extends ESTestCase {
     private void assertAgainstReference(FreqTermsEnum termsEnum, Map reference, boolean docFreq, boolean totalTermFreq) throws Exception {
         int cycles = randomIntBetween(1, 5);
         for (int i = 0; i < cycles; i++) {
-            List terms = Lists.newArrayList(Arrays.asList(this.terms));
+            List terms = new ArrayList<>(Arrays.asList(this.terms));
 
            Collections.shuffle(terms, getRandom());
             for (String term : terms) {
diff --git a/core/src/test/java/org/elasticsearch/common/util/CollectionUtilsTests.java b/core/src/test/java/org/elasticsearch/common/util/CollectionUtilsTests.java
index 09c4b800568..d277e3a240c 100644
--- a/core/src/test/java/org/elasticsearch/common/util/CollectionUtilsTests.java
+++ b/core/src/test/java/org/elasticsearch/common/util/CollectionUtilsTests.java
@@ -28,8 +28,16 @@ import org.apache.lucene.util.Counter;
 import org.elasticsearch.test.ESTestCase;
 import org.junit.Test;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.SortedSet;
+import java.util.TreeSet;
 
+import static org.elasticsearch.common.util.CollectionUtils.eagerPartition;
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.is;
 
@@ -129,4 +137,51 @@ public class CollectionUtilsTests extends ESTestCase {
 
     }
 
+    public void testEmptyPartition() {
+        assertEquals(
+                Collections.emptyList(),
+                eagerPartition(Collections.emptyList(), 1)
+        );
+    }
+
+    public void testSimplePartition() {
+        assertEquals(
+                Arrays.asList(
+                        Arrays.asList(1, 2),
+                        Arrays.asList(3, 4),
+                        Arrays.asList(5)
+                ),
+                eagerPartition(Arrays.asList(1, 2, 3, 4, 5), 2)
+        );
+    }
+
+    public void testSingletonPartition() {
+        assertEquals(
+                Arrays.asList(
+                        Arrays.asList(1),
+                        Arrays.asList(2),
+                        Arrays.asList(3),
+                        Arrays.asList(4),
+                        Arrays.asList(5)
+                ),
+                eagerPartition(Arrays.asList(1, 2, 3, 4, 5), 1)
+        );
+    }
+
+    public void testOversizedPartition() {
+        assertEquals(
+                Arrays.asList(Arrays.asList(1, 2, 3, 4, 5)),
+                eagerPartition(Arrays.asList(1, 2, 3, 4, 5), 15)
+        );
+    }
+
+    public void testPerfectPartition() {
+        assertEquals(
+                Arrays.asList(
+                        Arrays.asList(1, 2, 3, 4, 5, 6),
+                        Arrays.asList(7, 8, 9, 10, 11, 12)
+                ),
+                eagerPartition(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), 6)
+        );
+    }
 }
diff --git a/core/src/test/java/org/elasticsearch/common/util/concurrent/PrioritizedExecutorsTests.java b/core/src/test/java/org/elasticsearch/common/util/concurrent/PrioritizedExecutorsTests.java
index ef1c0a9d7ec..520b619caaa 100644
--- a/core/src/test/java/org/elasticsearch/common/util/concurrent/PrioritizedExecutorsTests.java
+++ b/core/src/test/java/org/elasticsearch/common/util/concurrent/PrioritizedExecutorsTests.java
@@ -18,7 +18,6 @@
  */
 package org.elasticsearch.common.util.concurrent;
 
-import com.google.common.collect.Lists;
 import org.elasticsearch.common.Priority;
 import org.elasticsearch.common.unit.TimeValue;
 import org.elasticsearch.test.ESTestCase;
@@ -26,9 +25,16 @@ import org.elasticsearch.threadpool.ThreadPool;
 import org.junit.Test;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
-import java.util.concurrent.*;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.PriorityBlockingQueue;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import static org.hamcrest.Matchers.equalTo;
@@ -42,7 +48,7 @@ public class PrioritizedExecutorsTests extends ESTestCase {
     @Test
     public void testPriorityQueue() throws Exception {
         PriorityBlockingQueue queue = new PriorityBlockingQueue<>();
-        List priorities = Lists.newArrayList(Priority.values());
+        List priorities = Arrays.asList(Priority.values());
         Collections.shuffle(priorities);
 
         for (Priority priority : priorities) {
diff --git a/core/src/test/java/org/elasticsearch/common/xcontent/builder/XContentBuilderTests.java b/core/src/test/java/org/elasticsearch/common/xcontent/builder/XContentBuilderTests.java
index d273f7c22b6..9089ec51ba9 100644
--- a/core/src/test/java/org/elasticsearch/common/xcontent/builder/XContentBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/common/xcontent/builder/XContentBuilderTests.java
@@ -19,19 +19,31 @@
 
 package org.elasticsearch.common.xcontent.builder;
 
-import com.google.common.collect.Lists;
-
 import org.elasticsearch.common.bytes.BytesArray;
 import org.elasticsearch.common.io.FastCharArrayWriter;
 import org.elasticsearch.common.io.PathUtils;
 import org.elasticsearch.common.io.stream.BytesStreamOutput;
-import org.elasticsearch.common.xcontent.*;
+import org.elasticsearch.common.xcontent.XContentBuilder;
+import org.elasticsearch.common.xcontent.XContentBuilderString;
+import org.elasticsearch.common.xcontent.XContentFactory;
+import org.elasticsearch.common.xcontent.XContentGenerator;
+import org.elasticsearch.common.xcontent.XContentParser;
+import org.elasticsearch.common.xcontent.XContentType;
 import org.elasticsearch.test.ESTestCase;
 import org.junit.Test;
 
 import java.io.IOException;
 import java.nio.file.Path;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.TimeZone;
 
 import static org.elasticsearch.common.xcontent.XContentBuilder.FieldCaseConversion.CAMELCASE;
 import static org.elasticsearch.common.xcontent.XContentBuilder.FieldCaseConversion.UNDERSCORE;
@@ -142,7 +154,7 @@ public class XContentBuilderTests extends ESTestCase {
     @Test
     public void testOverloadedList() throws Exception {
         XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
-        builder.startObject().field("test", Lists.newArrayList("1", "2")).endObject();
+        builder.startObject().field("test", Arrays.asList("1", "2")).endObject();
         assertThat(builder.string(), equalTo("{\"test\":[\"1\",\"2\"]}"));
     }
 
diff --git a/core/src/test/java/org/elasticsearch/http/netty/NettyHttpServerPipeliningTest.java b/core/src/test/java/org/elasticsearch/http/netty/NettyHttpServerPipeliningTest.java
index de923f5d3f9..e3a5861ea62 100644
--- a/core/src/test/java/org/elasticsearch/http/netty/NettyHttpServerPipeliningTest.java
+++ b/core/src/test/java/org/elasticsearch/http/netty/NettyHttpServerPipeliningTest.java
@@ -19,27 +19,34 @@
 package org.elasticsearch.http.netty;
 
 import com.google.common.base.Charsets;
-import com.google.common.collect.Lists;
-
+import org.elasticsearch.cache.recycler.MockPageCacheRecycler;
 import org.elasticsearch.common.network.NetworkService;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.common.transport.InetSocketTransportAddress;
+import org.elasticsearch.common.util.MockBigArrays;
 import org.elasticsearch.http.HttpServerTransport;
 import org.elasticsearch.http.netty.pipelining.OrderedDownstreamChannelEvent;
 import org.elasticsearch.http.netty.pipelining.OrderedUpstreamMessageEvent;
 import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
 import org.elasticsearch.test.ESTestCase;
-import org.elasticsearch.common.util.MockBigArrays;
-import org.elasticsearch.cache.recycler.MockPageCacheRecycler;
 import org.elasticsearch.threadpool.ThreadPool;
 import org.jboss.netty.buffer.ChannelBuffer;
 import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.*;
-import org.jboss.netty.handler.codec.http.*;
+import org.jboss.netty.channel.ChannelHandlerContext;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.channel.ChannelPipelineFactory;
+import org.jboss.netty.channel.ExceptionEvent;
+import org.jboss.netty.channel.MessageEvent;
+import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
+import org.jboss.netty.handler.codec.http.DefaultHttpResponse;
+import org.jboss.netty.handler.codec.http.HttpRequest;
+import org.jboss.netty.handler.codec.http.HttpResponse;
+import org.jboss.netty.handler.codec.http.QueryStringDecoder;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
@@ -108,7 +115,7 @@ public class NettyHttpServerPipeliningTest extends ESTestCase {
         List requests = Arrays.asList("/slow?sleep=1000", "/firstfast", "/secondfast", "/thirdfast", "/slow?sleep=500");
         try (NettyHttpClient nettyHttpClient = new NettyHttpClient()) {
             Collection responses = nettyHttpClient.sendRequests(transportAddress.address(), requests.toArray(new String[]{}));
-            List responseBodies = Lists.newArrayList(returnHttpResponseBodies(responses));
+            List responseBodies = new ArrayList<>(returnHttpResponseBodies(responses));
             // we cannot be sure about the order of the fast requests, but the slow ones should have to be last
             assertThat(responseBodies, hasSize(5));
             assertThat(responseBodies.get(3), is("/slow?sleep=500"));
diff --git a/core/src/test/java/org/elasticsearch/http/netty/NettyPipeliningDisabledIT.java b/core/src/test/java/org/elasticsearch/http/netty/NettyPipeliningDisabledIT.java
index 55879671993..1d968b75b73 100644
--- a/core/src/test/java/org/elasticsearch/http/netty/NettyPipeliningDisabledIT.java
+++ b/core/src/test/java/org/elasticsearch/http/netty/NettyPipeliningDisabledIT.java
@@ -18,7 +18,6 @@
  */
 package org.elasticsearch.http.netty;
 
-import com.google.common.collect.Lists;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.common.transport.InetSocketTransportAddress;
 import org.elasticsearch.http.HttpServerTransport;
@@ -27,6 +26,7 @@ import org.elasticsearch.test.ESIntegTestCase;
 import org.jboss.netty.handler.codec.http.HttpResponse;
 import org.junit.Test;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
@@ -36,7 +36,8 @@ import static org.elasticsearch.common.settings.Settings.settingsBuilder;
 import static org.elasticsearch.http.netty.NettyHttpClient.returnOpaqueIds;
 import static org.elasticsearch.test.ESIntegTestCase.ClusterScope;
 import static org.elasticsearch.test.ESIntegTestCase.Scope;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.hasSize;
 
 /**
  *
@@ -61,7 +62,7 @@ public class NettyPipeliningDisabledIT extends ESIntegTestCase {
             Collection responses = nettyHttpClient.sendRequests(inetSocketTransportAddress.address(), requests.toArray(new String[]{}));
             assertThat(responses, hasSize(requests.size()));
 
-            List opaqueIds = Lists.newArrayList(returnOpaqueIds(responses));
+            List opaqueIds = new ArrayList<>(returnOpaqueIds(responses));
 
             assertResponsesOutOfOrder(opaqueIds);
         }
diff --git a/core/src/test/java/org/elasticsearch/index/IndexWithShadowReplicasIT.java b/core/src/test/java/org/elasticsearch/index/IndexWithShadowReplicasIT.java
index ee85af93215..03100efde0a 100644
--- a/core/src/test/java/org/elasticsearch/index/IndexWithShadowReplicasIT.java
+++ b/core/src/test/java/org/elasticsearch/index/IndexWithShadowReplicasIT.java
@@ -44,11 +44,15 @@ import org.elasticsearch.snapshots.SnapshotState;
 import org.elasticsearch.test.ESIntegTestCase;
 import org.elasticsearch.test.InternalTestCluster;
 import org.elasticsearch.test.transport.MockTransportService;
-import org.elasticsearch.transport.*;
+import org.elasticsearch.transport.TransportException;
+import org.elasticsearch.transport.TransportRequest;
+import org.elasticsearch.transport.TransportRequestOptions;
+import org.elasticsearch.transport.TransportService;
 import org.junit.Test;
 
 import java.io.IOException;
 import java.nio.file.Path;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.CountDownLatch;
@@ -57,7 +61,6 @@ import java.util.concurrent.Future;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import static com.google.common.collect.Lists.newArrayList;
 import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
 import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
 import static org.hamcrest.Matchers.*;
@@ -570,7 +573,7 @@ public class IndexWithShadowReplicasIT extends ESIntegTestCase {
         ensureGreen(IDX);
 
         int docCount = randomIntBetween(10, 100);
-        List builders = newArrayList();
+        List builders = new ArrayList<>();
         for (int i = 0; i < docCount; i++) {
             builders.add(client().prepareIndex(IDX, "doc", i + "").setSource("foo", "bar"));
         }
diff --git a/core/src/test/java/org/elasticsearch/index/fielddata/DuelFieldDataTests.java b/core/src/test/java/org/elasticsearch/index/fielddata/DuelFieldDataTests.java
index 3dee75021dc..9a4250f188e 100644
--- a/core/src/test/java/org/elasticsearch/index/fielddata/DuelFieldDataTests.java
+++ b/core/src/test/java/org/elasticsearch/index/fielddata/DuelFieldDataTests.java
@@ -20,12 +20,15 @@ package org.elasticsearch.index.fielddata;
 
 import com.carrotsearch.randomizedtesting.generators.RandomPicks;
 import com.carrotsearch.randomizedtesting.generators.RandomStrings;
-import com.google.common.collect.Lists;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.SortedSetDocValuesField;
 import org.apache.lucene.document.StringField;
-import org.apache.lucene.index.*;
+import org.apache.lucene.index.CompositeReaderContext;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.LeafReaderContext;
+import org.apache.lucene.index.RandomAccessOrds;
+import org.apache.lucene.index.SortedNumericDocValues;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.BytesRefBuilder;
 import org.apache.lucene.util.English;
@@ -40,8 +43,16 @@ import org.elasticsearch.index.mapper.DocumentMapper;
 import org.elasticsearch.index.mapper.ParsedDocument;
 import org.junit.Test;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Random;
+import java.util.Set;
 
 import static org.hamcrest.Matchers.*;
 
@@ -578,8 +589,8 @@ public class DuelFieldDataTests extends AbstractFieldDataTests {
             final int numValues = leftValues.count();
             rightValues.setDocument(i);;
             assertEquals(numValues, rightValues.count());
-            List leftPoints = Lists.newArrayList();
-            List rightPoints = Lists.newArrayList();
+            List leftPoints = new ArrayList<>();
+            List rightPoints = new ArrayList<>();
             for (int j = 0; j < numValues; ++j) {
                 GeoPoint l = leftValues.valueAt(j);
                 leftPoints.add(new GeoPoint(l.getLat(), l.getLon()));
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/FieldTypeLookupTests.java b/core/src/test/java/org/elasticsearch/index/mapper/FieldTypeLookupTests.java
index bfefe436fa7..5ea01ee244e 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/FieldTypeLookupTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/FieldTypeLookupTests.java
@@ -20,14 +20,13 @@
 package org.elasticsearch.index.mapper;
 
 import com.google.common.collect.Iterators;
-import com.google.common.collect.Lists;
 import org.elasticsearch.Version;
 import org.elasticsearch.cluster.metadata.IndexMetaData;
 import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.index.mapper.core.StringFieldMapper;
 import org.elasticsearch.test.ESTestCase;
 
 import java.io.IOException;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
@@ -231,7 +230,7 @@ public class FieldTypeLookupTests extends ESTestCase {
     }
 
     static List newList(FieldMapper... mapper) {
-        return Lists.newArrayList(mapper);
+        return Arrays.asList(mapper);
     }
 
     // this sucks how much must be overridden just do get a dummy field mapper...
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/date/DateBackwardsCompatibilityTests.java b/core/src/test/java/org/elasticsearch/index/mapper/date/DateBackwardsCompatibilityTests.java
index b6ecb24d42a..4e906ae82fa 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/date/DateBackwardsCompatibilityTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/date/DateBackwardsCompatibilityTests.java
@@ -19,7 +19,6 @@
 
 package org.elasticsearch.index.mapper.date;
 
-import com.google.common.collect.Lists;
 import org.elasticsearch.Version;
 import org.elasticsearch.action.index.IndexResponse;
 import org.elasticsearch.action.search.SearchResponse;
@@ -33,6 +32,7 @@ import org.elasticsearch.index.query.QueryBuilders;
 import org.elasticsearch.test.ESSingleNodeTestCase;
 import org.junit.Before;
 
+import java.util.Arrays;
 import java.util.List;
 
 import static org.elasticsearch.common.settings.Settings.settingsBuilder;
@@ -84,7 +84,7 @@ public class DateBackwardsCompatibilityTests extends ESSingleNodeTestCase {
 
     public void testThatPre2xSupportsUnixTimestampsInAnyDateFormat() throws Exception {
         long dateInMillis = 1435073872l * 1000; // Tue Jun 23 17:37:52 CEST 2015
-        List dateFormats = Lists.newArrayList("dateOptionalTime", "weekDate", "tTime", "ordinalDate", "hourMinuteSecond", "hourMinute");
+        List dateFormats = Arrays.asList("dateOptionalTime", "weekDate", "tTime", "ordinalDate", "hourMinuteSecond", "hourMinute");
 
         for (String format : dateFormats) {
             XContentBuilder mapping = jsonBuilder().startObject().startObject("properties")
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/externalvalues/ExternalMapper.java b/core/src/test/java/org/elasticsearch/index/mapper/externalvalues/ExternalMapper.java
index 0024a63a4b5..e0c7a30673a 100755
--- a/core/src/test/java/org/elasticsearch/index/mapper/externalvalues/ExternalMapper.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/externalvalues/ExternalMapper.java
@@ -20,7 +20,6 @@
 package org.elasticsearch.index.mapper.externalvalues;
 
 import com.google.common.collect.Iterators;
-import com.google.common.collect.Lists;
 import com.spatial4j.core.shape.Point;
 import org.apache.lucene.document.Field;
 import org.elasticsearch.common.Strings;
@@ -43,6 +42,7 @@ import org.elasticsearch.index.mapper.geo.GeoShapeFieldMapper;
 
 import java.io.IOException;
 import java.nio.charset.Charset;
+import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -220,7 +220,7 @@ public class ExternalMapper extends FieldMapper {
 
     @Override
     public Iterator iterator() {
-        return Iterators.concat(super.iterator(), Lists.newArrayList(binMapper, boolMapper, pointMapper, shapeMapper, stringMapper).iterator());
+        return Iterators.concat(super.iterator(), Arrays.asList(binMapper, boolMapper, pointMapper, shapeMapper, stringMapper).iterator());
     }
 
     @Override
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/string/SimpleStringMappingTests.java b/core/src/test/java/org/elasticsearch/index/mapper/string/SimpleStringMappingTests.java
index f109aba6fdd..f122de90202 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/string/SimpleStringMappingTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/string/SimpleStringMappingTests.java
@@ -20,19 +20,18 @@
 package org.elasticsearch.index.mapper.string;
 
 import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-
 import org.apache.lucene.index.DocValuesType;
 import org.apache.lucene.index.IndexOptions;
 import org.apache.lucene.index.IndexableField;
 import org.apache.lucene.index.IndexableFieldType;
+import org.elasticsearch.Version;
+import org.elasticsearch.cluster.metadata.IndexMetaData;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.common.xcontent.ToXContent;
 import org.elasticsearch.common.xcontent.XContentBuilder;
 import org.elasticsearch.common.xcontent.XContentFactory;
 import org.elasticsearch.common.xcontent.XContentParser;
 import org.elasticsearch.common.xcontent.json.JsonXContent;
-import org.elasticsearch.cluster.metadata.IndexMetaData;
 import org.elasticsearch.index.IndexService;
 import org.elasticsearch.index.fielddata.FieldDataType;
 import org.elasticsearch.index.mapper.ContentPath;
@@ -40,16 +39,13 @@ import org.elasticsearch.index.mapper.DocumentMapper;
 import org.elasticsearch.index.mapper.DocumentMapperParser;
 import org.elasticsearch.index.mapper.FieldMapper;
 import org.elasticsearch.index.mapper.Mapper.BuilderContext;
+import org.elasticsearch.index.mapper.MapperParsingException;
 import org.elasticsearch.index.mapper.MergeResult;
 import org.elasticsearch.index.mapper.ParseContext.Document;
 import org.elasticsearch.index.mapper.ParsedDocument;
 import org.elasticsearch.index.mapper.core.StringFieldMapper;
-import org.elasticsearch.index.mapper.MapperParsingException;
-import org.elasticsearch.Version;
 import org.elasticsearch.test.ESSingleNodeTestCase;
 import org.elasticsearch.test.VersionUtils;
-
-
 import org.junit.Before;
 import org.junit.Test;
 
@@ -57,10 +53,7 @@ import java.util.Arrays;
 import java.util.Map;
 
 import static org.elasticsearch.index.mapper.core.StringFieldMapper.Builder;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.hamcrest.Matchers.nullValue;
-import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.*;
 
 /**
  */
@@ -253,7 +246,7 @@ public class SimpleStringMappingTests extends ESSingleNodeTestCase {
                 .endObject().endObject().string();
 
         DocumentMapper mapper = parser.parse(mapping);
-        for (String fieldName : Lists.newArrayList("field1", "field2", "field3", "field4")) {
+        for (String fieldName : Arrays.asList("field1", "field2", "field3", "field4")) {
             Map serializedMap = getSerializedMap(fieldName, mapper);
             assertFalse(fieldName, serializedMap.containsKey("search_quote_analyzer"));
         }
@@ -277,7 +270,7 @@ public class SimpleStringMappingTests extends ESSingleNodeTestCase {
                 .endObject().endObject().string();
         
         mapper = parser.parse(mapping);
-        for (String fieldName : Lists.newArrayList("field1", "field2")) {
+        for (String fieldName : Arrays.asList("field1", "field2")) {
             Map serializedMap = getSerializedMap(fieldName, mapper);
             assertEquals(serializedMap.get("search_quote_analyzer"), "simple");
         }
diff --git a/core/src/test/java/org/elasticsearch/index/query/SimpleIndexQueryParserTests.java b/core/src/test/java/org/elasticsearch/index/query/SimpleIndexQueryParserTests.java
index a7aa9f78d5a..559d5d1e225 100644
--- a/core/src/test/java/org/elasticsearch/index/query/SimpleIndexQueryParserTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/SimpleIndexQueryParserTests.java
@@ -19,25 +19,54 @@
 
 package org.elasticsearch.index.query;
 
-import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
 import org.apache.lucene.analysis.core.WhitespaceAnalyzer;
-import org.apache.lucene.index.*;
+import org.apache.lucene.index.Fields;
+import org.apache.lucene.index.MultiFields;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.index.Terms;
+import org.apache.lucene.index.TermsEnum;
 import org.apache.lucene.index.memory.MemoryIndex;
 import org.apache.lucene.queries.BoostingQuery;
 import org.apache.lucene.queries.ExtendedCommonTermsQuery;
 import org.apache.lucene.queries.TermsQuery;
-import org.apache.lucene.search.*;
+import org.apache.lucene.search.BooleanClause;
 import org.apache.lucene.search.BooleanClause.Occur;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.ConstantScoreQuery;
+import org.apache.lucene.search.DisjunctionMaxQuery;
+import org.apache.lucene.search.FuzzyQuery;
+import org.apache.lucene.search.MatchAllDocsQuery;
+import org.apache.lucene.search.MultiTermQuery;
+import org.apache.lucene.search.NumericRangeQuery;
+import org.apache.lucene.search.PrefixQuery;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.QueryWrapperFilter;
+import org.apache.lucene.search.RegexpQuery;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.TermRangeQuery;
+import org.apache.lucene.search.WildcardQuery;
 import org.apache.lucene.search.join.ToParentBlockJoinQuery;
-import org.apache.lucene.search.spans.*;
+import org.apache.lucene.search.spans.FieldMaskingSpanQuery;
+import org.apache.lucene.search.spans.SpanContainingQuery;
+import org.apache.lucene.search.spans.SpanFirstQuery;
+import org.apache.lucene.search.spans.SpanMultiTermQueryWrapper;
+import org.apache.lucene.search.spans.SpanNearQuery;
+import org.apache.lucene.search.spans.SpanNotQuery;
+import org.apache.lucene.search.spans.SpanOrQuery;
+import org.apache.lucene.search.spans.SpanTermQuery;
+import org.apache.lucene.search.spans.SpanWithinQuery;
 import org.apache.lucene.spatial.prefix.IntersectsPrefixTreeFilter;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.BytesRefBuilder;
 import org.apache.lucene.util.CharsRefBuilder;
 import org.apache.lucene.util.NumericUtils;
 import org.apache.lucene.util.automaton.TooComplexToDeterminizeException;
-import org.elasticsearch.action.termvectors.*;
+import org.elasticsearch.action.termvectors.MultiTermVectorsItemResponse;
+import org.elasticsearch.action.termvectors.MultiTermVectorsRequest;
+import org.elasticsearch.action.termvectors.MultiTermVectorsResponse;
+import org.elasticsearch.action.termvectors.TermVectorsRequest;
+import org.elasticsearch.action.termvectors.TermVectorsResponse;
 import org.elasticsearch.cluster.metadata.MetaData;
 import org.elasticsearch.common.Strings;
 import org.elasticsearch.common.bytes.BytesArray;
@@ -1044,7 +1073,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
     @Test
     public void testTermsQueryBuilder() throws IOException {
         IndexQueryParserService queryParser = queryParser();
-        Query parsedQuery = queryParser.parse(termsQuery("name.first", Lists.newArrayList("shay", "test"))).query();
+        Query parsedQuery = queryParser.parse(termsQuery("name.first", Arrays.asList("shay", "test"))).query();
         assertThat(parsedQuery, instanceOf(BooleanQuery.class));
         BooleanQuery booleanQuery = (BooleanQuery) parsedQuery;
         BooleanClause[] clauses = booleanQuery.getClauses();
@@ -1138,7 +1167,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
     @Test
     public void testInQuery() throws IOException {
         IndexQueryParserService queryParser = queryParser();
-        Query parsedQuery = queryParser.parse(termsQuery("name.first", Lists.newArrayList("test1", "test2", "test3"))).query();
+        Query parsedQuery = queryParser.parse(termsQuery("name.first", Arrays.asList("test1", "test2", "test3"))).query();
         assertThat(parsedQuery, instanceOf(BooleanQuery.class));
         BooleanQuery booleanQuery = (BooleanQuery) parsedQuery;
         BooleanClause[] clauses = booleanQuery.getClauses();
diff --git a/core/src/test/java/org/elasticsearch/index/shard/CommitPointsTests.java b/core/src/test/java/org/elasticsearch/index/shard/CommitPointsTests.java
index 5a84bb0cec1..68bcc4d2b8e 100644
--- a/core/src/test/java/org/elasticsearch/index/shard/CommitPointsTests.java
+++ b/core/src/test/java/org/elasticsearch/index/shard/CommitPointsTests.java
@@ -20,7 +20,6 @@
 package org.elasticsearch.index.shard;
 
 import com.google.common.base.Charsets;
-import com.google.common.collect.Lists;
 import org.elasticsearch.common.logging.ESLogger;
 import org.elasticsearch.common.logging.Loggers;
 import org.elasticsearch.test.ESTestCase;
@@ -28,7 +27,6 @@ import org.junit.Test;
 
 import java.util.ArrayList;
 
-import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.nullValue;
 
@@ -41,11 +39,11 @@ public class CommitPointsTests extends ESTestCase {
 
     @Test
     public void testCommitPointXContent() throws Exception {
-        ArrayList indexFiles = Lists.newArrayList();
+        ArrayList indexFiles = new ArrayList<>();
         indexFiles.add(new CommitPoint.FileInfo("file1", "file1_p", 100, "ck1"));
         indexFiles.add(new CommitPoint.FileInfo("file2", "file2_p", 200, "ck2"));
 
-        ArrayList translogFiles = Lists.newArrayList();
+        ArrayList translogFiles = new ArrayList<>();
         translogFiles.add(new CommitPoint.FileInfo("t_file1", "t_file1_p", 100, null));
         translogFiles.add(new CommitPoint.FileInfo("t_file2", "t_file2_p", 200, null));
 
diff --git a/core/src/test/java/org/elasticsearch/index/store/CorruptedFileIT.java b/core/src/test/java/org/elasticsearch/index/store/CorruptedFileIT.java
index b9d00741720..6ca68c6f495 100644
--- a/core/src/test/java/org/elasticsearch/index/store/CorruptedFileIT.java
+++ b/core/src/test/java/org/elasticsearch/index/store/CorruptedFileIT.java
@@ -21,12 +21,14 @@ package org.elasticsearch.index.store;
 import com.carrotsearch.randomizedtesting.generators.RandomPicks;
 import com.google.common.base.Charsets;
 import com.google.common.base.Predicate;
-import com.google.common.collect.Lists;
-
 import org.apache.lucene.codecs.CodecUtil;
 import org.apache.lucene.index.CheckIndex;
 import org.apache.lucene.index.IndexFileNames;
-import org.apache.lucene.store.*;
+import org.apache.lucene.store.ChecksumIndexInput;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.FSDirectory;
+import org.apache.lucene.store.IOContext;
+import org.apache.lucene.store.IndexInput;
 import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
 import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
 import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
@@ -40,7 +42,11 @@ import org.elasticsearch.client.Requests;
 import org.elasticsearch.cluster.ClusterState;
 import org.elasticsearch.cluster.metadata.IndexMetaData;
 import org.elasticsearch.cluster.node.DiscoveryNode;
-import org.elasticsearch.cluster.routing.*;
+import org.elasticsearch.cluster.routing.GroupShardsIterator;
+import org.elasticsearch.cluster.routing.IndexShardRoutingTable;
+import org.elasticsearch.cluster.routing.ShardIterator;
+import org.elasticsearch.cluster.routing.ShardRouting;
+import org.elasticsearch.cluster.routing.ShardRoutingState;
 import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider;
 import org.elasticsearch.cluster.routing.allocation.decider.ThrottlingAllocationDecider;
 import org.elasticsearch.common.Nullable;
@@ -53,7 +59,10 @@ import org.elasticsearch.common.unit.ByteSizeUnit;
 import org.elasticsearch.discovery.Discovery;
 import org.elasticsearch.gateway.PrimaryShardAllocator;
 import org.elasticsearch.index.settings.IndexSettings;
-import org.elasticsearch.index.shard.*;
+import org.elasticsearch.index.shard.IndexShard;
+import org.elasticsearch.index.shard.IndexShardState;
+import org.elasticsearch.index.shard.MergePolicyConfig;
+import org.elasticsearch.index.shard.ShardId;
 import org.elasticsearch.index.translog.TranslogService;
 import org.elasticsearch.indices.IndicesLifecycle;
 import org.elasticsearch.indices.IndicesService;
@@ -66,7 +75,10 @@ import org.elasticsearch.test.ESIntegTestCase;
 import org.elasticsearch.test.InternalTestCluster;
 import org.elasticsearch.test.store.MockFSDirectoryService;
 import org.elasticsearch.test.transport.MockTransportService;
-import org.elasticsearch.transport.*;
+import org.elasticsearch.transport.TransportException;
+import org.elasticsearch.transport.TransportRequest;
+import org.elasticsearch.transport.TransportRequestOptions;
+import org.elasticsearch.transport.TransportService;
 import org.junit.Test;
 
 import java.io.IOException;
@@ -78,7 +90,13 @@ import java.nio.file.DirectoryStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.StandardOpenOption;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutionException;
@@ -86,6 +104,7 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import static org.elasticsearch.common.settings.Settings.settingsBuilder;
+import static org.elasticsearch.common.util.CollectionUtils.iterableAsArrayList;
 import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
 import static org.hamcrest.Matchers.*;
 
@@ -595,7 +614,7 @@ public class CorruptedFileIT extends ESIntegTestCase {
     private ShardRouting corruptRandomPrimaryFile(final boolean includePerCommitFiles) throws IOException {
         ClusterState state = client().admin().cluster().prepareState().get().getState();
         GroupShardsIterator shardIterators = state.getRoutingNodes().getRoutingTable().activePrimaryShardsGrouped(new String[]{"test"}, false);
-        List iterators = Lists.newArrayList(shardIterators);
+        List iterators = iterableAsArrayList(shardIterators);
         ShardIterator shardIterator = RandomPicks.randomFrom(getRandom(), iterators);
         ShardRouting shardRouting = shardIterator.nextOrNull();
         assertNotNull(shardRouting);
diff --git a/core/src/test/java/org/elasticsearch/index/store/CorruptedTranslogIT.java b/core/src/test/java/org/elasticsearch/index/store/CorruptedTranslogIT.java
index 04b0ed38742..f0fda717f96 100644
--- a/core/src/test/java/org/elasticsearch/index/store/CorruptedTranslogIT.java
+++ b/core/src/test/java/org/elasticsearch/index/store/CorruptedTranslogIT.java
@@ -19,9 +19,7 @@
 
 package org.elasticsearch.index.store;
 
-import com.google.common.collect.Lists;
 import com.carrotsearch.randomizedtesting.generators.RandomPicks;
-
 import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse;
 import org.elasticsearch.action.index.IndexRequestBuilder;
 import org.elasticsearch.action.search.SearchPhaseExecutionException;
@@ -38,18 +36,21 @@ import org.elasticsearch.test.ESIntegTestCase;
 import org.elasticsearch.test.engine.MockEngineSupport;
 import org.elasticsearch.test.junit.annotations.TestLogging;
 import org.elasticsearch.test.transport.MockTransportService;
-import org.elasticsearch.transport.TransportModule;
 import org.junit.Test;
 
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.channels.FileChannel;
-import java.nio.file.*;
+import java.nio.file.DirectoryStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardOpenOption;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Set;
 import java.util.TreeSet;
 
+import static org.elasticsearch.common.util.CollectionUtils.iterableAsArrayList;
 import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
 import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
 import static org.hamcrest.Matchers.notNullValue;
@@ -115,7 +116,7 @@ public class CorruptedTranslogIT extends ESIntegTestCase {
     private void corruptRandomTranslogFiles() throws IOException {
         ClusterState state = client().admin().cluster().prepareState().get().getState();
         GroupShardsIterator shardIterators = state.getRoutingNodes().getRoutingTable().activePrimaryShardsGrouped(new String[]{"test"}, false);
-        List iterators = Lists.newArrayList(shardIterators);
+        List iterators = iterableAsArrayList(shardIterators);
         ShardIterator shardIterator = RandomPicks.randomFrom(getRandom(), iterators);
         ShardRouting shardRouting = shardIterator.nextOrNull();
         assertNotNull(shardRouting);
diff --git a/core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java b/core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java
index 06fa074b05b..c7ebedf1cb7 100644
--- a/core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java
+++ b/core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java
@@ -53,9 +53,25 @@ import java.io.InputStream;
 import java.nio.ByteBuffer;
 import java.nio.channels.FileChannel;
 import java.nio.charset.Charset;
-import java.nio.file.*;
-import java.util.*;
-import java.util.concurrent.*;
+import java.nio.file.DirectoryStream;
+import java.nio.file.Files;
+import java.nio.file.InvalidPathException;
+import java.nio.file.Path;
+import java.nio.file.StandardOpenOption;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.BrokenBarrierException;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
@@ -63,7 +79,6 @@ import java.util.concurrent.atomic.AtomicReference;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import static com.google.common.collect.Lists.newArrayList;
 import static org.hamcrest.Matchers.*;
 
 /**
@@ -546,7 +561,7 @@ public class TranslogTests extends ESTestCase {
 
     @Test
     public void testTranslogChecksums() throws Exception {
-        List locations = newArrayList();
+        List locations = new ArrayList<>();
 
         int translogOperations = randomIntBetween(10, 100);
         for (int op = 0; op < translogOperations; op++) {
@@ -570,7 +585,7 @@ public class TranslogTests extends ESTestCase {
 
     @Test
     public void testTruncatedTranslogs() throws Exception {
-        List locations = newArrayList();
+        List locations = new ArrayList<>();
 
         int translogOperations = randomIntBetween(10, 100);
         for (int op = 0; op < translogOperations; op++) {
@@ -855,7 +870,7 @@ public class TranslogTests extends ESTestCase {
     }
 
     public void testLocationComparison() throws IOException {
-        List locations = newArrayList();
+        List locations = new ArrayList<>();
         int translogOperations = randomIntBetween(10, 100);
         int count = 0;
         for (int op = 0; op < translogOperations; op++) {
@@ -884,7 +899,7 @@ public class TranslogTests extends ESTestCase {
 
 
     public void testBasicCheckpoint() throws IOException {
-        List locations = newArrayList();
+        List locations = new ArrayList<>();
         int translogOperations = randomIntBetween(10, 100);
         int lastSynced = -1;
         for (int op = 0; op < translogOperations; op++) {
@@ -970,7 +985,7 @@ public class TranslogTests extends ESTestCase {
     }
 
     public void testBasicRecovery() throws IOException {
-        List locations = newArrayList();
+        List locations = new ArrayList<>();
         int translogOperations = randomIntBetween(10, 100);
         Translog.TranslogGeneration translogGeneration = null;
         int minUncommittedOp = -1;
@@ -1012,7 +1027,7 @@ public class TranslogTests extends ESTestCase {
     }
 
     public void testRecoveryUncommitted() throws IOException {
-        List locations = newArrayList();
+        List locations = new ArrayList<>();
         int translogOperations = randomIntBetween(10, 100);
         final int prepareOp = randomIntBetween(0, translogOperations-1);
         Translog.TranslogGeneration translogGeneration = null;
@@ -1066,7 +1081,7 @@ public class TranslogTests extends ESTestCase {
 
     public void testSnapshotFromStreamInput() throws IOException {
         BytesStreamOutput out = new BytesStreamOutput();
-        List ops = newArrayList();
+        List ops = new ArrayList<>();
         int translogOperations = randomIntBetween(10, 100);
         for (int op = 0; op < translogOperations; op++) {
             Translog.Create test = new Translog.Create("test", "" + op, Integer.toString(op).getBytes(Charset.forName("UTF-8")));
@@ -1079,8 +1094,8 @@ public class TranslogTests extends ESTestCase {
     }
 
     public void testLocationHashCodeEquals() throws IOException {
-        List locations = newArrayList();
-        List locations2 = newArrayList();
+        List locations = new ArrayList<>();
+        List locations2 = new ArrayList<>();
         int translogOperations = randomIntBetween(10, 100);
         try(Translog translog2 = create(createTempDir())) {
             for (int op = 0; op < translogOperations; op++) {
@@ -1107,7 +1122,7 @@ public class TranslogTests extends ESTestCase {
     }
 
     public void testOpenForeignTranslog() throws IOException {
-        List locations = newArrayList();
+        List locations = new ArrayList<>();
         int translogOperations = randomIntBetween(1, 10);
         int firstUncommitted = 0;
         for (int op = 0; op < translogOperations; op++) {
diff --git a/core/src/test/java/org/elasticsearch/indices/analysis/PreBuiltAnalyzerIntegrationIT.java b/core/src/test/java/org/elasticsearch/indices/analysis/PreBuiltAnalyzerIntegrationIT.java
index 839fc598d01..c27a507d5c1 100644
--- a/core/src/test/java/org/elasticsearch/indices/analysis/PreBuiltAnalyzerIntegrationIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/analysis/PreBuiltAnalyzerIntegrationIT.java
@@ -19,7 +19,6 @@
 
 package org.elasticsearch.indices.analysis;
 
-import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import org.apache.lucene.analysis.Analyzer;
 import org.elasticsearch.Version;
@@ -30,6 +29,7 @@ import org.elasticsearch.test.ESIntegTestCase;
 import org.junit.Test;
 
 import java.lang.reflect.Field;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
@@ -54,7 +54,7 @@ public class PreBuiltAnalyzerIntegrationIT extends ESIntegTestCase {
     @Test
     public void testThatPreBuiltAnalyzersAreNotClosedOnIndexClose() throws Exception {
         Map> loadedAnalyzers = Maps.newHashMap();
-        List indexNames = Lists.newArrayList();
+        List indexNames = new ArrayList<>();
         final int numIndices = scaledRandomIntBetween(2, 4);
         for (int i = 0; i < numIndices; i++) {
             String indexName = randomAsciiOfLength(10).toLowerCase(Locale.ROOT);
@@ -66,7 +66,7 @@ public class PreBuiltAnalyzerIntegrationIT extends ESIntegTestCase {
 
             Version randomVersion = randomVersion(random());
             if (!loadedAnalyzers.containsKey(preBuiltAnalyzer)) {
-                 loadedAnalyzers.put(preBuiltAnalyzer, Lists.newArrayList());
+                 loadedAnalyzers.put(preBuiltAnalyzer, new ArrayList());
             }
             loadedAnalyzers.get(preBuiltAnalyzer).add(randomVersion);
 
diff --git a/core/src/test/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java b/core/src/test/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java
index 71ccf68e41a..a7ad9285aee 100644
--- a/core/src/test/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java
@@ -19,8 +19,6 @@
 
 package org.elasticsearch.indices.mapping;
 
-import com.google.common.collect.Lists;
-
 import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse;
 import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
 import org.elasticsearch.action.admin.indices.refresh.RefreshResponse;
@@ -39,13 +37,15 @@ import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
 import org.hamcrest.Matchers;
 import org.junit.Test;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
 import java.util.concurrent.CyclicBarrier;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
 import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
 import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
 import static org.hamcrest.Matchers.*;
 
@@ -64,7 +64,7 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase {
 
         int recCount = randomIntBetween(200, 600);
         int numberOfTypes = randomIntBetween(1, 5);
-        List indexRequests = Lists.newArrayList();
+        List indexRequests = new ArrayList<>();
         for (int rec = 0; rec < recCount; rec++) {
             String type = "type" + (rec % numberOfTypes);
             String fieldName = "field_" + type + "_" + rec;
diff --git a/core/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerNoopIT.java b/core/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerNoopIT.java
index 29e057d612c..4992b9f72dc 100644
--- a/core/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerNoopIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerNoopIT.java
@@ -27,9 +27,9 @@ import org.elasticsearch.search.sort.SortOrder;
 import org.elasticsearch.test.ESIntegTestCase;
 import org.junit.Test;
 
+import java.util.ArrayList;
 import java.util.List;
 
-import static com.google.common.collect.Lists.newArrayList;
 import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
 import static org.elasticsearch.common.settings.Settings.settingsBuilder;
 import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
@@ -59,7 +59,7 @@ public class CircuitBreakerNoopIT extends ESIntegTestCase {
 
         // index some different terms so we have some field data for loading
         int docCount = scaledRandomIntBetween(300, 1000);
-        List reqs = newArrayList();
+        List reqs = new ArrayList<>();
         for (long id = 0; id < docCount; id++) {
             reqs.add(client.prepareIndex("cb-test", "type", Long.toString(id)).setSource("test", id));
         }
@@ -77,7 +77,7 @@ public class CircuitBreakerNoopIT extends ESIntegTestCase {
 
         // index some different terms so we have some field data for loading
         int docCount = scaledRandomIntBetween(300, 1000);
-        List reqs = newArrayList();
+        List reqs = new ArrayList<>();
         for (long id = 0; id < docCount; id++) {
             reqs.add(client.prepareIndex("cb-test", "type", Long.toString(id)).setSource("test", id));
         }
diff --git a/core/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerServiceIT.java b/core/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerServiceIT.java
index fb9e9cb935f..4ffe6361cb5 100644
--- a/core/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerServiceIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerServiceIT.java
@@ -40,10 +40,10 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 
-import static com.google.common.collect.Lists.newArrayList;
 import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
 import static org.elasticsearch.common.settings.Settings.settingsBuilder;
 import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
@@ -111,7 +111,7 @@ public class CircuitBreakerServiceIT extends ESIntegTestCase {
 
         // index some different terms so we have some field data for loading
         int docCount = scaledRandomIntBetween(300, 1000);
-        List reqs = newArrayList();
+        List reqs = new ArrayList<>();
         for (long id = 0; id < docCount; id++) {
             reqs.add(client.prepareIndex("cb-test", "type", Long.toString(id)).setSource("test", "value" + id));
         }
@@ -158,7 +158,7 @@ public class CircuitBreakerServiceIT extends ESIntegTestCase {
 
         // index some different terms so we have some field data for loading
         int docCount = scaledRandomIntBetween(300, 1000);
-        List reqs = newArrayList();
+        List reqs = new ArrayList<>();
         for (long id = 0; id < docCount; id++) {
             reqs.add(client.prepareIndex("ramtest", "type", Long.toString(id)).setSource("test", "value" + id));
         }
@@ -207,7 +207,7 @@ public class CircuitBreakerServiceIT extends ESIntegTestCase {
 
         // index some different terms so we have some field data for loading
         int docCount = scaledRandomIntBetween(300, 1000);
-        List reqs = newArrayList();
+        List reqs = new ArrayList<>();
         for (long id = 0; id < docCount; id++) {
             reqs.add(client.prepareIndex("cb-test", "type", Long.toString(id)).setSource("test", "value" + id));
         }
@@ -273,7 +273,7 @@ public class CircuitBreakerServiceIT extends ESIntegTestCase {
 
         // index some different terms so we have some field data for loading
         int docCount = scaledRandomIntBetween(300, 1000);
-        List reqs = newArrayList();
+        List reqs = new ArrayList<>();
         for (long id = 0; id < docCount; id++) {
             reqs.add(client.prepareIndex("cb-test", "type", Long.toString(id)).setSource("test", id));
         }
diff --git a/core/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java b/core/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java
index b8185250761..4ffc09b22d5 100644
--- a/core/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java
@@ -18,7 +18,6 @@
  */
 package org.elasticsearch.indices.template;
 
-import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
 import org.elasticsearch.ElasticsearchParseException;
 import org.elasticsearch.action.ActionRequestValidationException;
@@ -41,6 +40,7 @@ import org.elasticsearch.search.SearchHit;
 import org.elasticsearch.test.ESIntegTestCase;
 import org.junit.Test;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Set;
@@ -235,7 +235,7 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase {
         GetIndexTemplatesResponse getTemplate1Response = client().admin().indices().prepareGetTemplates("template_*").execute().actionGet();
         assertThat(getTemplate1Response.getIndexTemplates(), hasSize(2));
 
-        List templateNames = Lists.newArrayList();
+        List templateNames = new ArrayList<>();
         templateNames.add(getTemplate1Response.getIndexTemplates().get(0).name());
         templateNames.add(getTemplate1Response.getIndexTemplates().get(1).name());
         assertThat(templateNames, containsInAnyOrder("template_1", "template_2"));
@@ -244,7 +244,7 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase {
         getTemplate1Response = client().admin().indices().prepareGetTemplates("template*").execute().actionGet();
         assertThat(getTemplate1Response.getIndexTemplates(), hasSize(3));
 
-        templateNames = Lists.newArrayList();
+        templateNames = new ArrayList<>();
         templateNames.add(getTemplate1Response.getIndexTemplates().get(0).name());
         templateNames.add(getTemplate1Response.getIndexTemplates().get(1).name());
         templateNames.add(getTemplate1Response.getIndexTemplates().get(2).name());
@@ -254,7 +254,7 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase {
         getTemplate1Response = client().admin().indices().prepareGetTemplates("template_1", "template_2").execute().actionGet();
         assertThat(getTemplate1Response.getIndexTemplates(), hasSize(2));
 
-        templateNames = Lists.newArrayList();
+        templateNames = new ArrayList<>();
         templateNames.add(getTemplate1Response.getIndexTemplates().get(0).name());
         templateNames.add(getTemplate1Response.getIndexTemplates().get(1).name());
         assertThat(templateNames, containsInAnyOrder("template_1", "template_2"));
diff --git a/core/src/test/java/org/elasticsearch/plugins/PluginInfoTests.java b/core/src/test/java/org/elasticsearch/plugins/PluginInfoTests.java
index 58180b277f8..232169474b2 100644
--- a/core/src/test/java/org/elasticsearch/plugins/PluginInfoTests.java
+++ b/core/src/test/java/org/elasticsearch/plugins/PluginInfoTests.java
@@ -20,8 +20,6 @@
 package org.elasticsearch.plugins;
 
 import com.google.common.base.Function;
-import com.google.common.collect.Lists;
-
 import org.elasticsearch.Version;
 import org.elasticsearch.action.admin.cluster.node.info.PluginsInfo;
 import org.elasticsearch.test.ESTestCase;
@@ -33,6 +31,7 @@ import java.nio.file.Path;
 import java.util.List;
 import java.util.Properties;
 
+import static org.elasticsearch.common.util.CollectionUtils.eagerTransform;
 import static org.hamcrest.Matchers.contains;
 
 public class PluginInfoTests extends ESTestCase {
@@ -282,7 +281,7 @@ public class PluginInfoTests extends ESTestCase {
         pluginsInfo.add(new PluginInfo("d", "foo", true, "dummy", true, "dummyclass", true));
 
         final List infos = pluginsInfo.getInfos();
-        List names = Lists.transform(infos, new Function() {
+        List names = eagerTransform(infos, new Function() {
             @Override
             public String apply(PluginInfo input) {
                 return input.getName();
diff --git a/core/src/test/java/org/elasticsearch/rest/RestFilterChainTests.java b/core/src/test/java/org/elasticsearch/rest/RestFilterChainTests.java
index a8ad99d3b39..5760c284161 100644
--- a/core/src/test/java/org/elasticsearch/rest/RestFilterChainTests.java
+++ b/core/src/test/java/org/elasticsearch/rest/RestFilterChainTests.java
@@ -19,7 +19,6 @@
 
 package org.elasticsearch.rest;
 
-import com.google.common.collect.Lists;
 import org.elasticsearch.common.Nullable;
 import org.elasticsearch.common.bytes.BytesReference;
 import org.elasticsearch.common.io.stream.BytesStreamOutput;
@@ -30,7 +29,12 @@ import org.elasticsearch.test.rest.FakeRestRequest;
 import org.junit.Test;
 
 import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -57,7 +61,7 @@ public class RestFilterChainTests extends ESTestCase {
             restController.registerFilter(testFilter);
         }
 
-        ArrayList restFiltersByOrder = Lists.newArrayList(filters);
+        ArrayList restFiltersByOrder = new ArrayList<>(filters);
         Collections.sort(restFiltersByOrder, new Comparator() {
             @Override
             public int compare(RestFilter o1, RestFilter o2) {
@@ -65,7 +69,7 @@ public class RestFilterChainTests extends ESTestCase {
             }
         });
 
-        List expectedRestFilters = Lists.newArrayList();
+        List expectedRestFilters = new ArrayList<>();
         for (RestFilter filter : restFiltersByOrder) {
             TestFilter testFilter = (TestFilter) filter;
             expectedRestFilters.add(testFilter);
@@ -87,7 +91,7 @@ public class RestFilterChainTests extends ESTestCase {
         assertThat(fakeRestChannel.await(), equalTo(true));
 
 
-        List testFiltersByLastExecution = Lists.newArrayList();
+        List testFiltersByLastExecution = new ArrayList<>();
         for (RestFilter restFilter : filters) {
             testFiltersByLastExecution.add((TestFilter)restFilter);
         }
@@ -98,7 +102,7 @@ public class RestFilterChainTests extends ESTestCase {
             }
         });
 
-        ArrayList finalTestFilters = Lists.newArrayList();
+        ArrayList finalTestFilters = new ArrayList<>();
         for (RestFilter filter : testFiltersByLastExecution) {
             TestFilter testFilter = (TestFilter) filter;
             finalTestFilters.add(testFilter);
diff --git a/core/src/test/java/org/elasticsearch/script/GroovyScriptIT.java b/core/src/test/java/org/elasticsearch/script/GroovyScriptIT.java
index 8df2c205b38..ed4c999ad22 100644
--- a/core/src/test/java/org/elasticsearch/script/GroovyScriptIT.java
+++ b/core/src/test/java/org/elasticsearch/script/GroovyScriptIT.java
@@ -28,18 +28,12 @@ import org.elasticsearch.script.groovy.GroovyScriptEngineService;
 import org.elasticsearch.test.ESIntegTestCase;
 import org.junit.Test;
 
+import java.util.ArrayList;
 import java.util.List;
 
-import static com.google.common.collect.Lists.newArrayList;
-import static org.elasticsearch.index.query.QueryBuilders.constantScoreQuery;
-import static org.elasticsearch.index.query.QueryBuilders.functionScoreQuery;
-import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
-import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
-import static org.elasticsearch.index.query.QueryBuilders.scriptQuery;
+import static org.elasticsearch.index.query.QueryBuilders.*;
 import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.scriptFunction;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertOrderedSearchHits;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchHits;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
 import static org.hamcrest.Matchers.equalTo;
 
 /**
@@ -67,7 +61,7 @@ public class GroovyScriptIT extends ESIntegTestCase {
 
     @Test
     public void testGroovyExceptionSerialization() throws Exception {
-        List reqs = newArrayList();
+        List reqs = new ArrayList<>();
         for (int i = 0; i < randomIntBetween(50, 500); i++) {
             reqs.add(client().prepareIndex("test", "doc", "" + i).setSource("foo", "bar"));
         }
diff --git a/core/src/test/java/org/elasticsearch/script/NativeScriptTests.java b/core/src/test/java/org/elasticsearch/script/NativeScriptTests.java
index 3c35a286e3b..e0a7d4ba3cd 100644
--- a/core/src/test/java/org/elasticsearch/script/NativeScriptTests.java
+++ b/core/src/test/java/org/elasticsearch/script/NativeScriptTests.java
@@ -20,7 +20,6 @@
 package org.elasticsearch.script;
 
 import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
 import org.elasticsearch.common.Nullable;
 import org.elasticsearch.common.inject.Injector;
 import org.elasticsearch.common.inject.ModulesBuilder;
@@ -36,6 +35,7 @@ import org.elasticsearch.watcher.ResourceWatcherService;
 import org.junit.Test;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
@@ -83,7 +83,7 @@ public class NativeScriptTests extends ESTestCase {
         Map nativeScriptFactoryMap = new HashMap<>();
         nativeScriptFactoryMap.put("my", new MyNativeScriptFactory());
         Set scriptEngineServices = ImmutableSet.of(new NativeScriptEngineService(settings, nativeScriptFactoryMap));
-        ScriptContextRegistry scriptContextRegistry = new ScriptContextRegistry(Lists.newArrayList());
+        ScriptContextRegistry scriptContextRegistry = new ScriptContextRegistry(new ArrayList());
         ScriptService scriptService = new ScriptService(settings, environment, scriptEngineServices, resourceWatcherService, scriptContextRegistry);
 
         for (ScriptContext scriptContext : scriptContextRegistry.scriptContexts()) {
diff --git a/core/src/test/java/org/elasticsearch/script/ScriptContextRegistryTests.java b/core/src/test/java/org/elasticsearch/script/ScriptContextRegistryTests.java
index 8bb77b48fef..c7d3a52bf7e 100644
--- a/core/src/test/java/org/elasticsearch/script/ScriptContextRegistryTests.java
+++ b/core/src/test/java/org/elasticsearch/script/ScriptContextRegistryTests.java
@@ -19,12 +19,13 @@
 
 package org.elasticsearch.script;
 
-import com.google.common.collect.Lists;
 import org.elasticsearch.test.ESTestCase;
 import org.hamcrest.Matchers;
 import org.junit.Test;
 
 import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
 
 public class ScriptContextRegistryTests extends ESTestCase {
 
@@ -33,7 +34,7 @@ public class ScriptContextRegistryTests extends ESTestCase {
         for (final String rejectedContext : ScriptContextRegistry.RESERVED_SCRIPT_CONTEXTS) {
             try {
                 //try to register a prohibited script context
-                new ScriptContextRegistry(Lists.newArrayList(new ScriptContext.Plugin("test", rejectedContext)));
+                new ScriptContextRegistry(Arrays.asList(new ScriptContext.Plugin("test", rejectedContext)));
                 fail("ScriptContextRegistry initialization should have failed");
             } catch(IllegalArgumentException e) {
                 assertThat(e.getMessage(), Matchers.containsString("[" + rejectedContext + "] is a reserved name, it cannot be registered as a custom script context"));
@@ -46,7 +47,7 @@ public class ScriptContextRegistryTests extends ESTestCase {
         for (final String rejectedContext : ScriptContextRegistry.RESERVED_SCRIPT_CONTEXTS) {
             try {
                 //try to register a prohibited script context
-                new ScriptContextRegistry(Lists.newArrayList(new ScriptContext.Plugin(rejectedContext, "test")));
+                new ScriptContextRegistry(Collections.singleton(new ScriptContext.Plugin(rejectedContext, "test")));
                 fail("ScriptContextRegistry initialization should have failed");
             } catch(IllegalArgumentException e) {
                 assertThat(e.getMessage(), Matchers.containsString("[" + rejectedContext + "] is a reserved name, it cannot be registered as a custom script context"));
@@ -68,7 +69,7 @@ public class ScriptContextRegistryTests extends ESTestCase {
     public void testDuplicatedPluginScriptContexts() throws IOException {
         try {
             //try to register a prohibited script context
-            new ScriptContextRegistry(Lists.newArrayList(new ScriptContext.Plugin("testplugin", "test"), new ScriptContext.Plugin("testplugin", "test")));
+            new ScriptContextRegistry(Arrays.asList(new ScriptContext.Plugin("testplugin", "test"), new ScriptContext.Plugin("testplugin", "test")));
             fail("ScriptContextRegistry initialization should have failed");
         } catch(IllegalArgumentException e) {
             assertThat(e.getMessage(), Matchers.containsString("script context [testplugin_test] cannot be registered twice"));
@@ -77,6 +78,6 @@ public class ScriptContextRegistryTests extends ESTestCase {
 
     @Test
     public void testNonDuplicatedPluginScriptContexts() throws IOException {
-        new ScriptContextRegistry(Lists.newArrayList(new ScriptContext.Plugin("testplugin1", "test"), new ScriptContext.Plugin("testplugin2", "test")));
+        new ScriptContextRegistry(Arrays.asList(new ScriptContext.Plugin("testplugin1", "test"), new ScriptContext.Plugin("testplugin2", "test")));
     }
 }
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/AggregationsIntegrationIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/AggregationsIntegrationIT.java
index 8944294fd42..e395b0ad528 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/AggregationsIntegrationIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/AggregationsIntegrationIT.java
@@ -19,7 +19,6 @@
 
 package org.elasticsearch.search.aggregations;
 
-import com.google.common.collect.Lists;
 import org.elasticsearch.action.index.IndexRequestBuilder;
 import org.elasticsearch.action.search.SearchPhaseExecutionException;
 import org.elasticsearch.action.search.SearchResponse;
@@ -28,6 +27,7 @@ import org.elasticsearch.common.unit.TimeValue;
 import org.elasticsearch.search.aggregations.bucket.terms.Terms;
 import org.elasticsearch.test.ESIntegTestCase;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import static org.elasticsearch.search.aggregations.AggregationBuilders.terms;
@@ -45,7 +45,7 @@ public class AggregationsIntegrationIT extends ESIntegTestCase {
         assertAcked(prepareCreate("index").addMapping("type", "f", "type=string").get());
         ensureYellow("index");
         numDocs = randomIntBetween(1, 20);
-        List docs = Lists.newArrayList();
+        List docs = new ArrayList<>();
         for (int i = 0; i < numDocs; ++i) {
             docs.add(client().prepareIndex("index", "type").setSource("f", Integer.toString(i / 3)));
         }
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/EquivalenceIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/EquivalenceIT.java
index abe88af10aa..0d881feac6d 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/EquivalenceIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/EquivalenceIT.java
@@ -20,7 +20,6 @@
 package org.elasticsearch.search.aggregations;
 
 import com.carrotsearch.hppc.IntHashSet;
-import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import org.elasticsearch.action.index.IndexRequestBuilder;
 import org.elasticsearch.action.search.SearchRequestBuilder;
@@ -49,19 +48,8 @@ import java.util.List;
 import java.util.Map;
 
 import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
-import static org.elasticsearch.search.aggregations.AggregationBuilders.extendedStats;
-import static org.elasticsearch.search.aggregations.AggregationBuilders.filter;
-import static org.elasticsearch.search.aggregations.AggregationBuilders.histogram;
-import static org.elasticsearch.search.aggregations.AggregationBuilders.max;
-import static org.elasticsearch.search.aggregations.AggregationBuilders.min;
-import static org.elasticsearch.search.aggregations.AggregationBuilders.percentiles;
-import static org.elasticsearch.search.aggregations.AggregationBuilders.range;
-import static org.elasticsearch.search.aggregations.AggregationBuilders.stats;
-import static org.elasticsearch.search.aggregations.AggregationBuilders.sum;
-import static org.elasticsearch.search.aggregations.AggregationBuilders.terms;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAllSuccessful;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.*;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.core.IsNull.notNullValue;
 
@@ -202,7 +190,7 @@ public class EquivalenceIT extends ESIntegTestCase {
                         .endObject()
                         .endObject()).execute().actionGet();
 
-        List indexingRequests = Lists.newArrayList();
+        List indexingRequests = new ArrayList<>();
         for (int i = 0; i < numDocs; ++i) {
             final int[] values = new int[randomInt(4)];
             for (int j = 0; j < values.length; ++j) {
@@ -329,7 +317,7 @@ public class EquivalenceIT extends ESIntegTestCase {
 
         final int numDocs = scaledRandomIntBetween(2500, 5000);
         logger.info("Indexing [" + numDocs +"] docs");
-        List indexingRequests = Lists.newArrayList();
+        List indexingRequests = new ArrayList<>();
         for (int i = 0; i < numDocs; ++i) {
             indexingRequests.add(client().prepareIndex("idx", "type", Integer.toString(i)).setSource("double_value", randomDouble()));
         }
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/HDRPercentileRanksIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/HDRPercentileRanksIT.java
index 1c19af1fecb..24abca0b99e 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/HDRPercentileRanksIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/HDRPercentileRanksIT.java
@@ -18,8 +18,6 @@
  */
 package org.elasticsearch.search.aggregations.metrics;
 
-import com.google.common.collect.Lists;
-
 import org.elasticsearch.action.search.SearchResponse;
 import org.elasticsearch.common.logging.Loggers;
 import org.elasticsearch.script.Script;
@@ -37,16 +35,11 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import static org.elasticsearch.common.util.CollectionUtils.iterableAsArrayList;
 import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
-import static org.elasticsearch.search.aggregations.AggregationBuilders.global;
-import static org.elasticsearch.search.aggregations.AggregationBuilders.histogram;
-import static org.elasticsearch.search.aggregations.AggregationBuilders.percentileRanks;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.*;
 import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.greaterThanOrEqualTo;
-import static org.hamcrest.Matchers.lessThanOrEqualTo;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.hamcrest.Matchers.sameInstance;
+import static org.hamcrest.Matchers.*;
 
 /**
  *
@@ -80,7 +73,7 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
     }
 
     private void assertConsistent(double[] pcts, PercentileRanks percentiles, long minValue, long maxValue, int numberSigDigits) {
-        final List percentileList = Lists.newArrayList(percentiles);
+        final List percentileList = iterableAsArrayList(percentiles);
         assertEquals(pcts.length, percentileList.size());
         for (int i = 0; i < pcts.length; ++i) {
             final Percentile percentile = percentileList.get(i);
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/HDRPercentilesIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/HDRPercentilesIT.java
index d251218a93d..b5568f918cf 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/HDRPercentilesIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/HDRPercentilesIT.java
@@ -18,10 +18,9 @@
  */
 package org.elasticsearch.search.aggregations.metrics;
 
-import com.google.common.collect.Lists;
-
 import org.elasticsearch.action.search.SearchResponse;
 import org.elasticsearch.common.logging.Loggers;
+import org.elasticsearch.common.util.CollectionUtils;
 import org.elasticsearch.script.Script;
 import org.elasticsearch.script.ScriptService.ScriptType;
 import org.elasticsearch.search.aggregations.bucket.global.Global;
@@ -38,16 +37,9 @@ import java.util.List;
 import java.util.Map;
 
 import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
-import static org.elasticsearch.search.aggregations.AggregationBuilders.global;
-import static org.elasticsearch.search.aggregations.AggregationBuilders.histogram;
-import static org.elasticsearch.search.aggregations.AggregationBuilders.percentiles;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.*;
 import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
-import static org.hamcrest.Matchers.closeTo;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.greaterThanOrEqualTo;
-import static org.hamcrest.Matchers.lessThanOrEqualTo;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.hamcrest.Matchers.sameInstance;
+import static org.hamcrest.Matchers.*;
 
 /**
  *
@@ -80,7 +72,7 @@ public class HDRPercentilesIT extends AbstractNumericTestCase {
     }
 
     private void assertConsistent(double[] pcts, Percentiles percentiles, long minValue, long maxValue, int numberSigDigits) {
-        final List percentileList = Lists.newArrayList(percentiles);
+        final List percentileList = CollectionUtils.iterableAsArrayList(percentiles);
         assertEquals(pcts.length, percentileList.size());
         for (int i = 0; i < pcts.length; ++i) {
             final Percentile percentile = percentileList.get(i);
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TDigestPercentileRanksIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TDigestPercentileRanksIT.java
index 81bde020aa6..8499f754602 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TDigestPercentileRanksIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TDigestPercentileRanksIT.java
@@ -18,10 +18,9 @@
  */
 package org.elasticsearch.search.aggregations.metrics;
 
-import com.google.common.collect.Lists;
-
 import org.elasticsearch.action.search.SearchResponse;
 import org.elasticsearch.common.logging.Loggers;
+import org.elasticsearch.common.util.CollectionUtils;
 import org.elasticsearch.script.Script;
 import org.elasticsearch.script.ScriptService.ScriptType;
 import org.elasticsearch.search.aggregations.bucket.global.Global;
@@ -38,15 +37,9 @@ import java.util.List;
 import java.util.Map;
 
 import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
-import static org.elasticsearch.search.aggregations.AggregationBuilders.global;
-import static org.elasticsearch.search.aggregations.AggregationBuilders.histogram;
-import static org.elasticsearch.search.aggregations.AggregationBuilders.percentileRanks;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.*;
 import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.greaterThanOrEqualTo;
-import static org.hamcrest.Matchers.lessThanOrEqualTo;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.hamcrest.Matchers.sameInstance;
+import static org.hamcrest.Matchers.*;
 
 /**
  *
@@ -83,7 +76,7 @@ public class TDigestPercentileRanksIT extends AbstractNumericTestCase {
     }
 
     private void assertConsistent(double[] pcts, PercentileRanks percentiles, long minValue, long maxValue) {
-        final List percentileList = Lists.newArrayList(percentiles);
+        final List percentileList = CollectionUtils.iterableAsArrayList(percentiles);
         assertEquals(pcts.length, percentileList.size());
         for (int i = 0; i < pcts.length; ++i) {
             final Percentile percentile = percentileList.get(i);
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TDigestPercentilesIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TDigestPercentilesIT.java
index f3e89488cf7..65b0ea596c8 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TDigestPercentilesIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TDigestPercentilesIT.java
@@ -18,10 +18,9 @@
  */
 package org.elasticsearch.search.aggregations.metrics;
 
-import com.google.common.collect.Lists;
-
 import org.elasticsearch.action.search.SearchResponse;
 import org.elasticsearch.common.logging.Loggers;
+import org.elasticsearch.common.util.CollectionUtils;
 import org.elasticsearch.script.Script;
 import org.elasticsearch.script.ScriptService.ScriptType;
 import org.elasticsearch.search.aggregations.bucket.global.Global;
@@ -38,15 +37,9 @@ import java.util.List;
 import java.util.Map;
 
 import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
-import static org.elasticsearch.search.aggregations.AggregationBuilders.global;
-import static org.elasticsearch.search.aggregations.AggregationBuilders.histogram;
-import static org.elasticsearch.search.aggregations.AggregationBuilders.percentiles;
+import static org.elasticsearch.search.aggregations.AggregationBuilders.*;
 import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.greaterThanOrEqualTo;
-import static org.hamcrest.Matchers.lessThanOrEqualTo;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.hamcrest.Matchers.sameInstance;
+import static org.hamcrest.Matchers.*;
 
 /**
  *
@@ -82,7 +75,7 @@ public class TDigestPercentilesIT extends AbstractNumericTestCase {
     }
 
     private void assertConsistent(double[] pcts, Percentiles percentiles, long minValue, long maxValue) {
-        final List percentileList = Lists.newArrayList(percentiles);
+        final List percentileList = CollectionUtils.iterableAsArrayList(percentiles);
         assertEquals(pcts.length, percentileList.size());
         for (int i = 0; i < pcts.length; ++i) {
             final Percentile percentile = percentileList.get(i);
diff --git a/core/src/test/java/org/elasticsearch/search/functionscore/RandomScoreFunctionIT.java b/core/src/test/java/org/elasticsearch/search/functionscore/RandomScoreFunctionIT.java
index d3ff321d65f..cdbe3be602f 100644
--- a/core/src/test/java/org/elasticsearch/search/functionscore/RandomScoreFunctionIT.java
+++ b/core/src/test/java/org/elasticsearch/search/functionscore/RandomScoreFunctionIT.java
@@ -26,30 +26,18 @@ import org.elasticsearch.script.ScriptService.ScriptType;
 import org.elasticsearch.search.SearchHit;
 import org.elasticsearch.test.ESIntegTestCase;
 import org.hamcrest.CoreMatchers;
-import org.junit.Ignore;
 
 import java.util.Arrays;
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.Map;
 
-import static com.google.common.collect.Lists.newArrayList;
 import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
-import static org.elasticsearch.index.query.QueryBuilders.functionScoreQuery;
-import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
-import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
-import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.fieldValueFactorFunction;
-import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.randomFunction;
-import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.scriptFunction;
+import static org.elasticsearch.index.query.QueryBuilders.*;
+import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.*;
 import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
 import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
-import static org.hamcrest.Matchers.allOf;
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.greaterThan;
-import static org.hamcrest.Matchers.greaterThanOrEqualTo;
-import static org.hamcrest.Matchers.lessThanOrEqualTo;
-import static org.hamcrest.Matchers.nullValue;
+import static org.hamcrest.Matchers.*;
 
 public class RandomScoreFunctionIT extends ESIntegTestCase {
 
@@ -121,7 +109,7 @@ public class RandomScoreFunctionIT extends ESIntegTestCase {
 
         int docCount = randomIntBetween(100, 200);
         for (int i = 0; i < docCount; i++) {
-            client().prepareIndex("test", "type", "" + i).setSource("body", randomFrom(newArrayList("foo", "bar", "baz")), "index", i + 1)// we add 1 to the index field to make sure that the scripts below never compute log(0)
+            client().prepareIndex("test", "type", "" + i).setSource("body", randomFrom(Arrays.asList("foo", "bar", "baz")), "index", i + 1) // we add 1 to the index field to make sure that the scripts below never compute log(0)
                     .get();
         }
         refresh();
diff --git a/core/src/test/java/org/elasticsearch/search/highlight/CustomHighlighter.java b/core/src/test/java/org/elasticsearch/search/highlight/CustomHighlighter.java
index e193d2ad69b..5a8d7c0150a 100644
--- a/core/src/test/java/org/elasticsearch/search/highlight/CustomHighlighter.java
+++ b/core/src/test/java/org/elasticsearch/search/highlight/CustomHighlighter.java
@@ -18,11 +18,11 @@
  */
 package org.elasticsearch.search.highlight;
 
-import com.google.common.collect.Lists;
 import org.elasticsearch.common.text.StringText;
 import org.elasticsearch.common.text.Text;
 import org.elasticsearch.index.mapper.FieldMapper;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
@@ -51,7 +51,7 @@ public class CustomHighlighter implements Highlighter {
             }
         }
 
-        List responses = Lists.newArrayList();
+        List responses = new ArrayList<>();
         responses.add(new StringText(String.format(Locale.ENGLISH, "standard response for %s at position %s", field.field(),
                 cacheEntry.position)));
 
diff --git a/core/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchIT.java b/core/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchIT.java
index 672dc5e081f..0b5e0d88a11 100644
--- a/core/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchIT.java
+++ b/core/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchIT.java
@@ -20,8 +20,6 @@ package org.elasticsearch.search.suggest;
 
 import com.carrotsearch.hppc.ObjectLongHashMap;
 import com.carrotsearch.randomizedtesting.generators.RandomStrings;
-import com.google.common.collect.Lists;
-
 import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
 import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
 import org.elasticsearch.action.admin.indices.optimize.OptimizeResponse;
@@ -51,6 +49,8 @@ import org.elasticsearch.test.ESIntegTestCase;
 import org.junit.Test;
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
@@ -60,6 +60,7 @@ import java.util.concurrent.ExecutionException;
 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.common.settings.Settings.settingsBuilder;
+import static org.elasticsearch.common.util.CollectionUtils.iterableAsArrayList;
 import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
 import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
 import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
@@ -145,7 +146,7 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
     public void testThatWeightsAreWorking() throws Exception {
         createIndexAndMapping(completionMappingBuilder);
 
-        List similarNames = Lists.newArrayList("the", "The Prodigy", "The Verve", "The the");
+        List similarNames = Arrays.asList("the", "The Prodigy", "The Verve", "The the");
         // the weight is 1000 divided by string length, so the results are easy to to check
         for (String similarName : similarNames) {
             client().prepareIndex(INDEX, TYPE, similarName).setSource(jsonBuilder()
@@ -853,8 +854,8 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
     private void assertSuggestions(SuggestResponse suggestResponse, boolean suggestionOrderStrict, String name, String... suggestions) {
         assertAllSuccessful(suggestResponse);
 
-        List suggestionNames = Lists.newArrayList();
-        for (Suggest.Suggestion> suggestion : Lists.newArrayList(suggestResponse.getSuggest().iterator())) {
+        List suggestionNames = new ArrayList<>();
+        for (Suggest.Suggestion> suggestion : iterableAsArrayList(suggestResponse.getSuggest())) {
             suggestionNames.add(suggestion.getName());
         }
         String expectFieldInResponseMsg = String.format(Locale.ROOT, "Expected suggestion named %s in response, got %s", name, suggestionNames);
@@ -881,7 +882,7 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
     }
 
     private List getNames(Suggest.Suggestion.Entry suggestEntry) {
-        List names = Lists.newArrayList();
+        List names = new ArrayList<>();
         for (Suggest.Suggestion.Entry.Option entry : suggestEntry.getOptions()) {
             names.add(entry.getText().string());
         }
diff --git a/core/src/test/java/org/elasticsearch/search/suggest/CustomSuggesterSearchIT.java b/core/src/test/java/org/elasticsearch/search/suggest/CustomSuggesterSearchIT.java
index 1d7ad858321..b804de63832 100644
--- a/core/src/test/java/org/elasticsearch/search/suggest/CustomSuggesterSearchIT.java
+++ b/core/src/test/java/org/elasticsearch/search/suggest/CustomSuggesterSearchIT.java
@@ -18,7 +18,6 @@
  */
 package org.elasticsearch.search.suggest;
 
-import com.google.common.collect.Lists;
 import org.elasticsearch.action.search.SearchRequestBuilder;
 import org.elasticsearch.action.search.SearchResponse;
 import org.elasticsearch.common.settings.Settings;
@@ -30,8 +29,9 @@ import org.junit.Test;
 import java.util.List;
 import java.util.Locale;
 
+import static org.elasticsearch.common.util.CollectionUtils.iterableAsArrayList;
 import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
-import static org.elasticsearch.test.ESIntegTestCase.*;
+import static org.elasticsearch.test.ESIntegTestCase.Scope;
 import static org.hamcrest.Matchers.hasSize;
 import static org.hamcrest.Matchers.is;
 
@@ -76,7 +76,7 @@ public class CustomSuggesterSearchIT extends ESIntegTestCase {
         SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
 
         // TODO: infer type once JI-9019884 is fixed
-        List> suggestions = Lists.>newArrayList(searchResponse.getSuggest().getSuggestion("someName").iterator());
+        List> suggestions = iterableAsArrayList(searchResponse.getSuggest().getSuggestion("someName"));
         assertThat(suggestions, hasSize(2));
         assertThat(suggestions.get(0).getText().string(), is(String.format(Locale.ROOT, "%s-%s-%s-12", randomText, randomField, randomSuffix)));
         assertThat(suggestions.get(1).getText().string(), is(String.format(Locale.ROOT, "%s-%s-%s-123", randomText, randomField, randomSuffix)));
diff --git a/core/src/test/java/org/elasticsearch/search/suggest/completion/CompletionPostingsFormatTest.java b/core/src/test/java/org/elasticsearch/search/suggest/completion/CompletionPostingsFormatTest.java
index 1b29173973b..0bbd1cef8bf 100644
--- a/core/src/test/java/org/elasticsearch/search/suggest/completion/CompletionPostingsFormatTest.java
+++ b/core/src/test/java/org/elasticsearch/search/suggest/completion/CompletionPostingsFormatTest.java
@@ -19,8 +19,6 @@
 
 package org.elasticsearch.search.suggest.completion;
 
-import com.google.common.collect.Lists;
-
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
 import org.apache.lucene.codecs.Codec;
 import org.apache.lucene.codecs.FieldsConsumer;
@@ -89,7 +87,7 @@ public class CompletionPostingsFormatTest extends ESTestCase {
     public void testCompletionPostingsFormat() throws IOException {
         AnalyzingCompletionLookupProviderV1 providerV1 = new AnalyzingCompletionLookupProviderV1(true, false, true, true);
         AnalyzingCompletionLookupProvider currentProvider = new AnalyzingCompletionLookupProvider(true, false, true, true);
-        List providers = Lists.newArrayList(providerV1, currentProvider);
+        List providers = Arrays.asList(providerV1, currentProvider);
 
         Completion090PostingsFormat.CompletionLookupProvider randomProvider = providers.get(getRandom().nextInt(providers.size()));
         RAMDirectory dir = new RAMDirectory();
diff --git a/core/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java b/core/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java
index 75c72162ab9..d36ecfa7d46 100644
--- a/core/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java
+++ b/core/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java
@@ -66,7 +66,6 @@ import org.elasticsearch.snapshots.mockstore.MockRepository;
 import org.elasticsearch.test.ESIntegTestCase;
 import org.elasticsearch.test.InternalTestCluster;
 import org.elasticsearch.test.rest.FakeRestRequest;
-import org.elasticsearch.transport.TransportModule;
 import org.junit.Test;
 
 import java.io.IOException;
@@ -79,22 +78,11 @@ import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicReference;
 
-import static com.google.common.collect.Lists.newArrayList;
 import static org.elasticsearch.common.settings.Settings.settingsBuilder;
 import static org.elasticsearch.test.ESIntegTestCase.ClusterScope;
 import static org.elasticsearch.test.ESIntegTestCase.Scope;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertThrows;
-import static org.hamcrest.Matchers.allOf;
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.greaterThan;
-import static org.hamcrest.Matchers.greaterThanOrEqualTo;
-import static org.hamcrest.Matchers.lessThan;
-import static org.hamcrest.Matchers.not;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.hamcrest.Matchers.nullValue;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
+import static org.hamcrest.Matchers.*;
 
 /**
  */
@@ -341,7 +329,7 @@ public class DedicatedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTest
     @Test
     public void snapshotWithStuckNodeTest() throws Exception {
         logger.info("--> start 2 nodes");
-        ArrayList nodes = newArrayList();
+        ArrayList nodes = new ArrayList<>();
         nodes.add(internalCluster().startNode());
         nodes.add(internalCluster().startNode());
         Client client = client();
diff --git a/core/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java b/core/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java
index 1c42072b889..c3d3f0ff896 100644
--- a/core/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java
+++ b/core/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java
@@ -79,30 +79,13 @@ import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 
-import static com.google.common.collect.Lists.newArrayList;
 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.common.settings.Settings.settingsBuilder;
 import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
 import static org.elasticsearch.index.shard.IndexShard.INDEX_REFRESH_INTERVAL;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAliasesExist;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAliasesMissing;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAllSuccessful;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertIndexTemplateExists;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertIndexTemplateMissing;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertThrows;
-import static org.hamcrest.Matchers.allOf;
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.greaterThan;
-import static org.hamcrest.Matchers.lessThan;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.hamcrest.Matchers.nullValue;
-import static org.hamcrest.Matchers.startsWith;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
+import static org.hamcrest.Matchers.*;
 
 public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCase {
 
@@ -133,7 +116,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
 
         ListenableActionFuture flushResponseFuture = null;
         if (randomBoolean()) {
-            ArrayList indicesToFlush = newArrayList();
+            ArrayList indicesToFlush = new ArrayList<>();
             for (int i = 1; i < 4; i++) {
                 if (randomBoolean()) {
                     indicesToFlush.add("test-idx-" + i);
diff --git a/core/src/test/java/org/elasticsearch/stresstest/manyindices/ManyNodesManyIndicesRecoveryStressTest.java b/core/src/test/java/org/elasticsearch/stresstest/manyindices/ManyNodesManyIndicesRecoveryStressTest.java
index ea4d20f9149..ccd25a1607f 100644
--- a/core/src/test/java/org/elasticsearch/stresstest/manyindices/ManyNodesManyIndicesRecoveryStressTest.java
+++ b/core/src/test/java/org/elasticsearch/stresstest/manyindices/ManyNodesManyIndicesRecoveryStressTest.java
@@ -19,7 +19,6 @@
 
 package org.elasticsearch.stresstest.manyindices;
 
-import com.google.common.collect.Lists;
 import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
 import org.elasticsearch.action.count.CountResponse;
 import org.elasticsearch.client.Client;
@@ -28,6 +27,7 @@ import org.elasticsearch.index.query.QueryBuilders;
 import org.elasticsearch.node.Node;
 import org.elasticsearch.node.NodeBuilder;
 
+import java.util.ArrayList;
 import java.util.List;
 
 public class ManyNodesManyIndicesRecoveryStressTest {
@@ -48,7 +48,7 @@ public class ManyNodesManyIndicesRecoveryStressTest {
                 .put("index.number_of_shards", 1)
                 .build();
 
-        List nodes = Lists.newArrayList();
+        List nodes = new ArrayList<>();
         for (int i = 0; i < NUM_NODES; i++) {
             nodes.add(NodeBuilder.nodeBuilder().settings(Settings.settingsBuilder().put(nodeSettings).put("name", "node" + i)).node());
         }
@@ -93,7 +93,7 @@ public class ManyNodesManyIndicesRecoveryStressTest {
         Thread.sleep(5000);
         System.out.println("--> All nodes are closed, starting back...");
 
-        nodes = Lists.newArrayList();
+        nodes = new ArrayList<>();
         for (int i = 0; i < NUM_NODES; i++) {
             nodes.add(NodeBuilder.nodeBuilder().settings(Settings.settingsBuilder().put(nodeSettings).put("name", "node" + i)).node());
         }
diff --git a/core/src/test/java/org/elasticsearch/test/ESAllocationTestCase.java b/core/src/test/java/org/elasticsearch/test/ESAllocationTestCase.java
index 991aea74345..d12f4d68752 100644
--- a/core/src/test/java/org/elasticsearch/test/ESAllocationTestCase.java
+++ b/core/src/test/java/org/elasticsearch/test/ESAllocationTestCase.java
@@ -46,8 +46,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.Random;
 
-import static com.google.common.collect.Lists.newArrayList;
 import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
+import static org.elasticsearch.common.util.CollectionUtils.arrayAsArrayList;
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.is;
 
@@ -132,7 +132,7 @@ public abstract class ESAllocationTestCase extends ESTestCase {
         if (initializingShards.isEmpty()) {
             return clusterState;
         }
-        RoutingTable routingTable = strategy.applyStartedShards(clusterState, newArrayList(initializingShards.get(randomInt(initializingShards.size() - 1)))).routingTable();
+        RoutingTable routingTable = strategy.applyStartedShards(clusterState, arrayAsArrayList(initializingShards.get(randomInt(initializingShards.size() - 1)))).routingTable();
         return ClusterState.builder(clusterState).routingTable(routingTable).build();
     }
 
diff --git a/core/src/test/java/org/elasticsearch/test/ESIntegTestCase.java b/core/src/test/java/org/elasticsearch/test/ESIntegTestCase.java
index 798c66ca8f7..55fae7fc3fd 100644
--- a/core/src/test/java/org/elasticsearch/test/ESIntegTestCase.java
+++ b/core/src/test/java/org/elasticsearch/test/ESIntegTestCase.java
@@ -26,15 +26,7 @@ import com.carrotsearch.randomizedtesting.generators.RandomInts;
 import com.carrotsearch.randomizedtesting.generators.RandomPicks;
 import com.google.common.base.Joiner;
 import com.google.common.base.Predicate;
-import com.google.common.collect.Lists;
-
 import org.apache.http.impl.client.HttpClients;
-import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
-import org.elasticsearch.cluster.metadata.IndexMetaData;
-import org.elasticsearch.cluster.routing.UnassignedInfo;
-import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider;
-import org.elasticsearch.common.network.NetworkAddress;
-import org.elasticsearch.index.shard.MergeSchedulerConfig;
 import org.apache.lucene.util.IOUtils;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.TestUtil;
@@ -47,6 +39,7 @@ import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
 import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
 import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
 import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
+import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
 import org.elasticsearch.action.admin.cluster.tasks.PendingClusterTasksResponse;
 import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder;
 import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse;
@@ -69,17 +62,21 @@ import org.elasticsearch.client.Client;
 import org.elasticsearch.client.Requests;
 import org.elasticsearch.cluster.ClusterService;
 import org.elasticsearch.cluster.ClusterState;
+import org.elasticsearch.cluster.metadata.IndexMetaData;
 import org.elasticsearch.cluster.metadata.MappingMetaData;
 import org.elasticsearch.cluster.metadata.MetaData;
 import org.elasticsearch.cluster.routing.IndexRoutingTable;
 import org.elasticsearch.cluster.routing.IndexShardRoutingTable;
 import org.elasticsearch.cluster.routing.ShardRouting;
+import org.elasticsearch.cluster.routing.UnassignedInfo;
 import org.elasticsearch.cluster.routing.allocation.decider.DiskThresholdDecider;
+import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider;
 import org.elasticsearch.common.Nullable;
 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.network.NetworkAddress;
 import org.elasticsearch.common.regex.Regex;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.common.transport.InetSocketTransportAddress;
@@ -104,6 +101,7 @@ import org.elasticsearch.index.mapper.MappedFieldType;
 import org.elasticsearch.index.mapper.MappedFieldType.Loading;
 import org.elasticsearch.index.mapper.internal.TimestampFieldMapper;
 import org.elasticsearch.index.shard.MergePolicyConfig;
+import org.elasticsearch.index.shard.MergeSchedulerConfig;
 import org.elasticsearch.index.translog.Translog;
 import org.elasticsearch.index.translog.TranslogConfig;
 import org.elasticsearch.index.translog.TranslogService;
@@ -119,28 +117,49 @@ import org.elasticsearch.search.SearchService;
 import org.elasticsearch.test.client.RandomizingClient;
 import org.elasticsearch.test.disruption.ServiceDisruptionScheme;
 import org.elasticsearch.test.rest.client.http.HttpRequestBuilder;
-import org.elasticsearch.transport.TransportModule;
 import org.hamcrest.Matchers;
 import org.joda.time.DateTimeZone;
-import org.junit.*;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.lang.annotation.*;
+import java.lang.annotation.Annotation;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.UnknownHostException;
 import java.nio.file.DirectoryStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
-import java.util.*;
-import java.util.concurrent.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.IdentityHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
 
 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.common.settings.Settings.settingsBuilder;
+import static org.elasticsearch.common.util.CollectionUtils.eagerPartition;
 import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
 import static org.elasticsearch.test.XContentTestUtils.convertToMap;
 import static org.elasticsearch.test.XContentTestUtils.differenceBetweenMapsIgnoringArrayOrder;
@@ -1362,7 +1381,7 @@ public abstract class ESIntegTestCase extends ESTestCase {
                 }
             }
         } else {
-            List> partition = Lists.partition(builders, Math.min(MAX_BULK_INDEX_REQUEST_SIZE,
+            List> partition = eagerPartition(builders, Math.min(MAX_BULK_INDEX_REQUEST_SIZE,
                     Math.max(1, (int) (builders.size() * randomDouble()))));
             logger.info("Index [{}] docs async: [{}] bulk: [{}] partitions [{}]", builders.size(), false, true, partition.size());
             for (List segmented : partition) {
diff --git a/core/src/test/java/org/elasticsearch/test/ESTestCase.java b/core/src/test/java/org/elasticsearch/test/ESTestCase.java
index 97d5a2ec917..e0c24a541c6 100644
--- a/core/src/test/java/org/elasticsearch/test/ESTestCase.java
+++ b/core/src/test/java/org/elasticsearch/test/ESTestCase.java
@@ -31,7 +31,6 @@ import com.carrotsearch.randomizedtesting.generators.RandomPicks;
 import com.carrotsearch.randomizedtesting.generators.RandomStrings;
 import com.carrotsearch.randomizedtesting.rules.TestRuleAdapter;
 import com.google.common.base.Predicate;
-
 import org.apache.lucene.uninverting.UninvertingReader;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
@@ -39,6 +38,7 @@ import org.apache.lucene.util.TestUtil;
 import org.apache.lucene.util.TimeUnits;
 import org.elasticsearch.Version;
 import org.elasticsearch.bootstrap.BootstrapForTesting;
+import org.elasticsearch.cache.recycler.MockPageCacheRecycler;
 import org.elasticsearch.client.Requests;
 import org.elasticsearch.cluster.metadata.IndexMetaData;
 import org.elasticsearch.cluster.routing.DjbHashFunction;
@@ -46,19 +46,22 @@ import org.elasticsearch.common.io.PathUtils;
 import org.elasticsearch.common.logging.ESLogger;
 import org.elasticsearch.common.logging.Loggers;
 import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.common.util.MockBigArrays;
 import org.elasticsearch.common.util.concurrent.EsExecutors;
 import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException;
 import org.elasticsearch.common.xcontent.XContentType;
 import org.elasticsearch.env.Environment;
 import org.elasticsearch.env.NodeEnvironment;
-import org.elasticsearch.common.util.MockBigArrays;
-import org.elasticsearch.cache.recycler.MockPageCacheRecycler;
+import org.elasticsearch.search.MockSearchService;
 import org.elasticsearch.test.junit.listeners.AssertionErrorThreadDumpPrinter;
 import org.elasticsearch.test.junit.listeners.LoggingListener;
 import org.elasticsearch.test.junit.listeners.ReproduceInfoPrinter;
-import org.elasticsearch.search.MockSearchService;
 import org.elasticsearch.threadpool.ThreadPool;
-import org.junit.*;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
 import org.junit.rules.RuleChain;
 
 import java.io.IOException;
@@ -67,13 +70,18 @@ import java.nio.file.DirectoryStream;
 import java.nio.file.FileSystem;
 import java.nio.file.Files;
 import java.nio.file.Path;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
 
-import static com.google.common.collect.Lists.newArrayList;
+import static org.elasticsearch.common.util.CollectionUtils.arrayAsArrayList;
 import static org.hamcrest.Matchers.equalTo;
 
 /**
@@ -564,7 +572,7 @@ public abstract class ESTestCase extends LuceneTestCase {
         if (size > values.length) {
             throw new IllegalArgumentException("Can\'t pick " + size + " random objects from a list of " + values.length + " objects");
         }
-        List list = newArrayList(values);
+        List list = arrayAsArrayList(values);
         Collections.shuffle(list);
         return list.subList(0, size);
     }
diff --git a/core/src/test/java/org/elasticsearch/test/ExternalTestCluster.java b/core/src/test/java/org/elasticsearch/test/ExternalTestCluster.java
index 42b780c670c..9a919a391cb 100644
--- a/core/src/test/java/org/elasticsearch/test/ExternalTestCluster.java
+++ b/core/src/test/java/org/elasticsearch/test/ExternalTestCluster.java
@@ -19,7 +19,6 @@
 
 package org.elasticsearch.test;
 
-import com.google.common.collect.Lists;
 import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
 import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
 import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
@@ -38,6 +37,7 @@ import org.elasticsearch.node.internal.InternalSettingsPreparer;
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.nio.file.Path;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -153,7 +153,7 @@ public final class ExternalTestCluster extends TestCluster {
 
     @Override
     public Iterator iterator() {
-        return Lists.newArrayList(client).iterator();
+        return Collections.singleton(client).iterator();
     }
 
     @Override
diff --git a/core/src/test/java/org/elasticsearch/test/InternalTestCluster.java b/core/src/test/java/org/elasticsearch/test/InternalTestCluster.java
index f24ac1e3645..217e8da3340 100644
--- a/core/src/test/java/org/elasticsearch/test/InternalTestCluster.java
+++ b/core/src/test/java/org/elasticsearch/test/InternalTestCluster.java
@@ -29,7 +29,6 @@ import com.google.common.base.Predicates;
 import com.google.common.collect.Collections2;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Iterators;
-import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 import com.google.common.util.concurrent.Futures;
@@ -63,7 +62,6 @@ import org.elasticsearch.common.io.FileSystemUtils;
 import org.elasticsearch.common.lease.Releasables;
 import org.elasticsearch.common.logging.ESLogger;
 import org.elasticsearch.common.logging.Loggers;
-import org.elasticsearch.common.network.NetworkUtils;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.common.settings.Settings.Builder;
 import org.elasticsearch.common.transport.InetSocketTransportAddress;
@@ -94,9 +92,9 @@ import org.elasticsearch.node.NodeMocksPlugin;
 import org.elasticsearch.node.internal.InternalSettingsPreparer;
 import org.elasticsearch.node.service.NodeService;
 import org.elasticsearch.script.ScriptService;
+import org.elasticsearch.search.MockSearchService;
 import org.elasticsearch.search.SearchService;
 import org.elasticsearch.test.disruption.ServiceDisruptionScheme;
-import org.elasticsearch.search.MockSearchService;
 import org.elasticsearch.test.store.MockFSIndexStore;
 import org.elasticsearch.test.transport.AssertingLocalTransport;
 import org.elasticsearch.test.transport.MockTransportService;
@@ -108,7 +106,6 @@ import org.junit.Assert;
 
 import java.io.Closeable;
 import java.io.IOException;
-import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.nio.file.Path;
 import java.util.ArrayList;
@@ -130,16 +127,12 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import static junit.framework.Assert.fail;
-import static org.apache.lucene.util.LuceneTestCase.TEST_NIGHTLY;
-import static org.apache.lucene.util.LuceneTestCase.rarely;
-import static org.apache.lucene.util.LuceneTestCase.usually;
+import static org.apache.lucene.util.LuceneTestCase.*;
 import static org.elasticsearch.common.settings.Settings.settingsBuilder;
 import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
 import static org.elasticsearch.test.ESTestCase.assertBusy;
 import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoTimeout;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.greaterThan;
-import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.*;
 import static org.junit.Assert.assertThat;
 
 /**
@@ -551,7 +544,7 @@ public final class InternalTestCluster extends TestCluster {
      * stop any of the running nodes.
      */
     public void ensureAtLeastNumDataNodes(int n) {
-        List> futures = Lists.newArrayList();
+        List> futures = new ArrayList<>();
         synchronized (this) {
             int size = numDataNodes();
             for (int i = size; i < n; i++) {
@@ -1183,7 +1176,7 @@ public final class InternalTestCluster extends TestCluster {
 
     @Override
     public InetSocketAddress[] httpAddresses() {
-        List addresses = Lists.newArrayList();
+        List addresses = new ArrayList<>();
         for (HttpServerTransport httpServerTransport : getInstances(HttpServerTransport.class)) {
             addresses.add(((InetSocketTransportAddress) httpServerTransport.boundAddress().publishAddress()).address());
         }
@@ -1587,7 +1580,7 @@ public final class InternalTestCluster extends TestCluster {
      * Starts multiple nodes in an async manner with the given settings and version and returns future with its name.
      */
     public synchronized ListenableFuture> startNodesAsync(final int numNodes, final Settings settings, final Version version) {
-        List> futures = Lists.newArrayList();
+        List> futures = new ArrayList<>();
         for (int i = 0; i < numNodes; i++) {
             futures.add(startNodeAsync(settings, version));
         }
@@ -1599,7 +1592,7 @@ public final class InternalTestCluster extends TestCluster {
      * The order of the node names returned matches the order of the settings provided.
      */
     public synchronized ListenableFuture> startNodesAsync(final Settings... settings) {
-        List> futures = Lists.newArrayList();
+        List> futures = new ArrayList<>();
         for (Settings setting : settings) {
             futures.add(startNodeAsync(setting, Version.CURRENT));
         }
diff --git a/core/src/test/java/org/elasticsearch/test/MockLogAppender.java b/core/src/test/java/org/elasticsearch/test/MockLogAppender.java
index 2e0c293c1de..c0866a81081 100644
--- a/core/src/test/java/org/elasticsearch/test/MockLogAppender.java
+++ b/core/src/test/java/org/elasticsearch/test/MockLogAppender.java
@@ -23,9 +23,9 @@ import org.apache.log4j.Level;
 import org.apache.log4j.spi.LoggingEvent;
 import org.elasticsearch.common.regex.Regex;
 
+import java.util.ArrayList;
 import java.util.List;
 
-import static com.google.common.collect.Lists.newArrayList;
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.MatcherAssert.assertThat;
 
@@ -39,7 +39,7 @@ public class MockLogAppender extends AppenderSkeleton {
     private List expectations;
 
     public MockLogAppender() {
-        expectations = newArrayList();
+        expectations = new ArrayList<>();
     }
 
     public void addExpectation(LoggingExpectation expectation) {
diff --git a/core/src/test/java/org/elasticsearch/test/XContentTestUtils.java b/core/src/test/java/org/elasticsearch/test/XContentTestUtils.java
index 647930398b6..866a19e0a72 100644
--- a/core/src/test/java/org/elasticsearch/test/XContentTestUtils.java
+++ b/core/src/test/java/org/elasticsearch/test/XContentTestUtils.java
@@ -19,13 +19,13 @@
 
 package org.elasticsearch.test;
 
-import com.google.common.collect.Lists;
 import org.elasticsearch.common.xcontent.ToXContent;
 import org.elasticsearch.common.xcontent.XContentBuilder;
 import org.elasticsearch.common.xcontent.XContentFactory;
 import org.elasticsearch.common.xcontent.XContentHelper;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -78,7 +78,7 @@ public final class XContentTestUtils {
             }
         } else if (first instanceof List) {
             if (second instanceof List) {
-                List secondList = Lists.newArrayList((List) second);
+                List secondList = new ArrayList<>((List) second);
                 List firstList = (List) first;
                 if (firstList.size() == secondList.size()) {
                     String reason = path + ": no matches found";
diff --git a/core/src/test/java/org/elasticsearch/test/rest/ESRestTestCase.java b/core/src/test/java/org/elasticsearch/test/rest/ESRestTestCase.java
index 9315fff0a20..f3e18d75124 100644
--- a/core/src/test/java/org/elasticsearch/test/rest/ESRestTestCase.java
+++ b/core/src/test/java/org/elasticsearch/test/rest/ESRestTestCase.java
@@ -22,7 +22,6 @@ package org.elasticsearch.test.rest;
 import com.carrotsearch.randomizedtesting.RandomizedTest;
 import com.carrotsearch.randomizedtesting.annotations.TestGroup;
 import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite;
-import com.google.common.collect.Lists;
 import org.apache.lucene.util.IOUtils;
 import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
 import org.apache.lucene.util.LuceneTestCase.SuppressFsync;
@@ -68,6 +67,7 @@ import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.PathMatcher;
 import java.nio.file.StandardCopyOption;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
@@ -169,11 +169,11 @@ public abstract class ESRestTestCase extends ESIntegTestCase {
             enabled = false;
         }
         if (!enabled) {
-            return Lists.newArrayList();
+            return new ArrayList<>();
         }
         //parse tests only if rest test group is enabled, otherwise rest tests might not even be available on file system
         List restTestCandidates = collectTestCandidates(id, count);
-        List objects = Lists.newArrayList();
+        List objects = new ArrayList<>();
         for (RestTestCandidate restTestCandidate : restTestCandidates) {
             objects.add(new Object[]{restTestCandidate});
         }
@@ -181,7 +181,7 @@ public abstract class ESRestTestCase extends ESIntegTestCase {
     }
 
     private static List collectTestCandidates(int id, int count) throws RestTestParseException, IOException {
-        List testCandidates = Lists.newArrayList();
+        List testCandidates = new ArrayList<>();
         FileSystem fileSystem = getFileSystem();
         // don't make a try-with, getFileSystem returns null
         // ... and you can't close() the default filesystem
@@ -191,7 +191,7 @@ public abstract class ESRestTestCase extends ESIntegTestCase {
             RestTestSuiteParser restTestSuiteParser = new RestTestSuiteParser();
             //yaml suites are grouped by directory (effectively by api)
             for (String api : yamlSuites.keySet()) {
-                List yamlFiles = Lists.newArrayList(yamlSuites.get(api));
+                List yamlFiles = new ArrayList<>(yamlSuites.get(api));
                 for (Path yamlFile : yamlFiles) {
                     String key = api + yamlFile.getFileName().toString();
                     if (mustExecute(key, id, count)) {
diff --git a/core/src/test/java/org/elasticsearch/test/rest/client/RestClient.java b/core/src/test/java/org/elasticsearch/test/rest/client/RestClient.java
index f18f9201d1a..4eed5510797 100644
--- a/core/src/test/java/org/elasticsearch/test/rest/client/RestClient.java
+++ b/core/src/test/java/org/elasticsearch/test/rest/client/RestClient.java
@@ -19,10 +19,8 @@
 package org.elasticsearch.test.rest.client;
 
 import com.carrotsearch.randomizedtesting.RandomizedTest;
-import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
-
 import org.apache.http.config.Registry;
 import org.apache.http.config.RegistryBuilder;
 import org.apache.http.conn.socket.ConnectionSocketFactory;
@@ -46,6 +44,7 @@ import org.elasticsearch.test.rest.client.http.HttpResponse;
 import org.elasticsearch.test.rest.spec.RestApi;
 import org.elasticsearch.test.rest.spec.RestSpec;
 
+import javax.net.ssl.SSLContext;
 import java.io.Closeable;
 import java.io.IOException;
 import java.io.InputStream;
@@ -57,13 +56,12 @@ import java.security.KeyStore;
 import java.security.KeyStoreException;
 import java.security.NoSuchAlgorithmException;
 import java.security.cert.CertificateException;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
 
-import javax.net.ssl.SSLContext;
-
 /**
  * REST client used to test the elasticsearch REST layer
  * Holds the {@link RestSpec} used to translate api calls into REST calls
@@ -136,7 +134,7 @@ public class RestClient implements Closeable {
      */
     public RestResponse callApi(String apiName, Map params, String body) throws IOException, RestException {
 
-        List ignores = Lists.newArrayList();
+        List ignores = new ArrayList<>();
         Map requestParams = null;
         if (params != null) {
             //makes a copy of the parameters before modifying them for this specific request
diff --git a/core/src/test/java/org/elasticsearch/test/rest/json/JsonPath.java b/core/src/test/java/org/elasticsearch/test/rest/json/JsonPath.java
index 567e849a391..c3dbd583430 100644
--- a/core/src/test/java/org/elasticsearch/test/rest/json/JsonPath.java
+++ b/core/src/test/java/org/elasticsearch/test/rest/json/JsonPath.java
@@ -18,13 +18,12 @@
  */
 package org.elasticsearch.test.rest.json;
 
-import com.google.common.collect.Lists;
-
 import org.elasticsearch.common.xcontent.XContentParser;
 import org.elasticsearch.common.xcontent.json.JsonXContent;
 import org.elasticsearch.test.rest.Stash;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -93,7 +92,7 @@ public class JsonPath {
     }
 
     private String[] parsePath(String path) {
-        List list = Lists.newArrayList();
+        List list = new ArrayList<>();
         StringBuilder current = new StringBuilder();
         boolean escape = false;
         for (int i = 0; i < path.length(); i++) {
diff --git a/core/src/test/java/org/elasticsearch/test/rest/parser/SkipSectionParser.java b/core/src/test/java/org/elasticsearch/test/rest/parser/SkipSectionParser.java
index 0a81583cf32..33733821019 100644
--- a/core/src/test/java/org/elasticsearch/test/rest/parser/SkipSectionParser.java
+++ b/core/src/test/java/org/elasticsearch/test/rest/parser/SkipSectionParser.java
@@ -18,12 +18,12 @@
  */
 package org.elasticsearch.test.rest.parser;
 
-import com.google.common.collect.Lists;
 import org.elasticsearch.common.Strings;
 import org.elasticsearch.common.xcontent.XContentParser;
 import org.elasticsearch.test.rest.section.SkipSection;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -40,7 +40,7 @@ public class SkipSectionParser implements RestTestFragmentParser {
         XContentParser.Token token;
         String version = null;
         String reason = null;
-        List features = Lists.newArrayList();
+        List features = new ArrayList<>();
 
         while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
             if (token == XContentParser.Token.FIELD_NAME) {
diff --git a/core/src/test/java/org/elasticsearch/test/rest/section/ApiCallSection.java b/core/src/test/java/org/elasticsearch/test/rest/section/ApiCallSection.java
index 2a49cd4c594..a40d2268d43 100644
--- a/core/src/test/java/org/elasticsearch/test/rest/section/ApiCallSection.java
+++ b/core/src/test/java/org/elasticsearch/test/rest/section/ApiCallSection.java
@@ -21,9 +21,9 @@ package org.elasticsearch.test.rest.section;
 import com.google.common.base.Joiner;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -34,7 +34,7 @@ public class ApiCallSection {
 
     private final String api;
     private final Map params = Maps.newHashMap();
-    private final List> bodies = Lists.newArrayList();
+    private final List> bodies = new ArrayList<>();
 
     public ApiCallSection(String api) {
         this.api = api;
diff --git a/core/src/test/java/org/elasticsearch/test/rest/section/RestTestSuite.java b/core/src/test/java/org/elasticsearch/test/rest/section/RestTestSuite.java
index a9047c18db1..923ba93521c 100644
--- a/core/src/test/java/org/elasticsearch/test/rest/section/RestTestSuite.java
+++ b/core/src/test/java/org/elasticsearch/test/rest/section/RestTestSuite.java
@@ -18,9 +18,9 @@
  */
 package org.elasticsearch.test.rest.section;
 
-import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
 
@@ -71,6 +71,6 @@ public class RestTestSuite {
     }
 
     public List getTestSections() {
-        return Lists.newArrayList(testSections);
+        return new ArrayList<>(testSections);
     }
 }
diff --git a/core/src/test/java/org/elasticsearch/test/rest/section/SetupSection.java b/core/src/test/java/org/elasticsearch/test/rest/section/SetupSection.java
index 72f653e6c8f..45c66fbad4f 100644
--- a/core/src/test/java/org/elasticsearch/test/rest/section/SetupSection.java
+++ b/core/src/test/java/org/elasticsearch/test/rest/section/SetupSection.java
@@ -18,8 +18,7 @@
  */
 package org.elasticsearch.test.rest.section;
 
-import com.google.common.collect.Lists;
-
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -36,7 +35,7 @@ public class SetupSection {
 
     private SkipSection skipSection;
 
-    private List doSections = Lists.newArrayList();
+    private List doSections = new ArrayList<>();
 
     public SkipSection getSkipSection() {
         return skipSection;
diff --git a/core/src/test/java/org/elasticsearch/test/rest/section/SkipSection.java b/core/src/test/java/org/elasticsearch/test/rest/section/SkipSection.java
index e7ab4555776..179d0a1e868 100644
--- a/core/src/test/java/org/elasticsearch/test/rest/section/SkipSection.java
+++ b/core/src/test/java/org/elasticsearch/test/rest/section/SkipSection.java
@@ -18,12 +18,11 @@
  */
 package org.elasticsearch.test.rest.section;
 
-import com.google.common.collect.Lists;
 import org.elasticsearch.Version;
-import org.elasticsearch.common.Strings;
 import org.elasticsearch.test.VersionUtils;
 import org.elasticsearch.test.rest.support.Features;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -44,7 +43,7 @@ public class SkipSection {
     private SkipSection() {
         this.lowerVersion = null;
         this.upperVersion = null;
-        this.features = Lists.newArrayList();
+        this.features = new ArrayList<>();
         this.reason = null;
     }
 
diff --git a/core/src/test/java/org/elasticsearch/test/rest/section/TestSection.java b/core/src/test/java/org/elasticsearch/test/rest/section/TestSection.java
index def613b1c56..3f44e5ce767 100644
--- a/core/src/test/java/org/elasticsearch/test/rest/section/TestSection.java
+++ b/core/src/test/java/org/elasticsearch/test/rest/section/TestSection.java
@@ -18,8 +18,7 @@
  */
 package org.elasticsearch.test.rest.section;
 
-import com.google.common.collect.Lists;
-
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -32,7 +31,7 @@ public class TestSection implements Comparable {
 
     public TestSection(String name) {
         this.name = name;
-        this.executableSections = Lists.newArrayList();
+        this.executableSections = new ArrayList<>();
     }
 
     public String getName() {
diff --git a/core/src/test/java/org/elasticsearch/test/rest/spec/RestApi.java b/core/src/test/java/org/elasticsearch/test/rest/spec/RestApi.java
index 0996df45b48..7931be1649f 100644
--- a/core/src/test/java/org/elasticsearch/test/rest/spec/RestApi.java
+++ b/core/src/test/java/org/elasticsearch/test/rest/spec/RestApi.java
@@ -18,11 +18,11 @@
  */
 package org.elasticsearch.test.rest.spec;
 
-import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.client.methods.HttpPut;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -35,10 +35,10 @@ import java.util.regex.Pattern;
 public class RestApi {
 
     private final String name;
-    private List methods = Lists.newArrayList();
-    private List paths = Lists.newArrayList();
-    private List pathParts = Lists.newArrayList();
-    private List params = Lists.newArrayList();
+    private List methods = new ArrayList<>();
+    private List paths = new ArrayList<>();
+    private List pathParts = new ArrayList<>();
+    private List params = new ArrayList<>();
     private BODY body = BODY.NOT_SUPPORTED;
 
     public static enum BODY {
@@ -63,7 +63,7 @@ public class RestApi {
     public List getSupportedMethods(Set restParams) {
         //we try to avoid hardcoded mappings but the index api is the exception
         if ("index".equals(name) || "create".equals(name)) {
-            List indexMethods = Lists.newArrayList();
+            List indexMethods = new ArrayList<>();
             for (String method : methods) {
                 if (restParams.contains("id")) {
                     //PUT when the id is provided
@@ -163,7 +163,7 @@ public class RestApi {
      */
     private List findMatchingRestPaths(Set restParams) {
 
-        List matchingRestPaths = Lists.newArrayList();
+        List matchingRestPaths = new ArrayList<>();
         RestPath[] restPaths = buildRestPaths();
 
         for (RestPath restPath : restPaths) {
diff --git a/core/src/test/java/org/elasticsearch/test/rest/support/Features.java b/core/src/test/java/org/elasticsearch/test/rest/support/Features.java
index 3b867262685..018d2413737 100644
--- a/core/src/test/java/org/elasticsearch/test/rest/support/Features.java
+++ b/core/src/test/java/org/elasticsearch/test/rest/support/Features.java
@@ -19,9 +19,9 @@
 
 package org.elasticsearch.test.rest.support;
 
-import com.google.common.collect.Lists;
 import org.elasticsearch.test.ESIntegTestCase;
 
+import java.util.Arrays;
 import java.util.List;
 
 /**
@@ -34,7 +34,7 @@ import java.util.List;
  */
 public final class Features {
 
-    private static final List SUPPORTED = Lists.newArrayList("stash_in_path", "groovy_scripting");
+    private static final List SUPPORTED = Arrays.asList("stash_in_path", "groovy_scripting");
 
     private Features() {
 
diff --git a/core/src/test/java/org/elasticsearch/watcher/FileWatcherTest.java b/core/src/test/java/org/elasticsearch/watcher/FileWatcherTest.java
index 457f7578f9b..537fd873a09 100644
--- a/core/src/test/java/org/elasticsearch/watcher/FileWatcherTest.java
+++ b/core/src/test/java/org/elasticsearch/watcher/FileWatcherTest.java
@@ -29,12 +29,10 @@ import java.nio.charset.Charset;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.StandardOpenOption;
+import java.util.ArrayList;
 import java.util.List;
 
-import static com.google.common.collect.Lists.newArrayList;
-import static org.hamcrest.Matchers.contains;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.*;
 
 @LuceneTestCase.SuppressFileSystems("ExtrasFS")
 public class FileWatcherTest extends ESTestCase {
@@ -51,7 +49,7 @@ public class FileWatcherTest extends ESTestCase {
             return rootDir.toUri().relativize(file.toUri()).getPath();
         }
 
-        private List notifications = newArrayList();
+        private List notifications = new ArrayList<>();
 
         @Override
         public void onFileInit(Path file) {
diff --git a/dev-tools/src/main/resources/forbidden/core-signatures.txt b/dev-tools/src/main/resources/forbidden/core-signatures.txt
index 796f3eec850..d95b793d1ef 100644
--- a/dev-tools/src/main/resources/forbidden/core-signatures.txt
+++ b/dev-tools/src/main/resources/forbidden/core-signatures.txt
@@ -84,3 +84,6 @@ java.util.concurrent.Future#cancel(boolean)
 @defaultMessage Don't try reading from paths that are not configured in Environment, resolve from Environment instead
 org.elasticsearch.common.io.PathUtils#get(java.lang.String, java.lang.String[])
 org.elasticsearch.common.io.PathUtils#get(java.net.URI)
+
+@defaultMessage avoid adding additional dependencies on Guava
+com.google.common.collect.Lists
diff --git a/plugins/cloud-azure/src/test/java/org/elasticsearch/cloud/azure/AzureComputeServiceSimpleMock.java b/plugins/cloud-azure/src/test/java/org/elasticsearch/cloud/azure/AzureComputeServiceSimpleMock.java
index 6323e91d1df..997a8aa17dc 100644
--- a/plugins/cloud-azure/src/test/java/org/elasticsearch/cloud/azure/AzureComputeServiceSimpleMock.java
+++ b/plugins/cloud-azure/src/test/java/org/elasticsearch/cloud/azure/AzureComputeServiceSimpleMock.java
@@ -78,10 +78,10 @@ public class AzureComputeServiceSimpleMock extends AzureComputeServiceAbstractMo
         endpoint.setName("elasticsearch");
         endpoint.setVirtualIPAddress(InetAddress.getLoopbackAddress());
         endpoint.setPort(9400);
-        instance.setInstanceEndpoints(CollectionUtils.newArrayList(endpoint));
+        instance.setInstanceEndpoints(CollectionUtils.newSingletonArrayList(endpoint));
 
-        deployment.setRoleInstances(CollectionUtils.newArrayList(instance));
-        response.setDeployments(CollectionUtils.newArrayList(deployment));
+        deployment.setRoleInstances(CollectionUtils.newSingletonArrayList(instance));
+        response.setDeployments(CollectionUtils.newSingletonArrayList(deployment));
 
         return response;
     }
diff --git a/plugins/cloud-azure/src/test/java/org/elasticsearch/cloud/azure/AzureComputeServiceTwoNodesMock.java b/plugins/cloud-azure/src/test/java/org/elasticsearch/cloud/azure/AzureComputeServiceTwoNodesMock.java
index a87a4ef3434..ee8bf350f63 100644
--- a/plugins/cloud-azure/src/test/java/org/elasticsearch/cloud/azure/AzureComputeServiceTwoNodesMock.java
+++ b/plugins/cloud-azure/src/test/java/org/elasticsearch/cloud/azure/AzureComputeServiceTwoNodesMock.java
@@ -19,15 +19,22 @@
 
 package org.elasticsearch.cloud.azure;
 
-import com.microsoft.windowsazure.management.compute.models.*;
+import com.microsoft.windowsazure.management.compute.models.DeploymentSlot;
+import com.microsoft.windowsazure.management.compute.models.DeploymentStatus;
+import com.microsoft.windowsazure.management.compute.models.HostedServiceGetDetailedResponse;
+import com.microsoft.windowsazure.management.compute.models.InstanceEndpoint;
+import com.microsoft.windowsazure.management.compute.models.RoleInstance;
 import org.elasticsearch.cloud.azure.management.AzureComputeServiceAbstractMock;
 import org.elasticsearch.common.inject.Inject;
 import org.elasticsearch.common.network.NetworkService;
 import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.common.util.CollectionUtils;
 import org.elasticsearch.plugins.Plugin;
 
 import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import static org.elasticsearch.common.util.CollectionUtils.newSingletonArrayList;
 
 
 /**
@@ -78,7 +85,7 @@ public class AzureComputeServiceTwoNodesMock extends AzureComputeServiceAbstract
         endpoint1.setName("elasticsearch");
         endpoint1.setVirtualIPAddress(InetAddress.getLoopbackAddress());
         endpoint1.setPort(9400);
-        instance1.setInstanceEndpoints(CollectionUtils.newArrayList(endpoint1));
+        instance1.setInstanceEndpoints(newSingletonArrayList(endpoint1));
 
         // Fake a first instance
         RoleInstance instance2 = new RoleInstance();
@@ -92,11 +99,11 @@ public class AzureComputeServiceTwoNodesMock extends AzureComputeServiceAbstract
         endpoint2.setName("elasticsearch");
         endpoint2.setVirtualIPAddress(InetAddress.getLoopbackAddress());
         endpoint2.setPort(9401);
-        instance2.setInstanceEndpoints(CollectionUtils.newArrayList(endpoint2));
+        instance2.setInstanceEndpoints(newSingletonArrayList(endpoint2));
 
-        deployment.setRoleInstances(CollectionUtils.newArrayList(instance1, instance2));
+        deployment.setRoleInstances(new ArrayList<>(Arrays.asList(instance1, instance2)));
 
-        response.setDeployments(CollectionUtils.newArrayList(deployment));
+        response.setDeployments(newSingletonArrayList(deployment));
 
         return response;
     }
diff --git a/plugins/cloud-gce/src/main/java/org/elasticsearch/cloud/gce/GceComputeServiceImpl.java b/plugins/cloud-gce/src/main/java/org/elasticsearch/cloud/gce/GceComputeServiceImpl.java
index 7e6d3548674..7321d032d69 100644
--- a/plugins/cloud-gce/src/main/java/org/elasticsearch/cloud/gce/GceComputeServiceImpl.java
+++ b/plugins/cloud-gce/src/main/java/org/elasticsearch/cloud/gce/GceComputeServiceImpl.java
@@ -29,12 +29,12 @@ import com.google.api.services.compute.model.Instance;
 import com.google.api.services.compute.model.InstanceList;
 import com.google.common.base.Function;
 import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
 import org.elasticsearch.ElasticsearchException;
 import org.elasticsearch.common.component.AbstractLifecycleComponent;
 import org.elasticsearch.common.inject.Inject;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.common.unit.TimeValue;
+import org.elasticsearch.common.util.CollectionUtils;
 
 import java.io.IOException;
 import java.security.GeneralSecurityException;
@@ -43,6 +43,8 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 
+import static org.elasticsearch.common.util.CollectionUtils.eagerTransform;
+
 /**
  *
  */
@@ -62,7 +64,7 @@ public class GceComputeServiceImpl extends AbstractLifecycleComponent> instanceListByZone = Lists.transform(zones, new Function>() {
+            List> instanceListByZone = eagerTransform(zones, new Function>() {
                 @Override
                 public List apply(String zoneId) {
                     try {
@@ -83,7 +85,7 @@ public class GceComputeServiceImpl extends AbstractLifecycleComponent instanceList = Lists.newArrayList(Iterables.concat(instanceListByZone));
+            List instanceList = CollectionUtils.iterableAsArrayList(Iterables.concat(instanceListByZone));
 
             if (instanceList.size() == 0) {
                 logger.warn("disabling GCE discovery. Can not get list of nodes");