You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by kr...@apache.org on 2023/03/23 02:06:47 UTC
[solr] branch branch_9x updated: SOLR-16713: Replace Guava usages with pure Java (#1466)
This is an automated email from the ASF dual-hosted git repository.
krisden pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new d0942e92ebb SOLR-16713: Replace Guava usages with pure Java (#1466)
d0942e92ebb is described below
commit d0942e92ebb600add8b078869d7a81482e263144
Author: Kevin Risden <ri...@users.noreply.github.com>
AuthorDate: Wed Mar 22 10:29:39 2023 -0400
SOLR-16713: Replace Guava usages with pure Java (#1466)
Guava is used in a variety of places that can be simplified especially with Java streams.
* Preconditions -> Objects
* Strings.isNullOrEmpty -> Simple helper method on StrUtils
* Maps/ImmutableMap -> Java Map
* Lists/ImmutableList -> Java List
* Sets/ImmutableSet/ImmutableSortedSet -> Java Set
* Collections2/Iterables/Iterators/ObjectArrays -> Java Stream
* Guava cache -> Caffeine cache
This ends up removing the Guava dependency from 4 build.gradle files:
* modules/analytics
* modules/sql
* modules/gcs-repository - test
* solrj - test
---
.../forbidden-apis/com.google.guava.guava.all.txt | 29 ++-
solr/CHANGES.txt | 2 +
solr/core/src/java/org/apache/solr/api/Api.java | 5 +-
solr/core/src/java/org/apache/solr/api/ApiBag.java | 25 +--
.../src/java/org/apache/solr/api/V2HttpCall.java | 4 +-
.../org/apache/solr/cloud/CloudDescriptor.java | 8 +-
.../apache/solr/cloud/OverseerTaskProcessor.java | 3 +-
.../solr/cloud/SizeLimitedDistributedMap.java | 4 +-
.../java/org/apache/solr/cloud/ZkController.java | 3 +-
.../cloud/ZkDistributedCollectionLockFactory.java | 18 +-
.../cloud/ZkDistributedConfigSetLockFactory.java | 4 +-
.../org/apache/solr/cloud/ZkDistributedQueue.java | 5 +-
.../solr/cloud/api/collections/CreateAliasCmd.java | 6 +-
.../solr/cloud/api/collections/RoutedAlias.java | 4 +-
.../apache/solr/cloud/overseer/SliceMutator.java | 4 +-
.../impl/SimpleClusterAbstractionsImpl.java | 6 +-
.../java/org/apache/solr/core/CoreContainer.java | 10 +-
.../java/org/apache/solr/core/CoreDescriptor.java | 26 ++-
.../apache/solr/core/CorePropertiesLocator.java | 4 +-
.../src/java/org/apache/solr/core/InitParams.java | 3 +-
.../java/org/apache/solr/core/RequestParams.java | 16 +-
.../src/java/org/apache/solr/core/SolrConfig.java | 152 ++++++--------
.../src/java/org/apache/solr/core/SolrCore.java | 11 +-
.../org/apache/solr/core/SolrResourceLoader.java | 3 +-
.../java/org/apache/solr/core/SolrXmlConfig.java | 8 +-
.../org/apache/solr/core/backup/BackupManager.java | 5 +-
.../repository/LocalFileSystemRepository.java | 9 +-
.../java/org/apache/solr/handler/BlobHandler.java | 4 +-
.../java/org/apache/solr/handler/ClusterAPI.java | 15 +-
.../java/org/apache/solr/handler/IndexFetcher.java | 4 +-
.../apache/solr/handler/MoreLikeThisHandler.java | 3 +-
.../apache/solr/handler/RealTimeGetHandler.java | 3 +-
.../apache/solr/handler/RequestHandlerBase.java | 4 +-
.../org/apache/solr/handler/SolrConfigHandler.java | 6 +-
.../solr/handler/admin/BaseHandlerApiSupport.java | 6 +-
.../solr/handler/admin/CollectionsHandler.java | 9 +-
.../solr/handler/admin/ConfigSetsHandler.java | 3 +-
.../solr/handler/admin/CoreAdminHandler.java | 36 ++--
.../org/apache/solr/handler/admin/InfoHandler.java | 7 +-
.../apache/solr/handler/admin/MergeIndexesOp.java | 10 +-
.../solr/handler/admin/SecurityConfHandler.java | 3 +-
.../solr/handler/admin/ShowFileRequestHandler.java | 4 +-
.../solr/handler/admin/api/DeleteShardAPI.java | 4 +-
.../solr/handler/admin/api/ForceLeaderAPI.java | 4 +-
.../admin/api/RequestCoreCommandStatusAPI.java | 4 +-
.../solr/handler/admin/api/SyncShardAPI.java | 4 +-
.../handler/component/QueryElevationComponent.java | 76 ++++---
.../handler/component/RealTimeGetComponent.java | 11 +-
.../handler/component/ShardHandlerFactory.java | 4 +-
.../handler/configsets/DeleteConfigSetAPI.java | 4 +-
.../handler/designer/DefaultSchemaSuggester.java | 3 +-
.../solr/handler/designer/ManagedSchemaDiff.java | 3 +-
.../designer/SchemaDesignerConfigSetHelper.java | 11 +-
.../org/apache/solr/handler/loader/XMLLoader.java | 3 +-
.../apache/solr/packagemanager/PackageManager.java | 16 +-
.../apache/solr/parser/SolrQueryParserBase.java | 6 +-
.../solr/response/TabularResponseWriter.java | 12 +-
.../transform/RawValueTransformerFactory.java | 4 +-
.../solr/schema/AbstractSpatialFieldType.java | 14 +-
.../java/org/apache/solr/schema/IndexSchema.java | 5 +-
.../org/apache/solr/search/SolrIndexSearcher.java | 7 +-
.../org/apache/solr/search/facet/FacetRequest.java | 3 +-
.../org/apache/solr/security/BasicAuthPlugin.java | 3 +-
.../java/org/apache/solr/security/Permission.java | 6 +-
.../security/Sha256AuthenticationProvider.java | 3 +-
.../org/apache/solr/update/DocumentBuilder.java | 4 +-
.../src/java/org/apache/solr/util/CryptoKeys.java | 3 +-
.../java/org/apache/solr/util/DistanceUnits.java | 5 +-
.../src/java/org/apache/solr/util/ExportTool.java | 3 +-
.../java/org/apache/solr/util/SolrPluginUtils.java | 4 +-
.../SSLCredentialProviderFactory.java | 3 +-
.../providers/AbstractSSLCredentialProvider.java | 7 +-
.../providers/EnvSSLCredentialProvider.java | 6 +-
.../test/org/apache/solr/TestCrossCoreJoin.java | 4 +-
.../apache/solr/cloud/CollectionsAPISolrJTest.java | 23 ++-
.../solr/cloud/NestedShardedAtomicUpdateTest.java | 20 +-
.../org/apache/solr/cloud/TestConfigSetsAPI.java | 11 +-
.../solr/cloud/TestConfigSetsAPIZkFailure.java | 3 +-
.../test/org/apache/solr/cloud/TestLockTree.java | 7 +-
.../cloud/api/collections/TestCollectionAPI.java | 3 +-
.../test/org/apache/solr/core/TestConfigSets.java | 8 +-
.../org/apache/solr/core/TestCoreContainer.java | 28 ++-
.../org/apache/solr/core/TestCoreDiscovery.java | 10 +-
.../test/org/apache/solr/core/TestLazyCores.java | 3 +-
.../apache/solr/core/TestSolrConfigHandler.java | 7 +-
.../solr/handler/V2ClusterAPIMappingTest.java | 3 +-
.../solr/handler/V2UpdateAPIMappingTest.java | 3 +-
.../solr/handler/admin/CoreAdminOperationTest.java | 48 ++---
.../solr/handler/admin/V2ApiMappingTest.java | 3 +-
.../handler/admin/api/V2NodeAPIMappingTest.java | 3 +-
.../handler/designer/TestSchemaDesignerAPI.java | 5 +-
.../TestChildDocTransformerHierarchy.java | 6 +-
.../TestSubQueryTransformerCrossCore.java | 4 +-
.../org/apache/solr/schema/TestPointFields.java | 27 ++-
.../org/apache/solr/search/TestIndexSearcher.java | 7 +-
.../apache/solr/update/SolrIndexSplitterTest.java | 21 +-
.../AbstractAtomicUpdatesMultivalueTestBase.java | 29 ++-
.../solr/update/processor/AtomicUpdatesTest.java | 218 ++++++++-------------
.../SkipExistingDocumentsProcessorFactoryTest.java | 4 +-
.../processor/TestPartialUpdateDeduplication.java | 7 +-
.../src/test/org/apache/solr/util/TestUtils.java | 7 +-
.../providers/EnvSSLCredentialProviderTest.java | 3 +-
solr/modules/analytics/build.gradle | 1 -
.../apache/solr/analytics/facet/SortableFacet.java | 11 +-
.../legacy/LegacyAbstractAnalyticsTest.java | 12 +-
.../facet/LegacyAbstractAnalyticsFacetTest.java | 17 +-
solr/modules/gcs-repository/build.gradle | 1 -
.../solr/gcs/LocalStorageGCSBackupRepository.java | 7 +-
.../org/apache/solr/hdfs/HdfsDirectoryFactory.java | 42 ++--
.../backup/repository/HdfsBackupRepository.java | 5 +-
.../solr/hdfs/snapshots/SolrSnapshotsTool.java | 28 +--
.../java/org/apache/solr/s3/S3StorageClient.java | 2 +
solr/modules/sql/build.gradle | 2 -
.../org/apache/solr/handler/sql/SolrFilter.java | 14 +-
.../org/apache/solr/handler/sql/SolrSchema.java | 5 +-
.../handler/sql/SolrToEnumerableConverter.java | 4 +-
.../solr/common/cloud/TestPerReplicaStates.java | 24 +--
solr/solrj/build.gradle | 1 -
.../apache/solr/common/util/CollectionUtil.java | 52 +++++
.../java/org/apache/solr/common/util/StrUtils.java | 4 +
.../CollectionAdminRequestRequiredParamsTest.java | 11 +-
.../apache/solr/client/solrj/SolrExampleTests.java | 5 +-
.../impl/CloudHttp2SolrClientBadInputTest.java | 9 +-
.../solrj/impl/CloudHttp2SolrClientTest.java | 11 +-
.../solrj/impl/CloudSolrClientBadInputTest.java | 9 +-
.../solrj/impl/CloudSolrClientCacheTest.java | 3 +-
.../client/solrj/impl/CloudSolrClientTest.java | 11 +-
...oncurrentUpdateHttp2SolrClientBadInputTest.java | 17 +-
.../ConcurrentUpdateSolrClientBadInputTest.java | 17 +-
.../solrj/impl/HttpSolrClientBadInputTest.java | 17 +-
.../solrj/impl/LBHttpSolrClientBadInputTest.java | 17 +-
.../org/apache/solr/common/util/TestPathTrie.java | 5 +-
.../solr/common/util/TestValidatingJsonMap.java | 6 +-
.../collections/AbstractBackupRepositoryTest.java | 13 +-
...bstractCollectionsAPIDistributedZkTestBase.java | 4 +-
.../src/java/org/apache/solr/util/TestHarness.java | 3 +-
136 files changed, 793 insertions(+), 861 deletions(-)
diff --git a/gradle/validation/forbidden-apis/com.google.guava.guava.all.txt b/gradle/validation/forbidden-apis/com.google.guava.guava.all.txt
index e1768ea18b9..7ded09d9789 100644
--- a/gradle/validation/forbidden-apis/com.google.guava.guava.all.txt
+++ b/gradle/validation/forbidden-apis/com.google.guava.guava.all.txt
@@ -10,7 +10,34 @@ com.google.common.base.Charsets
@defaultMessage Use methods in java.util.Objects instead
com.google.common.base.Objects#equal(**)
com.google.common.base.Objects#hashCode(**)
-com.google.common.base.Preconditions#checkNotNull(**)
+com.google.common.base.Preconditions
@defaultMessage Use methods in java.util.Comparator instead
com.google.common.collect.Ordering
+
+@defaultMessage Use methods in java.util.Map
+com.google.common.collect.Maps
+com.google.common.collect.ImmutableMap
+
+@defaultMessage Use methods in java.util.List
+com.google.common.collect.Lists
+com.google.common.collect.ImmutableList
+
+@defaultMessage Use methods in java.util.Set
+com.google.common.collect.Sets
+com.google.common.collect.ImmutableSet
+com.google.common.collect.ImmutableSortedSet
+
+@defaultMessage Use Java stream methods
+com.google.common.collect.Collections2
+com.google.common.collect.Iterables
+com.google.common.collect.Iterators
+com.google.common.collect.ObjectArrays
+
+@defaultMessage Use org.apache.solr.common.util.StrUtils
+com.google.common.base.Strings
+
+@defaultMessage Use Caffeine cache instead
+com.google.common.cache.**
+
+# TODO com.google.common.base.MoreObjects
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 116accea0fd..7a1d6a47e3c 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -44,6 +44,8 @@ Other Changes
* SOLR-16709: Update Solr's internal use of Solr Client Builders to use TimeUnit parameter for time specific builder methods. (Eric Pugh)
+* SOLR-16713: Replace Guava usages with pure Java (Kevin Risden)
+
================== 9.2.0 ==================
New Features
diff --git a/solr/core/src/java/org/apache/solr/api/Api.java b/solr/core/src/java/org/apache/solr/api/Api.java
index 91389e7ebf7..54010912ae2 100644
--- a/solr/core/src/java/org/apache/solr/api/Api.java
+++ b/solr/core/src/java/org/apache/solr/api/Api.java
@@ -17,7 +17,6 @@
package org.apache.solr.api;
-import com.google.common.collect.ImmutableMap;
import java.util.Map;
import org.apache.solr.common.SpecProvider;
import org.apache.solr.common.util.JsonSchemaValidator;
@@ -44,9 +43,7 @@ public abstract class Api implements SpecProvider {
if (commandSchema == null) {
ValidatingJsonMap commands = getSpec().getMap("commands", null);
commandSchema =
- commands != null
- ? ImmutableMap.copyOf(ApiBag.getParsedSchema(commands))
- : ImmutableMap.of();
+ commands != null ? Map.copyOf(ApiBag.getParsedSchema(commands)) : Map.of();
}
}
}
diff --git a/solr/core/src/java/org/apache/solr/api/ApiBag.java b/solr/core/src/java/org/apache/solr/api/ApiBag.java
index c9bd0530d4b..48359f783b1 100644
--- a/solr/core/src/java/org/apache/solr/api/ApiBag.java
+++ b/solr/core/src/java/org/apache/solr/api/ApiBag.java
@@ -23,13 +23,10 @@ import static org.apache.solr.common.util.StrUtils.formatString;
import static org.apache.solr.common.util.ValidatingJsonMap.ENUM_OF;
import static org.apache.solr.common.util.ValidatingJsonMap.NOT_NULL;
-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 java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -150,8 +147,8 @@ public class ApiBag {
private Collection<AnnotatedApi> combinedApis;
protected CommandAggregatingAnnotatedApi(AnnotatedApi api) {
- super(api.spec, api.getEndPoint(), Maps.newHashMap(api.getCommands()), null);
- combinedApis = Lists.newArrayList();
+ super(api.spec, api.getEndPoint(), new HashMap<>(api.getCommands()), null);
+ combinedApis = new ArrayList<>();
}
public void combineWith(AnnotatedApi api) {
@@ -196,7 +193,7 @@ public class ApiBag {
PathTrie<Api> registry = apis.get(method);
if (registry == null)
- apis.put(method, registry = new CommandAggregatingPathTrie(ImmutableSet.of("_introspect")));
+ apis.put(method, registry = new CommandAggregatingPathTrie(Set.of("_introspect")));
ValidatingJsonMap url = spec.getMap("url", NOT_NULL);
ValidatingJsonMap params = url.getMap("params", null);
if (params != null) {
@@ -213,8 +210,7 @@ public class ApiBag {
if (!wildCardNames.contains(o.toString()))
throw new RuntimeException("" + o + " is not a valid part name");
ValidatingJsonMap pathMeta = parts.getMap(o.toString(), NOT_NULL);
- pathMeta.get(
- "type", ENUM_OF, ImmutableSet.of("enum", "string", "int", "number", "boolean"));
+ pathMeta.get("type", ENUM_OF, Set.of("enum", "string", "int", "number", "boolean"));
}
}
verifyCommands(api.getSpec());
@@ -376,21 +372,20 @@ public class ApiBag {
}
public static List<Api> wrapRequestHandlers(final SolrRequestHandler rh, String... specs) {
- ImmutableList.Builder<Api> b = ImmutableList.builder();
- for (String spec : specs) b.add(new ReqHandlerToApi(rh, Utils.getSpec(spec)));
- return b.build();
+ return Arrays.stream(specs)
+ .map(spec -> new ReqHandlerToApi(rh, Utils.getSpec(spec)))
+ .collect(Collectors.toUnmodifiableList());
}
public static final String HANDLER_NAME = "handlerName";
public static final SpecProvider EMPTY_SPEC = () -> ValidatingJsonMap.EMPTY;
public static final Set<String> KNOWN_TYPES =
- ImmutableSet.of("string", "boolean", "list", "int", "double", "object");
-
+ Set.of("string", "boolean", "list", "int", "double", "object");
// A Spec template for GET AND POST APIs using the /$handlerName template-variable.
public static final SpecProvider HANDLER_NAME_SPEC_PROVIDER =
() -> {
final ValidatingJsonMap spec = new ValidatingJsonMap();
- spec.put("methods", Lists.newArrayList("GET", "POST"));
+ spec.put("methods", List.of("GET", "POST"));
final ValidatingJsonMap urlMap = new ValidatingJsonMap();
urlMap.put("paths", Collections.singletonList("$" + HANDLER_NAME));
spec.put("url", urlMap);
diff --git a/solr/core/src/java/org/apache/solr/api/V2HttpCall.java b/solr/core/src/java/org/apache/solr/api/V2HttpCall.java
index ad8c4308fe6..46c66e403df 100644
--- a/solr/core/src/java/org/apache/solr/api/V2HttpCall.java
+++ b/solr/core/src/java/org/apache/solr/api/V2HttpCall.java
@@ -23,7 +23,6 @@ import static org.apache.solr.servlet.SolrDispatchFilter.Action.ADMIN_OR_REMOTEQ
import static org.apache.solr.servlet.SolrDispatchFilter.Action.PROCESS;
import static org.apache.solr.servlet.SolrDispatchFilter.Action.REMOTEQUERY;
-import com.google.common.collect.ImmutableSet;
import io.opentracing.Span;
import io.opentracing.tag.Tags;
import java.io.IOException;
@@ -81,8 +80,7 @@ public class V2HttpCall extends HttpSolrCall {
private boolean servedByJaxRs =
false; // A flag indicating whether the request was served by JAX-RS or the native framework
HashMap<String, String> parts = new HashMap<>();
- static final Set<String> knownPrefixes =
- ImmutableSet.of("cluster", "node", "collections", "cores", "c");
+ static final Set<String> knownPrefixes = Set.of("cluster", "node", "collections", "cores", "c");
public V2HttpCall(
SolrDispatchFilter solrDispatchFilter,
diff --git a/solr/core/src/java/org/apache/solr/cloud/CloudDescriptor.java b/solr/core/src/java/org/apache/solr/cloud/CloudDescriptor.java
index 3fab10c2d6a..d38f5fca1c4 100644
--- a/solr/core/src/java/org/apache/solr/cloud/CloudDescriptor.java
+++ b/solr/core/src/java/org/apache/solr/cloud/CloudDescriptor.java
@@ -16,13 +16,13 @@
*/
package org.apache.solr.cloud;
-import com.google.common.base.Strings;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import org.apache.solr.common.StringUtils;
import org.apache.solr.common.cloud.Replica;
import org.apache.solr.common.util.PropertiesUtil;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.core.CoreDescriptor;
/** SolrCloud metadata attached to a {@link CoreDescriptor}. */
@@ -54,15 +54,15 @@ public class CloudDescriptor {
public CloudDescriptor(CoreDescriptor cd, String coreName, Properties props) {
this.cd = cd;
this.shardId = props.getProperty(CoreDescriptor.CORE_SHARD, null);
- if (Strings.isNullOrEmpty(shardId)) this.shardId = null;
+ if (StrUtils.isNullOrEmpty(shardId)) this.shardId = null;
// If no collection name is specified, we default to the core name
this.collectionName = props.getProperty(CoreDescriptor.CORE_COLLECTION, coreName);
this.roles = props.getProperty(CoreDescriptor.CORE_ROLES, null);
this.nodeName = props.getProperty(CoreDescriptor.CORE_NODE_NAME);
- if (Strings.isNullOrEmpty(nodeName)) this.nodeName = null;
+ if (StrUtils.isNullOrEmpty(nodeName)) this.nodeName = null;
this.numShards = PropertiesUtil.toInteger(props.getProperty(CloudDescriptor.NUM_SHARDS), null);
String replicaTypeStr = props.getProperty(CloudDescriptor.REPLICA_TYPE);
- if (Strings.isNullOrEmpty(replicaTypeStr)) {
+ if (StrUtils.isNullOrEmpty(replicaTypeStr)) {
this.replicaType = Replica.Type.NRT;
} else {
this.replicaType = Replica.Type.valueOf(replicaTypeStr);
diff --git a/solr/core/src/java/org/apache/solr/cloud/OverseerTaskProcessor.java b/solr/core/src/java/org/apache/solr/cloud/OverseerTaskProcessor.java
index ca88c24baa9..e249e013895 100644
--- a/solr/core/src/java/org/apache/solr/cloud/OverseerTaskProcessor.java
+++ b/solr/core/src/java/org/apache/solr/cloud/OverseerTaskProcessor.java
@@ -20,7 +20,6 @@ import static org.apache.solr.common.params.CommonAdminParams.ASYNC;
import static org.apache.solr.common.params.CommonParams.ID;
import com.codahale.metrics.Timer;
-import com.google.common.collect.ImmutableSet;
import java.io.Closeable;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
@@ -124,7 +123,7 @@ public class OverseerTaskProcessor implements Runnable, Closeable {
@Override
public String toString() {
- return StrUtils.join(ImmutableSet.of(runningTasks, blockedTasks.keySet()), ',');
+ return StrUtils.join(Set.of(runningTasks, blockedTasks.keySet()), ',');
}
};
diff --git a/solr/core/src/java/org/apache/solr/cloud/SizeLimitedDistributedMap.java b/solr/core/src/java/org/apache/solr/cloud/SizeLimitedDistributedMap.java
index db36edbee1a..ab495fffea8 100644
--- a/solr/core/src/java/org/apache/solr/cloud/SizeLimitedDistributedMap.java
+++ b/solr/core/src/java/org/apache/solr/cloud/SizeLimitedDistributedMap.java
@@ -16,11 +16,11 @@
*/
package org.apache.solr.cloud;
-import com.google.common.collect.Maps;
import java.util.List;
import java.util.Map;
import org.apache.lucene.util.PriorityQueue;
import org.apache.solr.common.cloud.SolrZkClient;
+import org.apache.solr.common.util.CollectionUtil;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.data.Stat;
@@ -77,7 +77,7 @@ public class SizeLimitedDistributedMap extends DistributedMap {
}
};
- Map<String, Long> childToModificationZxid = Maps.newHashMapWithExpectedSize(children.size());
+ Map<String, Long> childToModificationZxid = CollectionUtil.newHashMap(children.size());
for (String child : children) {
Stat stat = zookeeper.exists(dir + "/" + child, null, true);
if (stat != null) {
diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkController.java b/solr/core/src/java/org/apache/solr/cloud/ZkController.java
index f4e7eda8558..ca196e8b9d8 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java
@@ -27,7 +27,6 @@ import static org.apache.solr.common.cloud.ZkStateReader.SHARD_ID_PROP;
import static org.apache.solr.common.params.CollectionParams.CollectionAction.ADDROLE;
import static org.apache.zookeeper.ZooDefs.Ids.OPEN_ACL_UNSAFE;
-import com.google.common.base.Strings;
import java.io.Closeable;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
@@ -1854,7 +1853,7 @@ public class ZkController implements Closeable {
getCollectionTerms(collection).remove(cd.getCloudDescriptor().getShardId(), cd);
replicasMetTragicEvent.remove(collection + ":" + coreNodeName);
- if (Strings.isNullOrEmpty(collection)) {
+ if (StrUtils.isNullOrEmpty(collection)) {
log.error("No collection was specified.");
assert false : "No collection was specified [" + collection + "]";
return;
diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkDistributedCollectionLockFactory.java b/solr/core/src/java/org/apache/solr/cloud/ZkDistributedCollectionLockFactory.java
index 9d787289c87..fe77b18c3f2 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ZkDistributedCollectionLockFactory.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ZkDistributedCollectionLockFactory.java
@@ -17,7 +17,7 @@
package org.apache.solr.cloud;
-import com.google.common.base.Preconditions;
+import java.util.Objects;
import org.apache.solr.cloud.api.collections.DistributedCollectionConfigSetCommandRunner;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.cloud.SolrZkClient;
@@ -45,13 +45,15 @@ public class ZkDistributedCollectionLockFactory extends ZkDistributedLockFactory
String collName,
String shardId,
String replicaName) {
- Preconditions.checkArgument(collName != null, "collName can't be null");
- Preconditions.checkArgument(
- level == CollectionParams.LockLevel.COLLECTION || shardId != null,
- "shardId can't be null when getting lock for shard or replica");
- Preconditions.checkArgument(
- level != CollectionParams.LockLevel.REPLICA || replicaName != null,
- "replicaName can't be null when getting lock for replica");
+ Objects.requireNonNull(collName, "collName can't be null");
+ if (level != CollectionParams.LockLevel.COLLECTION) {
+ Objects.requireNonNull(
+ shardId, "shardId can't be null when getting lock for shard or replica");
+ }
+ if (level == CollectionParams.LockLevel.REPLICA) {
+ Objects.requireNonNull(
+ replicaName, "replicaName can't be null when getting lock for replica");
+ }
String lockPath = getLockPath(level, collName, shardId, replicaName);
return doCreateLock(isWriteLock, lockPath);
diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkDistributedConfigSetLockFactory.java b/solr/core/src/java/org/apache/solr/cloud/ZkDistributedConfigSetLockFactory.java
index 488c69932a0..884703a8829 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ZkDistributedConfigSetLockFactory.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ZkDistributedConfigSetLockFactory.java
@@ -17,7 +17,7 @@
package org.apache.solr.cloud;
-import com.google.common.base.Preconditions;
+import java.util.Objects;
import org.apache.solr.common.cloud.SolrZkClient;
/**
@@ -37,7 +37,7 @@ public class ZkDistributedConfigSetLockFactory extends ZkDistributedLockFactory
@Override
public DistributedLock createLock(boolean isWriteLock, String configSetName) {
- Preconditions.checkArgument(configSetName != null, "configSetName can't be null");
+ Objects.requireNonNull(configSetName, "configSetName can't be null");
String lockPath = getLockPath(configSetName);
return doCreateLock(isWriteLock, lockPath);
diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkDistributedQueue.java b/solr/core/src/java/org/apache/solr/cloud/ZkDistributedQueue.java
index f2009301a07..39a1de01feb 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ZkDistributedQueue.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ZkDistributedQueue.java
@@ -18,7 +18,6 @@ package org.apache.solr.cloud;
import com.codahale.metrics.Timer;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
import java.util.Collection;
@@ -187,7 +186,9 @@ public class ZkDistributedQueue implements DistributedQueue {
*/
@Override
public byte[] peek(long wait) throws KeeperException, InterruptedException {
- Preconditions.checkArgument(wait > 0);
+ if (wait < 0) {
+ throw new IllegalArgumentException("Wait must be greater than 0. Wait was " + wait);
+ }
Timer.Context time;
if (wait == Long.MAX_VALUE) {
time = stats.time(dir + "_peek_wait_forever");
diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateAliasCmd.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateAliasCmd.java
index e4cd3ebb4fd..58932e3033c 100644
--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateAliasCmd.java
+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateAliasCmd.java
@@ -19,7 +19,6 @@ package org.apache.solr.cloud.api.collections;
import static org.apache.solr.common.SolrException.ErrorCode.BAD_REQUEST;
import static org.apache.solr.common.SolrException.ErrorCode.SERVER_ERROR;
-import com.google.common.collect.Sets;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap;
@@ -136,8 +135,9 @@ public class CreateAliasCmd extends AliasCmd {
throw new SolrException(
BAD_REQUEST,
"Not all required params were supplied. Missing params: "
- + StrUtils.join(
- Sets.difference(routedAlias.getRequiredParams(), props.keySet()), ','));
+ + routedAlias.getRequiredParams().stream()
+ .filter(e -> !props.containsKey(e))
+ .collect(Collectors.joining(",")));
}
// Create the first collection.
diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/RoutedAlias.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/RoutedAlias.java
index 1c196dd427e..93abb90faf4 100644
--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/RoutedAlias.java
+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/RoutedAlias.java
@@ -21,7 +21,6 @@ import static org.apache.solr.common.SolrException.ErrorCode.BAD_REQUEST;
import static org.apache.solr.common.SolrException.ErrorCode.SERVER_ERROR;
import static org.apache.solr.common.params.CollectionAdminParams.ROUTER_PREFIX;
-import com.google.common.collect.Sets;
import java.lang.invoke.MethodHandles;
import java.util.AbstractMap.SimpleEntry;
import java.util.ArrayList;
@@ -60,8 +59,7 @@ public abstract class RoutedAlias {
public static final String CREATE_COLLECTION_PREFIX = "create-collection.";
@SuppressWarnings("WeakerAccess")
- public static final Set<String> MINIMAL_REQUIRED_PARAMS =
- Sets.newHashSet(ROUTER_TYPE_NAME, ROUTER_FIELD);
+ public static final Set<String> MINIMAL_REQUIRED_PARAMS = Set.of(ROUTER_TYPE_NAME, ROUTER_FIELD);
public static final String ROUTED_ALIAS_NAME_CORE_PROP = "routedAliasName"; // core prop
private static final String DIMENSIONAL = "Dimensional[";
diff --git a/solr/core/src/java/org/apache/solr/cloud/overseer/SliceMutator.java b/solr/core/src/java/org/apache/solr/cloud/overseer/SliceMutator.java
index 47909e8ca28..c83a965d5a1 100644
--- a/solr/core/src/java/org/apache/solr/cloud/overseer/SliceMutator.java
+++ b/solr/core/src/java/org/apache/solr/cloud/overseer/SliceMutator.java
@@ -18,7 +18,6 @@ package org.apache.solr.cloud.overseer;
import static org.apache.solr.cloud.overseer.CollectionMutator.checkCollectionKeyExistence;
-import com.google.common.collect.ImmutableSet;
import java.lang.invoke.MethodHandles;
import java.util.HashMap;
import java.util.LinkedHashMap;
@@ -50,8 +49,7 @@ public class SliceMutator {
public static final String PREFERRED_LEADER_PROP =
CollectionAdminParams.PROPERTY_PREFIX + "preferredleader";
- public static final Set<String> SLICE_UNIQUE_BOOLEAN_PROPERTIES =
- ImmutableSet.of(PREFERRED_LEADER_PROP);
+ public static final Set<String> SLICE_UNIQUE_BOOLEAN_PROPERTIES = Set.of(PREFERRED_LEADER_PROP);
protected final SolrCloudManager cloudManager;
protected final DistribStateManager stateManager;
diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/impl/SimpleClusterAbstractionsImpl.java b/solr/core/src/java/org/apache/solr/cluster/placement/impl/SimpleClusterAbstractionsImpl.java
index 3fede98a576..c685e25303c 100644
--- a/solr/core/src/java/org/apache/solr/cluster/placement/impl/SimpleClusterAbstractionsImpl.java
+++ b/solr/core/src/java/org/apache/solr/cluster/placement/impl/SimpleClusterAbstractionsImpl.java
@@ -17,9 +17,9 @@
package org.apache.solr.cluster.placement.impl;
-import com.google.common.collect.Maps;
import java.io.IOException;
import java.util.Collection;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
@@ -228,7 +228,7 @@ class SimpleClusterAbstractionsImpl {
* of {@link Shard}'s, keyed by shard name ({@link Shard#getShardName()}).
*/
static Map<String, Shard> getShards(SolrCollection solrCollection, Collection<Slice> slices) {
- Map<String, Shard> shards = Maps.newHashMap();
+ Map<String, Shard> shards = new HashMap<>();
for (Slice slice : slices) {
String shardName = slice.getName();
@@ -355,7 +355,7 @@ class SimpleClusterAbstractionsImpl {
*/
static Pair<Map<String, Replica>, Replica> getReplicas(
Collection<org.apache.solr.common.cloud.Replica> sliceReplicas, Shard shard) {
- Map<String, Replica> replicas = Maps.newHashMap();
+ Map<String, Replica> replicas = new HashMap<>();
Replica leader = null;
for (org.apache.solr.common.cloud.Replica sliceReplica : sliceReplicas) {
diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
index ae8a62de115..8168a22342d 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -31,8 +31,6 @@ import static org.apache.solr.security.AuthenticationPlugin.AUTHENTICATION_PLUGI
import com.github.benmanes.caffeine.cache.Interner;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
import io.opentracing.Tracer;
import io.opentracing.noop.NoopTracer;
import io.opentracing.noop.NoopTracerFactory;
@@ -44,6 +42,7 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
+import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -1173,7 +1172,7 @@ public class CoreContainer {
}
private static void checkForDuplicateCoreNames(List<CoreDescriptor> cds) {
- Map<String, Path> addedCores = Maps.newHashMap();
+ Map<String, Path> addedCores = new HashMap<>();
for (CoreDescriptor cd : cds) {
final String name = cd.getName();
if (addedCores.containsKey(name))
@@ -1886,7 +1885,7 @@ public class CoreContainer {
* </ul>
*/
public Map<String, CoreLoadFailure> getCoreInitFailures() {
- return ImmutableMap.copyOf(coreInitFailures);
+ return Map.copyOf(coreInitFailures);
}
// ---------------- Core name related methods ---------------
@@ -2192,6 +2191,9 @@ public class CoreContainer {
* @see SolrCore#close()
*/
public SolrCore getCore(String name, UUID id) {
+ if (name == null) {
+ return null;
+ }
// Do this in two phases since we don't want to lock access to the cores over a load.
SolrCore core = solrCores.getCoreFromAnyList(name, true, id);
diff --git a/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java b/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java
index e45fccf6882..21234d81315 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java
@@ -16,8 +16,6 @@
*/
package org.apache.solr.core;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -27,6 +25,7 @@ import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashMap;
+import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
@@ -93,20 +92,19 @@ public class CoreDescriptor {
return originalExtraProperties;
}
- private static ImmutableMap<String, String> defaultProperties =
- new ImmutableMap.Builder<String, String>()
- .put(CORE_CONFIG, "solrconfig.xml")
- .put(CORE_SCHEMA, "schema.xml")
- .put(CORE_CONFIGSET_PROPERTIES, ConfigSetProperties.DEFAULT_FILENAME)
- .put(CORE_DATADIR, "data" + File.separator)
- .put(CORE_TRANSIENT, "false")
- .put(CORE_LOADONSTARTUP, "true")
- .build();
+ private static final Map<String, String> defaultProperties =
+ Map.of(
+ CORE_CONFIG, "solrconfig.xml",
+ CORE_SCHEMA, "schema.xml",
+ CORE_CONFIGSET_PROPERTIES, ConfigSetProperties.DEFAULT_FILENAME,
+ CORE_DATADIR, "data" + File.separator,
+ CORE_TRANSIENT, "false",
+ CORE_LOADONSTARTUP, "true");
- private static ImmutableList<String> requiredProperties = ImmutableList.of(CORE_NAME);
+ private static final List<String> requiredProperties = List.of(CORE_NAME);
- public static ImmutableList<String> standardPropNames =
- ImmutableList.of(
+ public static List<String> standardPropNames =
+ List.of(
CORE_NAME,
CORE_CONFIG,
CORE_DATADIR,
diff --git a/solr/core/src/java/org/apache/solr/core/CorePropertiesLocator.java b/solr/core/src/java/org/apache/solr/core/CorePropertiesLocator.java
index f2be093e3e9..be3da5c3447 100644
--- a/solr/core/src/java/org/apache/solr/core/CorePropertiesLocator.java
+++ b/solr/core/src/java/org/apache/solr/core/CorePropertiesLocator.java
@@ -16,7 +16,6 @@
*/
package org.apache.solr.core;
-import com.google.common.collect.Lists;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -30,6 +29,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -135,7 +135,7 @@ public class CorePropertiesLocator implements CoresLocator {
@Override
public List<CoreDescriptor> discover(final CoreContainer cc) {
log.debug("Looking for core definitions underneath {}", rootDirectory);
- final List<CoreDescriptor> cds = Lists.newArrayList();
+ final List<CoreDescriptor> cds = new ArrayList<>();
try {
Set<FileVisitOption> options = new HashSet<>();
options.add(FileVisitOption.FOLLOW_LINKS);
diff --git a/solr/core/src/java/org/apache/solr/core/InitParams.java b/solr/core/src/java/org/apache/solr/core/InitParams.java
index 1072de1ce9c..24fb5961b9c 100644
--- a/solr/core/src/java/org/apache/solr/core/InitParams.java
+++ b/solr/core/src/java/org/apache/solr/core/InitParams.java
@@ -22,7 +22,6 @@ import static org.apache.solr.core.PluginInfo.APPENDS;
import static org.apache.solr.core.PluginInfo.DEFAULTS;
import static org.apache.solr.core.PluginInfo.INVARIANTS;
-import com.google.common.collect.ImmutableSet;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -39,7 +38,7 @@ public class InitParams {
public final NamedList<?> invariants;
public final NamedList<?> appends;
private final PluginInfo pluginInfo;
- private final Set<String> KNOWN_KEYS = ImmutableSet.of(DEFAULTS, INVARIANTS, APPENDS);
+ private final Set<String> KNOWN_KEYS = Set.of(DEFAULTS, INVARIANTS, APPENDS);
public InitParams(PluginInfo p) {
this.pluginInfo = p;
diff --git a/solr/core/src/java/org/apache/solr/core/RequestParams.java b/solr/core/src/java/org/apache/solr/core/RequestParams.java
index cb6d68e8f6d..e5937d0856d 100644
--- a/solr/core/src/java/org/apache/solr/core/RequestParams.java
+++ b/solr/core/src/java/org/apache/solr/core/RequestParams.java
@@ -16,11 +16,11 @@
*/
package org.apache.solr.core;
-import com.google.common.collect.ImmutableMap;
import java.io.IOException;
import java.io.InputStream;
import java.lang.invoke.MethodHandles;
import java.util.Collections;
+import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -222,13 +222,15 @@ public class RequestParams implements MapSerializable {
this.defaults = defaults;
this.invariants = invariants;
this.appends = appends;
- ImmutableMap.Builder<String, VersionedParams> builder =
- ImmutableMap.<String, VersionedParams>builder()
- .put(PluginInfo.DEFAULTS, new VersionedParams(defaults, this));
- if (appends != null) builder.put(PluginInfo.APPENDS, new VersionedParams(appends, this));
- if (invariants != null)
+ Map<String, VersionedParams> builder = new HashMap<>();
+ builder.put(PluginInfo.DEFAULTS, new VersionedParams(defaults, this));
+ if (appends != null) {
+ builder.put(PluginInfo.APPENDS, new VersionedParams(appends, this));
+ }
+ if (invariants != null) {
builder.put(PluginInfo.INVARIANTS, new VersionedParams(invariants, this));
- paramsMap = builder.build();
+ }
+ paramsMap = Map.copyOf(builder);
this.meta = meta;
}
diff --git a/solr/core/src/java/org/apache/solr/core/SolrConfig.java b/solr/core/src/java/org/apache/solr/core/SolrConfig.java
index f9ffff39e36..be5bb3fccb3 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrConfig.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrConfig.java
@@ -27,7 +27,6 @@ import static org.apache.solr.core.SolrConfig.PluginOpts.REQUIRE_NAME;
import static org.apache.solr.core.SolrConfig.PluginOpts.REQUIRE_NAME_IN_OVERLAY;
import static org.apache.solr.core.XmlConfigFile.assertWarnOrFail;
-import com.google.common.collect.ImmutableList;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -437,100 +436,79 @@ public class SolrConfig implements MapSerializable {
}
public static final List<SolrPluginInfo> plugins =
- ImmutableList.<SolrPluginInfo>builder()
- .add(
- new SolrPluginInfo(
- SolrRequestHandler.class,
- SolrRequestHandler.TYPE,
- REQUIRE_NAME,
- REQUIRE_CLASS,
- MULTI_OK,
- LAZY))
- .add(
- new SolrPluginInfo(
- QParserPlugin.class, "queryParser", REQUIRE_NAME, REQUIRE_CLASS, MULTI_OK))
- .add(
- new SolrPluginInfo(
- Expressible.class, "expressible", REQUIRE_NAME, REQUIRE_CLASS, MULTI_OK))
- .add(
- new SolrPluginInfo(
- QueryResponseWriter.class,
- "queryResponseWriter",
- REQUIRE_NAME,
- REQUIRE_CLASS,
- MULTI_OK,
- LAZY))
- .add(
- new SolrPluginInfo(
- ValueSourceParser.class,
- "valueSourceParser",
- REQUIRE_NAME,
- REQUIRE_CLASS,
- MULTI_OK))
- .add(
- new SolrPluginInfo(
- TransformerFactory.class, "transformer", REQUIRE_NAME, REQUIRE_CLASS, MULTI_OK))
- .add(
- new SolrPluginInfo(
- SearchComponent.class, "searchComponent", REQUIRE_NAME, REQUIRE_CLASS, MULTI_OK))
- .add(
- new SolrPluginInfo(
- UpdateRequestProcessorFactory.class,
- "updateProcessor",
- REQUIRE_NAME,
- REQUIRE_CLASS,
- MULTI_OK))
- .add(new SolrPluginInfo(SolrCache.class, "cache", REQUIRE_NAME, REQUIRE_CLASS, MULTI_OK))
+ List.of(
+ new SolrPluginInfo(
+ SolrRequestHandler.class,
+ SolrRequestHandler.TYPE,
+ REQUIRE_NAME,
+ REQUIRE_CLASS,
+ MULTI_OK,
+ LAZY),
+ new SolrPluginInfo(
+ QParserPlugin.class, "queryParser", REQUIRE_NAME, REQUIRE_CLASS, MULTI_OK),
+ new SolrPluginInfo(
+ Expressible.class, "expressible", REQUIRE_NAME, REQUIRE_CLASS, MULTI_OK),
+ new SolrPluginInfo(
+ QueryResponseWriter.class,
+ "queryResponseWriter",
+ REQUIRE_NAME,
+ REQUIRE_CLASS,
+ MULTI_OK,
+ LAZY),
+ new SolrPluginInfo(
+ ValueSourceParser.class, "valueSourceParser", REQUIRE_NAME, REQUIRE_CLASS, MULTI_OK),
+ new SolrPluginInfo(
+ TransformerFactory.class, "transformer", REQUIRE_NAME, REQUIRE_CLASS, MULTI_OK),
+ new SolrPluginInfo(
+ SearchComponent.class, "searchComponent", REQUIRE_NAME, REQUIRE_CLASS, MULTI_OK),
+ new SolrPluginInfo(
+ UpdateRequestProcessorFactory.class,
+ "updateProcessor",
+ REQUIRE_NAME,
+ REQUIRE_CLASS,
+ MULTI_OK),
+ new SolrPluginInfo(SolrCache.class, "cache", REQUIRE_NAME, REQUIRE_CLASS, MULTI_OK),
// TODO: WTF is up with queryConverter???
// it apparently *only* works as a singleton? - SOLR-4304
// and even then -- only if there is a single SpellCheckComponent
// because of queryConverter.setIndexAnalyzer
- .add(
- new SolrPluginInfo(
- QueryConverter.class, "queryConverter", REQUIRE_NAME, REQUIRE_CLASS))
+ new SolrPluginInfo(QueryConverter.class, "queryConverter", REQUIRE_NAME, REQUIRE_CLASS),
// this is hackish, since it picks up all SolrEventListeners,
// regardless of when/how/why they are used (or even if they are
// declared outside of the appropriate context) but there's no nice
// way around that in the PluginInfo framework
- .add(
- new SolrPluginInfo(
- InitParams.class, InitParams.TYPE, MULTI_OK, REQUIRE_NAME_IN_OVERLAY))
- .add(
- new SolrPluginInfo(
- it -> {
- List<ConfigNode> result = new ArrayList<>();
- result.addAll(it.get("query").getAll("listener"));
- result.addAll(it.get("updateHandler").getAll("listener"));
- return result;
- },
- SolrEventListener.class,
- "//listener",
- REQUIRE_CLASS,
- MULTI_OK,
- REQUIRE_NAME_IN_OVERLAY))
- .add(new SolrPluginInfo(DirectoryFactory.class, "directoryFactory", REQUIRE_CLASS))
- .add(new SolrPluginInfo(RecoveryStrategy.Builder.class, "recoveryStrategy"))
- .add(
- new SolrPluginInfo(
- it -> it.get("indexConfig").getAll("deletionPolicy"),
- IndexDeletionPolicy.class,
- "indexConfig/deletionPolicy",
- REQUIRE_CLASS))
- .add(new SolrPluginInfo(CodecFactory.class, "codecFactory", REQUIRE_CLASS))
- .add(new SolrPluginInfo(IndexReaderFactory.class, "indexReaderFactory", REQUIRE_CLASS))
- .add(
- new SolrPluginInfo(
- UpdateRequestProcessorChain.class, "updateRequestProcessorChain", MULTI_OK))
- .add(
- new SolrPluginInfo(
- it -> it.get("updateHandler").getAll("updateLog"),
- UpdateLog.class,
- "updateHandler/updateLog"))
- .add(new SolrPluginInfo(IndexSchemaFactory.class, "schemaFactory", REQUIRE_CLASS))
- .add(new SolrPluginInfo(RestManager.class, "restManager"))
- .add(new SolrPluginInfo(StatsCache.class, "statsCache", REQUIRE_CLASS))
- .add(new SolrPluginInfo(CircuitBreakerManager.class, "circuitBreaker"))
- .build();
+ new SolrPluginInfo(InitParams.class, InitParams.TYPE, MULTI_OK, REQUIRE_NAME_IN_OVERLAY),
+ new SolrPluginInfo(
+ it -> {
+ List<ConfigNode> result = new ArrayList<>();
+ result.addAll(it.get("query").getAll("listener"));
+ result.addAll(it.get("updateHandler").getAll("listener"));
+ return result;
+ },
+ SolrEventListener.class,
+ "//listener",
+ REQUIRE_CLASS,
+ MULTI_OK,
+ REQUIRE_NAME_IN_OVERLAY),
+ new SolrPluginInfo(DirectoryFactory.class, "directoryFactory", REQUIRE_CLASS),
+ new SolrPluginInfo(RecoveryStrategy.Builder.class, "recoveryStrategy"),
+ new SolrPluginInfo(
+ it -> it.get("indexConfig").getAll("deletionPolicy"),
+ IndexDeletionPolicy.class,
+ "indexConfig/deletionPolicy",
+ REQUIRE_CLASS),
+ new SolrPluginInfo(CodecFactory.class, "codecFactory", REQUIRE_CLASS),
+ new SolrPluginInfo(IndexReaderFactory.class, "indexReaderFactory", REQUIRE_CLASS),
+ new SolrPluginInfo(
+ UpdateRequestProcessorChain.class, "updateRequestProcessorChain", MULTI_OK),
+ new SolrPluginInfo(
+ it -> it.get("updateHandler").getAll("updateLog"),
+ UpdateLog.class,
+ "updateHandler/updateLog"),
+ new SolrPluginInfo(IndexSchemaFactory.class, "schemaFactory", REQUIRE_CLASS),
+ new SolrPluginInfo(RestManager.class, "restManager"),
+ new SolrPluginInfo(StatsCache.class, "statsCache", REQUIRE_CLASS),
+ new SolrPluginInfo(CircuitBreakerManager.class, "circuitBreaker"));
public static final Map<String, SolrPluginInfo> classVsSolrPluginInfo;
static {
diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.java
index a8b6450cb8c..421b6805eec 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java
@@ -20,7 +20,6 @@ import static org.apache.solr.common.params.CommonParams.PATH;
import com.codahale.metrics.Counter;
import com.codahale.metrics.Timer;
-import com.google.common.collect.Iterators;
import com.google.common.collect.MapMaker;
import java.io.Closeable;
import java.io.File;
@@ -53,6 +52,8 @@ import java.util.Objects;
import java.util.Optional;
import java.util.Properties;
import java.util.Set;
+import java.util.Spliterator;
+import java.util.Spliterators;
import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
@@ -64,6 +65,7 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Consumer;
+import java.util.stream.StreamSupport;
import org.apache.commons.io.file.PathUtils;
import org.apache.lucene.codecs.Codec;
import org.apache.lucene.index.DirectoryReader;
@@ -2937,7 +2939,12 @@ public class SolrCore implements SolrInfoBean, Closeable {
@Override
public Iterator<String> getParameterNamesIterator() {
- return Iterators.filter(params.getParameterNamesIterator(), lpSet::contains);
+ return StreamSupport.stream(
+ Spliterators.spliteratorUnknownSize(
+ params.getParameterNamesIterator(), Spliterator.ORDERED),
+ false)
+ .filter(lpSet::contains)
+ .iterator();
}
@Override
diff --git a/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java b/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java
index 437cb5ceac3..8e5ea021eac 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java
@@ -17,7 +17,6 @@
package org.apache.solr.core;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.ImmutableSet;
import java.io.Closeable;
import java.io.File;
import java.io.FilterInputStream;
@@ -841,7 +840,7 @@ public class SolrResourceLoader
/** If these components are trying to load classes, use schema classloader */
private static final Set<Class<?>> schemaResourceLoaderComponents =
- ImmutableSet.of(
+ Set.of(
CharFilterFactory.class,
TokenFilterFactory.class,
TokenizerFactory.class,
diff --git a/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java b/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java
index bc85f6147d9..5a10d7fce0c 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java
@@ -18,7 +18,6 @@ package org.apache.solr.core;
import static org.apache.solr.common.params.CommonParams.NAME;
-import com.google.common.base.Strings;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.lang.invoke.MethodHandles;
@@ -45,6 +44,7 @@ import org.apache.solr.common.ConfigNode;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.util.DOMUtil;
import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.common.util.Utils;
import org.apache.solr.logging.LogWatcherConfig;
import org.apache.solr.metrics.reporters.SolrJmxReporter;
@@ -133,7 +133,7 @@ public class SolrXmlConfig {
NamedList<Object> entries = readNodeListAsNamedList(root, "<solr>");
String nodeName = (String) entries.remove("nodeName");
- if (Strings.isNullOrEmpty(nodeName) && cloudConfig != null) nodeName = cloudConfig.getHost();
+ if (StrUtils.isNullOrEmpty(nodeName) && cloudConfig != null) nodeName = cloudConfig.getHost();
// It should goes inside the fillSolrSection method but
// since it is arranged as a separate section it is placed here
@@ -400,14 +400,14 @@ public class SolrXmlConfig {
}
private static List<String> separateStrings(String commaSeparatedString) {
- if (Strings.isNullOrEmpty(commaSeparatedString)) {
+ if (StrUtils.isNullOrEmpty(commaSeparatedString)) {
return Collections.emptyList();
}
return Arrays.asList(COMMA_SEPARATED_PATTERN.split(commaSeparatedString));
}
private static Set<Path> separatePaths(String commaSeparatedString) {
- if (Strings.isNullOrEmpty(commaSeparatedString)) {
+ if (StrUtils.isNullOrEmpty(commaSeparatedString)) {
return Collections.emptySet();
}
// Parse the list of paths. The special values '*' and '_ALL_' mean all paths.
diff --git a/solr/core/src/java/org/apache/solr/core/backup/BackupManager.java b/solr/core/src/java/org/apache/solr/core/backup/BackupManager.java
index a94fdce804a..806ba1f6b69 100644
--- a/solr/core/src/java/org/apache/solr/core/backup/BackupManager.java
+++ b/solr/core/src/java/org/apache/solr/core/backup/BackupManager.java
@@ -16,7 +16,6 @@
*/
package org.apache.solr.core.backup;
-import com.google.common.base.Preconditions;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
@@ -254,7 +253,9 @@ public class BackupManager {
String sourceConfigName, String targetConfigName, ConfigSetService configSetService)
throws IOException {
URI source = repository.resolveDirectory(getZkStateDir(), CONFIG_STATE_DIR, sourceConfigName);
- Preconditions.checkState(repository.exists(source), "Path %s does not exist", source);
+ if (!repository.exists(source)) {
+ throw new IllegalArgumentException("Path " + source + " does not exist");
+ }
uploadConfigToSolrCloud(configSetService, source, targetConfigName, "");
}
diff --git a/solr/core/src/java/org/apache/solr/core/backup/repository/LocalFileSystemRepository.java b/solr/core/src/java/org/apache/solr/core/backup/repository/LocalFileSystemRepository.java
index fac7d9e9416..752986eb24d 100644
--- a/solr/core/src/java/org/apache/solr/core/backup/repository/LocalFileSystemRepository.java
+++ b/solr/core/src/java/org/apache/solr/core/backup/repository/LocalFileSystemRepository.java
@@ -17,7 +17,6 @@
package org.apache.solr.core.backup.repository;
-import com.google.common.base.Preconditions;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URI;
@@ -77,12 +76,14 @@ public class LocalFileSystemRepository implements BackupRepository {
@Override
public URI resolve(URI baseUri, String... pathComponents) {
- Preconditions.checkArgument(pathComponents.length > 0);
+ if (pathComponents.length <= 0) {
+ throw new IllegalArgumentException("pathComponents.length must be greater than 0.");
+ }
Path result = Path.of(baseUri);
- for (int i = 0; i < pathComponents.length; i++) {
+ for (String pathComponent : pathComponents) {
try {
- result = result.resolve(pathComponents[i]);
+ result = result.resolve(pathComponent);
} catch (Exception e) {
// unlikely to happen
throw new RuntimeException(e);
diff --git a/solr/core/src/java/org/apache/solr/handler/BlobHandler.java b/solr/core/src/java/org/apache/solr/handler/BlobHandler.java
index 3bb14b19ed4..4f43bb6493f 100644
--- a/solr/core/src/java/org/apache/solr/handler/BlobHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/BlobHandler.java
@@ -22,13 +22,13 @@ import static org.apache.solr.common.params.CommonParams.JSON;
import static org.apache.solr.common.params.CommonParams.SORT;
import static org.apache.solr.common.params.CommonParams.VERSION;
-import com.google.common.collect.Lists;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.invoke.MethodHandles;
import java.nio.ByteBuffer;
import java.security.MessageDigest;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
@@ -341,7 +341,7 @@ public class BlobHandler extends RequestHandlerBase
@Override
public Collection<Api> getApis() {
- final List<Api> apis = Lists.newArrayList();
+ final List<Api> apis = new ArrayList<>();
apis.addAll(AnnotatedApi.getApis(new GetBlobInfoAPI(this)));
apis.addAll(AnnotatedApi.getApis(new UploadBlobAPI(this)));
diff --git a/solr/core/src/java/org/apache/solr/handler/ClusterAPI.java b/solr/core/src/java/org/apache/solr/handler/ClusterAPI.java
index 83e3ffd006f..e161d55e5b3 100644
--- a/solr/core/src/java/org/apache/solr/handler/ClusterAPI.java
+++ b/solr/core/src/java/org/apache/solr/handler/ClusterAPI.java
@@ -32,7 +32,6 @@ import static org.apache.solr.core.RateLimiterConfig.RL_CONFIG_KEY;
import static org.apache.solr.security.PermissionNameProvider.Name.COLL_EDIT_PERM;
import static org.apache.solr.security.PermissionNameProvider.Name.COLL_READ_PERM;
-import com.google.common.collect.Maps;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
@@ -204,9 +203,8 @@ public class ClusterAPI {
@EndPoint(method = DELETE, path = "/cluster/command-status/{id}", permission = COLL_EDIT_PERM)
public void deleteCommandStatus(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
- final Map<String, Object> v1Params = Maps.newHashMap();
- v1Params.put(ACTION, DELETESTATUS.lowerName);
- v1Params.put(REQUESTID, req.getPathTemplateValues().get("id"));
+ final Map<String, Object> v1Params =
+ Map.of(ACTION, DELETESTATUS.lowerName, REQUESTID, req.getPathTemplateValues().get("id"));
collectionsHandler.handleRequestBody(wrapParams(req, v1Params), rsp);
}
@@ -238,9 +236,8 @@ public class ClusterAPI {
@EndPoint(method = GET, path = "/cluster/command-status/{id}", permission = COLL_READ_PERM)
public void getCommandStatus(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
- final Map<String, Object> v1Params = Maps.newHashMap();
- v1Params.put(ACTION, REQUESTSTATUS.lowerName);
- v1Params.put(REQUESTID, req.getPathTemplateValues().get("id"));
+ final Map<String, Object> v1Params =
+ Map.of(ACTION, REQUESTSTATUS.lowerName, REQUESTID, req.getPathTemplateValues().get("id"));
collectionsHandler.handleRequestBody(wrapParams(req, v1Params), rsp);
}
@@ -251,8 +248,8 @@ public class ClusterAPI {
@EndPoint(method = GET, path = "/cluster", permission = COLL_READ_PERM)
public void getClusterStatus(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
- final Map<String, Object> v1Params = Maps.newHashMap();
- v1Params.put(CommonParams.ACTION, CollectionAction.CLUSTERSTATUS.toLower());
+ final Map<String, Object> v1Params =
+ Map.of(CommonParams.ACTION, CollectionAction.CLUSTERSTATUS.toLower());
collectionsHandler.handleRequestBody(wrapParams(req, v1Params), rsp);
}
diff --git a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
index f3ab921b573..d3bcfb084dc 100644
--- a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
+++ b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
@@ -42,7 +42,6 @@ import static org.apache.solr.handler.ReplicationHandler.OFFSET;
import static org.apache.solr.handler.ReplicationHandler.SIZE;
import static org.apache.solr.handler.ReplicationHandler.SKIP_COMMIT_ON_LEADER_VERSION_ZERO;
-import com.google.common.base.Strings;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
@@ -116,6 +115,7 @@ import org.apache.solr.common.util.FastInputStream;
import org.apache.solr.common.util.IOUtils;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SolrNamedThreadFactory;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.common.util.SuppressForbidden;
import org.apache.solr.core.DirectoryFactory;
import org.apache.solr.core.DirectoryFactory.DirContext;
@@ -498,7 +498,7 @@ public class IndexFetcher {
response = getLatestVersion();
} catch (Exception e) {
final String errorMsg = e.toString();
- if (!Strings.isNullOrEmpty(errorMsg) && errorMsg.contains(INTERRUPT_RESPONSE_MESSAGE)) {
+ if (!StrUtils.isNullOrEmpty(errorMsg) && errorMsg.contains(INTERRUPT_RESPONSE_MESSAGE)) {
log.warn(
"Leader at: {} is not available. Index fetch failed by interrupt. Exception: {}",
leaderUrl,
diff --git a/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java b/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java
index fbe3b82953f..6df99e40c8d 100644
--- a/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java
@@ -16,7 +16,6 @@
*/
package org.apache.solr.handler;
-import com.google.common.collect.Lists;
import java.io.IOException;
import java.io.Reader;
import java.lang.invoke.MethodHandles;
@@ -504,7 +503,7 @@ public class MoreLikeThisHandler extends RequestHandlerBase {
@Override
public Collection<Api> getApis() {
- return Lists.newArrayList(AnnotatedApi.getApis(new MoreLikeThisAPI(this)));
+ return List.copyOf(AnnotatedApi.getApis(new MoreLikeThisAPI(this)));
}
@Override
diff --git a/solr/core/src/java/org/apache/solr/handler/RealTimeGetHandler.java b/solr/core/src/java/org/apache/solr/handler/RealTimeGetHandler.java
index 9716de9f3d8..5f1d0460090 100644
--- a/solr/core/src/java/org/apache/solr/handler/RealTimeGetHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/RealTimeGetHandler.java
@@ -16,7 +16,6 @@
*/
package org.apache.solr.handler;
-import com.google.common.collect.Lists;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -53,7 +52,7 @@ public class RealTimeGetHandler extends SearchHandler {
@Override
public Collection<Api> getApis() {
- return Lists.newArrayList(AnnotatedApi.getApis(new RealTimeGetAPI(this)));
+ return List.copyOf(AnnotatedApi.getApis(new RealTimeGetAPI(this)));
}
@Override
diff --git a/solr/core/src/java/org/apache/solr/handler/RequestHandlerBase.java b/solr/core/src/java/org/apache/solr/handler/RequestHandlerBase.java
index b0c5da5b895..7471d2e5d51 100644
--- a/solr/core/src/java/org/apache/solr/handler/RequestHandlerBase.java
+++ b/solr/core/src/java/org/apache/solr/handler/RequestHandlerBase.java
@@ -21,9 +21,9 @@ import static org.apache.solr.core.RequestParams.USEPARAM;
import com.codahale.metrics.Counter;
import com.codahale.metrics.Meter;
import com.codahale.metrics.Timer;
-import com.google.common.collect.ImmutableList;
import java.lang.invoke.MethodHandles;
import java.util.Collection;
+import java.util.List;
import org.apache.solr.api.Api;
import org.apache.solr.api.ApiBag;
import org.apache.solr.api.ApiSupport;
@@ -339,6 +339,6 @@ public abstract class RequestHandlerBase
@Override
public Collection<Api> getApis() {
- return ImmutableList.of(new ApiBag.ReqHandlerToApi(this, ApiBag.constructSpec(pluginInfo)));
+ return List.of(new ApiBag.ReqHandlerToApi(this, ApiBag.constructSpec(pluginInfo)));
}
}
diff --git a/solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java b/solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java
index aeb17522b8d..763ed3c11ab 100644
--- a/solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java
@@ -16,7 +16,6 @@
*/
package org.apache.solr.handler;
-import static com.google.common.base.Strings.isNullOrEmpty;
import static java.util.Collections.singletonList;
import static org.apache.solr.common.params.CoreAdminParams.NAME;
import static org.apache.solr.common.util.StrUtils.formatString;
@@ -32,7 +31,6 @@ import static org.apache.solr.core.SolrConfig.PluginOpts.REQUIRE_NAME;
import static org.apache.solr.core.SolrConfig.PluginOpts.REQUIRE_NAME_IN_OVERLAY;
import static org.apache.solr.schema.FieldType.CLASS_NAME;
-import com.google.common.collect.Lists;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
@@ -437,7 +435,7 @@ public class SolrConfigHandler extends RequestHandlerBase
@SuppressWarnings({"rawtypes"})
Map val;
String key = entry.getKey();
- if (isNullOrEmpty(key)) {
+ if (StrUtils.isNullOrEmpty(key)) {
op.addError("null key ");
continue;
}
@@ -1040,7 +1038,7 @@ public class SolrConfigHandler extends RequestHandlerBase
@Override
public Collection<Api> getApis() {
- final List<Api> apis = Lists.newArrayList();
+ final List<Api> apis = new ArrayList<>();
apis.addAll(AnnotatedApi.getApis(new GetConfigAPI(this)));
apis.addAll(AnnotatedApi.getApis(new ModifyConfigComponentAPI(this)));
apis.addAll(AnnotatedApi.getApis(new ModifyParamSetAPI(this)));
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/BaseHandlerApiSupport.java b/solr/core/src/java/org/apache/solr/handler/admin/BaseHandlerApiSupport.java
index 5bdb9c200e2..d7dcbc823fd 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/BaseHandlerApiSupport.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/BaseHandlerApiSupport.java
@@ -21,7 +21,6 @@ import static org.apache.solr.client.solrj.SolrRequest.METHOD.POST;
import static org.apache.solr.common.SolrException.ErrorCode.BAD_REQUEST;
import static org.apache.solr.common.util.StrUtils.splitSmart;
-import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -30,6 +29,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
+import java.util.stream.Collectors;
import org.apache.solr.api.Api;
import org.apache.solr.api.ApiSupport;
import org.apache.solr.client.solrj.SolrRequest;
@@ -63,9 +63,7 @@ public abstract class BaseHandlerApiSupport implements ApiSupport {
@Override
public synchronized Collection<Api> getApis() {
- ImmutableList.Builder<Api> l = ImmutableList.builder();
- for (V2EndPoint op : getEndPoints()) l.add(getApi(op));
- return l.build();
+ return getEndPoints().stream().map(this::getApi).collect(Collectors.toUnmodifiableList());
}
private Api getApi(final V2EndPoint op) {
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
index ff6e4643128..8864f45e1cb 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
@@ -124,8 +124,6 @@ import static org.apache.solr.common.params.CoreAdminParams.ULOG_DIR;
import static org.apache.solr.common.params.ShardParams._ROUTE_;
import static org.apache.solr.common.util.StrUtils.formatString;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.net.URI;
@@ -298,8 +296,7 @@ public class CollectionsHandler extends RequestHandlerBase implements Permission
Object defVal =
new ClusterProperties(coreContainer.getZkController().getZkStateReader().getZkClient())
.getClusterProperty(
- ImmutableList.of(
- CollectionAdminParams.DEFAULTS, CollectionAdminParams.COLLECTION, prop),
+ List.of(CollectionAdminParams.DEFAULTS, CollectionAdminParams.COLLECTION, prop),
null);
if (defVal != null) props.put(prop, String.valueOf(defVal));
}
@@ -385,7 +382,7 @@ public class CollectionsHandler extends RequestHandlerBase implements Permission
}
}
- static final Set<String> KNOWN_ROLES = ImmutableSet.of("overseer");
+ static final Set<String> KNOWN_ROLES = Set.of("overseer");
public static long DEFAULT_COLLECTION_OP_TIMEOUT = 180 * 1000;
@@ -634,7 +631,7 @@ public class CollectionsHandler extends RequestHandlerBase implements Permission
createSysConfigSet(h.coreContainer);
}
if (shardsParam == null) h.copyFromClusterProp(props, NUM_SLICES);
- for (String prop : ImmutableSet.of(NRT_REPLICAS, PULL_REPLICAS, TLOG_REPLICAS))
+ for (String prop : Set.of(NRT_REPLICAS, PULL_REPLICAS, TLOG_REPLICAS))
h.copyFromClusterProp(props, prop);
copyPropertiesWithPrefix(req.getParams(), props, PROPERTY_PREFIX);
return copyPropertiesWithPrefix(req.getParams(), props, "router.");
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/ConfigSetsHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/ConfigSetsHandler.java
index 52f0cfd7ef9..96015b2486e 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/ConfigSetsHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/ConfigSetsHandler.java
@@ -19,7 +19,6 @@ package org.apache.solr.handler.admin;
import static org.apache.solr.common.params.CommonParams.NAME;
import static org.apache.solr.handler.configsets.UploadConfigSetFileAPI.FILEPATH_PLACEHOLDER;
-import com.google.common.collect.Maps;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
import java.util.Collection;
@@ -113,7 +112,7 @@ public class ConfigSetsHandler extends RequestHandlerBase implements PermissionN
new DelegatingSolrQueryRequest(req) {
@Override
public Map<String, String> getPathTemplateValues() {
- final Map<String, String> templateValsByName = Maps.newHashMap();
+ final Map<String, String> templateValsByName = new HashMap<>();
templateValsByName.put(
UploadConfigSetAPI.CONFIGSET_NAME_PLACEHOLDER,
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
index 1769e919002..3f50824b3f2 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
@@ -21,10 +21,9 @@ import static org.apache.solr.common.params.CoreAdminParams.CoreAdminAction.STAT
import static org.apache.solr.security.PermissionNameProvider.Name.CORE_EDIT_PERM;
import static org.apache.solr.security.PermissionNameProvider.Name.CORE_READ_PERM;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
import java.io.File;
import java.lang.invoke.MethodHandles;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -247,22 +246,21 @@ public class CoreAdminHandler extends RequestHandlerBase implements PermissionNa
"Unsupported operation: " + req.getParams().get(ACTION));
}
- public static ImmutableMap<String, String> paramToProp =
- ImmutableMap.<String, String>builder()
- .put(CoreAdminParams.CONFIG, CoreDescriptor.CORE_CONFIG)
- .put(CoreAdminParams.SCHEMA, CoreDescriptor.CORE_SCHEMA)
- .put(CoreAdminParams.DATA_DIR, CoreDescriptor.CORE_DATADIR)
- .put(CoreAdminParams.ULOG_DIR, CoreDescriptor.CORE_ULOGDIR)
- .put(CoreAdminParams.CONFIGSET, CoreDescriptor.CORE_CONFIGSET)
- .put(CoreAdminParams.LOAD_ON_STARTUP, CoreDescriptor.CORE_LOADONSTARTUP)
- .put(CoreAdminParams.TRANSIENT, CoreDescriptor.CORE_TRANSIENT)
- .put(CoreAdminParams.SHARD, CoreDescriptor.CORE_SHARD)
- .put(CoreAdminParams.COLLECTION, CoreDescriptor.CORE_COLLECTION)
- .put(CoreAdminParams.ROLES, CoreDescriptor.CORE_ROLES)
- .put(CoreAdminParams.CORE_NODE_NAME, CoreDescriptor.CORE_NODE_NAME)
- .put(ZkStateReader.NUM_SHARDS_PROP, CloudDescriptor.NUM_SHARDS)
- .put(CoreAdminParams.REPLICA_TYPE, CloudDescriptor.REPLICA_TYPE)
- .build();
+ public static Map<String, String> paramToProp =
+ Map.ofEntries(
+ Map.entry(CoreAdminParams.CONFIG, CoreDescriptor.CORE_CONFIG),
+ Map.entry(CoreAdminParams.SCHEMA, CoreDescriptor.CORE_SCHEMA),
+ Map.entry(CoreAdminParams.DATA_DIR, CoreDescriptor.CORE_DATADIR),
+ Map.entry(CoreAdminParams.ULOG_DIR, CoreDescriptor.CORE_ULOGDIR),
+ Map.entry(CoreAdminParams.CONFIGSET, CoreDescriptor.CORE_CONFIGSET),
+ Map.entry(CoreAdminParams.LOAD_ON_STARTUP, CoreDescriptor.CORE_LOADONSTARTUP),
+ Map.entry(CoreAdminParams.TRANSIENT, CoreDescriptor.CORE_TRANSIENT),
+ Map.entry(CoreAdminParams.SHARD, CoreDescriptor.CORE_SHARD),
+ Map.entry(CoreAdminParams.COLLECTION, CoreDescriptor.CORE_COLLECTION),
+ Map.entry(CoreAdminParams.ROLES, CoreDescriptor.CORE_ROLES),
+ Map.entry(CoreAdminParams.CORE_NODE_NAME, CoreDescriptor.CORE_NODE_NAME),
+ Map.entry(ZkStateReader.NUM_SHARDS_PROP, CloudDescriptor.NUM_SHARDS),
+ Map.entry(CoreAdminParams.REPLICA_TYPE, CloudDescriptor.REPLICA_TYPE));
protected static Map<String, String> buildCoreParams(SolrParams params) {
@@ -357,7 +355,7 @@ public class CoreAdminHandler extends RequestHandlerBase implements PermissionNa
@Override
public Collection<Api> getApis() {
- final List<Api> apis = Lists.newArrayList();
+ final List<Api> apis = new ArrayList<>();
apis.addAll(AnnotatedApi.getApis(new AllCoresStatusAPI(this)));
apis.addAll(AnnotatedApi.getApis(new SingleCoreStatusAPI(this)));
apis.addAll(AnnotatedApi.getApis(new CreateCoreAPI(this)));
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/InfoHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/InfoHandler.java
index f14c76d24af..3f967123f94 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/InfoHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/InfoHandler.java
@@ -18,8 +18,9 @@ package org.apache.solr.handler.admin;
import static org.apache.solr.common.params.CommonParams.PATH;
-import com.google.common.collect.ImmutableList;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -159,13 +160,13 @@ public class InfoHandler extends RequestHandlerBase {
@Override
public Collection<Api> getApis() {
- final ImmutableList.Builder<Api> list = new ImmutableList.Builder<>();
+ final List<Api> list = new ArrayList<>();
list.addAll(handlers.get("threads").getApis());
list.addAll(handlers.get("properties").getApis());
list.addAll(handlers.get("logging").getApis());
list.addAll(handlers.get("system").getApis());
list.addAll(handlers.get("health").getApis());
- return list.build();
+ return List.copyOf(list);
}
@Override
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/MergeIndexesOp.java b/solr/core/src/java/org/apache/solr/handler/admin/MergeIndexesOp.java
index 9df24ff5e20..ff13c39a366 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/MergeIndexesOp.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/MergeIndexesOp.java
@@ -17,9 +17,9 @@
package org.apache.solr.handler.admin;
-import com.google.common.collect.Lists;
import java.lang.invoke.MethodHandles;
import java.nio.file.Paths;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@@ -56,10 +56,10 @@ class MergeIndexesOp implements CoreAdminHandler.CoreAdminOp {
SolrQueryRequest wrappedReq = null;
if (core == null) return;
- List<SolrCore> sourceCores = Lists.newArrayList();
- List<RefCounted<SolrIndexSearcher>> searchers = Lists.newArrayList();
+ List<SolrCore> sourceCores = new ArrayList<>();
+ List<RefCounted<SolrIndexSearcher>> searchers = new ArrayList<>();
// stores readers created from indexDir param values
- List<DirectoryReader> readersToBeClosed = Lists.newArrayList();
+ List<DirectoryReader> readersToBeClosed = new ArrayList<>();
Map<Directory, Boolean> dirsToBeReleased = new HashMap<>();
try {
@@ -106,7 +106,7 @@ class MergeIndexesOp implements CoreAdminHandler.CoreAdminOp {
if (readersToBeClosed.size() > 0) {
readers = readersToBeClosed;
} else {
- readers = Lists.newArrayList();
+ readers = new ArrayList<>();
for (SolrCore solrCore : sourceCores) {
// record the searchers so that we can decref
RefCounted<SolrIndexSearcher> searcher = solrCore.getSearcher();
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandler.java
index e38af3e2377..9142449cba6 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandler.java
@@ -18,7 +18,6 @@ package org.apache.solr.handler.admin;
import static org.apache.solr.common.SolrException.ErrorCode.SERVER_ERROR;
-import com.google.common.collect.ImmutableList;
import java.io.IOException;
import java.io.InputStream;
import java.lang.invoke.MethodHandles;
@@ -337,7 +336,7 @@ public abstract class SecurityConfHandler extends RequestHandlerBase
}
});
- this.apis = ImmutableList.copyOf(apis);
+ this.apis = List.copyOf(apis);
}
}
}
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java
index 4e7e1b8124b..7c72ee96c21 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java
@@ -16,7 +16,6 @@
*/
package org.apache.solr.handler.admin;
-import com.google.common.base.Strings;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
@@ -39,6 +38,7 @@ import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.ContentStreamBase;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.SolrCore;
import org.apache.solr.core.SolrResourceLoader;
@@ -265,7 +265,7 @@ public class ShowFileRequestHandler extends RequestHandlerBase implements Permis
* all standard mime types. If an HTML type is requested, it is instead returned as text/plain
*/
public static String getSafeContentType(String contentType) {
- if (Strings.isNullOrEmpty(contentType)) {
+ if (StrUtils.isNullOrEmpty(contentType)) {
log.debug("No contentType specified");
return null;
}
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/api/DeleteShardAPI.java b/solr/core/src/java/org/apache/solr/handler/admin/api/DeleteShardAPI.java
index ff434d26960..a5d05ac698d 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/api/DeleteShardAPI.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/api/DeleteShardAPI.java
@@ -24,7 +24,7 @@ import static org.apache.solr.common.params.CoreAdminParams.SHARD;
import static org.apache.solr.handler.ClusterAPI.wrapParams;
import static org.apache.solr.security.PermissionNameProvider.Name.COLL_EDIT_PERM;
-import com.google.common.collect.Maps;
+import java.util.HashMap;
import java.util.Map;
import org.apache.solr.api.EndPoint;
import org.apache.solr.common.params.CollectionParams;
@@ -52,7 +52,7 @@ public class DeleteShardAPI {
public void deleteShard(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
final Map<String, String> pathParams = req.getPathTemplateValues();
- final Map<String, Object> addedV1Params = Maps.newHashMap();
+ final Map<String, Object> addedV1Params = new HashMap<>();
addedV1Params.put(ACTION, CollectionParams.CollectionAction.DELETESHARD.toLower());
addedV1Params.put(COLLECTION, pathParams.get(COLLECTION));
addedV1Params.put(SHARD, pathParams.get(SHARD));
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/api/ForceLeaderAPI.java b/solr/core/src/java/org/apache/solr/handler/admin/api/ForceLeaderAPI.java
index fb8f3da6e25..c8bf6104770 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/api/ForceLeaderAPI.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/api/ForceLeaderAPI.java
@@ -24,7 +24,7 @@ import static org.apache.solr.common.params.CoreAdminParams.SHARD;
import static org.apache.solr.handler.ClusterAPI.wrapParams;
import static org.apache.solr.security.PermissionNameProvider.Name.COLL_EDIT_PERM;
-import com.google.common.collect.Maps;
+import java.util.HashMap;
import java.util.Map;
import org.apache.solr.api.Command;
import org.apache.solr.api.EndPoint;
@@ -56,7 +56,7 @@ public class ForceLeaderAPI {
@Command(name = V2_FORCE_LEADER_CMD)
public void forceLeader(PayloadObj<ForceLeaderPayload> obj) throws Exception {
- final Map<String, Object> addedV1Params = Maps.newHashMap();
+ final Map<String, Object> addedV1Params = new HashMap<>();
final Map<String, String> pathParams = obj.getRequest().getPathTemplateValues();
addedV1Params.put(ACTION, CollectionParams.CollectionAction.FORCELEADER.toLower());
addedV1Params.put(COLLECTION, pathParams.get(COLLECTION));
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/api/RequestCoreCommandStatusAPI.java b/solr/core/src/java/org/apache/solr/handler/admin/api/RequestCoreCommandStatusAPI.java
index 8feb9093dac..242ecbcd7a5 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/api/RequestCoreCommandStatusAPI.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/api/RequestCoreCommandStatusAPI.java
@@ -22,7 +22,7 @@ import static org.apache.solr.common.params.CollectionParams.ACTION;
import static org.apache.solr.handler.ClusterAPI.wrapParams;
import static org.apache.solr.security.PermissionNameProvider.Name.CORE_READ_PERM;
-import com.google.common.collect.Maps;
+import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import org.apache.solr.api.EndPoint;
@@ -53,7 +53,7 @@ public class RequestCoreCommandStatusAPI {
@EndPoint(method = GET, path = "/cores/{core}/command-status/{id}", permission = CORE_READ_PERM)
public void getCommandStatus(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
- final Map<String, Object> v1Params = Maps.newHashMap();
+ final Map<String, Object> v1Params = new HashMap<>();
v1Params.put(
ACTION, CoreAdminParams.CoreAdminAction.REQUESTSTATUS.name().toLowerCase(Locale.ROOT));
v1Params.put(CoreAdminParams.REQUESTID, req.getPathTemplateValues().get("id"));
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/api/SyncShardAPI.java b/solr/core/src/java/org/apache/solr/handler/admin/api/SyncShardAPI.java
index 3749a993d18..0819b09ad51 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/api/SyncShardAPI.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/api/SyncShardAPI.java
@@ -24,7 +24,7 @@ import static org.apache.solr.common.params.CoreAdminParams.SHARD;
import static org.apache.solr.handler.ClusterAPI.wrapParams;
import static org.apache.solr.security.PermissionNameProvider.Name.COLL_EDIT_PERM;
-import com.google.common.collect.Maps;
+import java.util.HashMap;
import java.util.Map;
import org.apache.solr.api.Command;
import org.apache.solr.api.EndPoint;
@@ -56,7 +56,7 @@ public class SyncShardAPI {
@Command(name = V2_SYNC_SHARD_CMD)
public void syncShard(PayloadObj<SyncShardPayload> obj) throws Exception {
- final Map<String, Object> addedV1Params = Maps.newHashMap();
+ final Map<String, Object> addedV1Params = new HashMap<>();
final Map<String, String> pathParams = obj.getRequest().getPathTemplateValues();
addedV1Params.put(ACTION, CollectionParams.CollectionAction.SYNCSHARD.toLower());
addedV1Params.put(COLLECTION, pathParams.get(COLLECTION));
diff --git a/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java b/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java
index 6c3ff178efc..587f270f5c0 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java
@@ -19,13 +19,6 @@ package org.apache.solr.handler.component;
import com.carrotsearch.hppc.IntIntHashMap;
import com.carrotsearch.hppc.cursors.IntIntCursor;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.ImmutableSortedSet;
-import com.google.common.collect.ObjectArrays;
-import com.google.common.collect.Sets;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.lang.ref.WeakReference;
@@ -48,7 +41,10 @@ import java.util.Objects;
import java.util.Queue;
import java.util.Set;
import java.util.SortedSet;
+import java.util.TreeSet;
import java.util.function.Consumer;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
@@ -72,6 +68,7 @@ import org.apache.lucene.util.BytesRefBuilder;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.QueryElevationParams;
import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.common.util.CollectionUtil;
import org.apache.solr.common.util.DOMUtil;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
@@ -919,7 +916,7 @@ public class QueryElevationComponent extends SearchComponent implements SolrCore
elevationBuilder.addExcludedIds(
excludedIds == null ? Collections.emptyList() : Arrays.asList(excludedIds));
Map<ElevatingQuery, ElevationBuilder> elevationBuilderMap =
- ImmutableMap.of(elevatingQuery, elevationBuilder);
+ Map.of(elevatingQuery, elevationBuilder);
synchronized (LOCK) {
cacheIndexReader = new WeakReference<>(reader);
cacheElevationProvider = createElevationProvider(elevationBuilderMap);
@@ -1221,7 +1218,7 @@ public class QueryElevationComponent extends SearchComponent implements SolrCore
includeQuery = EMPTY_QUERY;
this.elevatedIds = Collections.emptySet();
} else {
- this.elevatedIds = ImmutableSet.copyOf(elevatedIds);
+ this.elevatedIds = Collections.unmodifiableSet(new LinkedHashSet<>(elevatedIds));
BooleanQuery.Builder includeQueryBuilder = new BooleanQuery.Builder();
for (BytesRef elevatedId : elevatedIds) {
includeQueryBuilder.add(
@@ -1234,12 +1231,11 @@ public class QueryElevationComponent extends SearchComponent implements SolrCore
this.excludedIds = Collections.emptySet();
excludeQueries = null;
} else {
- this.excludedIds = ImmutableSet.copyOf(excludedIds);
- List<TermQuery> excludeQueriesBuilder = new ArrayList<>(excludedIds.size());
- for (BytesRef excludedId : excludedIds) {
- excludeQueriesBuilder.add(new TermQuery(new Term(queryFieldName, excludedId)));
- }
- excludeQueries = excludeQueriesBuilder.toArray(new TermQuery[0]);
+ this.excludedIds = Collections.unmodifiableSet(new LinkedHashSet<>(excludedIds));
+ this.excludeQueries =
+ this.excludedIds.stream()
+ .map(excludedId -> new TermQuery(new Term(queryFieldName, excludedId)))
+ .toArray(TermQuery[]::new);
}
}
@@ -1265,15 +1261,13 @@ public class QueryElevationComponent extends SearchComponent implements SolrCore
return this;
}
Set<BytesRef> elevatedIds =
- ImmutableSet.<BytesRef>builder()
- .addAll(this.elevatedIds)
- .addAll(elevation.elevatedIds)
- .build();
+ Stream.concat(this.elevatedIds.stream(), elevation.elevatedIds.stream())
+ .collect(Collectors.toCollection(LinkedHashSet::new));
boolean overlappingElevatedIds =
elevatedIds.size() != (this.elevatedIds.size() + elevation.elevatedIds.size());
BooleanQuery.Builder includeQueryBuilder = new BooleanQuery.Builder();
Set<BooleanClause> clauseSet =
- (overlappingElevatedIds ? Sets.newHashSetWithExpectedSize(elevatedIds.size()) : null);
+ (overlappingElevatedIds ? CollectionUtil.newHashSet(elevatedIds.size()) : null);
for (BooleanClause clause : this.includeQuery.clauses()) {
if (!overlappingElevatedIds || clauseSet.add(clause)) {
includeQueryBuilder.add(clause);
@@ -1285,10 +1279,8 @@ public class QueryElevationComponent extends SearchComponent implements SolrCore
}
}
Set<BytesRef> excludedIds =
- ImmutableSet.<BytesRef>builder()
- .addAll(this.excludedIds)
- .addAll(elevation.excludedIds)
- .build();
+ Stream.concat(this.excludedIds.stream(), elevation.excludedIds.stream())
+ .collect(Collectors.toUnmodifiableSet());
TermQuery[] excludeQueries;
if (this.excludeQueries == null) {
excludeQueries = elevation.excludeQueries;
@@ -1299,14 +1291,16 @@ public class QueryElevationComponent extends SearchComponent implements SolrCore
excludedIds.size() != (this.excludedIds.size() + elevation.excludedIds.size());
if (overlappingExcludedIds) {
excludeQueries =
- ImmutableSet.<TermQuery>builder()
- .add(this.excludeQueries)
- .add(elevation.excludeQueries)
- .build()
- .toArray(new TermQuery[0]);
+ Stream.concat(
+ Arrays.stream(this.excludeQueries), Arrays.stream(elevation.excludeQueries))
+ .distinct()
+ .toArray(TermQuery[]::new);
} else {
excludeQueries =
- ObjectArrays.concat(this.excludeQueries, elevation.excludeQueries, TermQuery.class);
+ Stream.concat(
+ Arrays.stream(this.excludeQueries), Arrays.stream(elevation.excludeQueries))
+ .distinct()
+ .toArray(TermQuery[]::new);
}
}
return new Elevation(elevatedIds, includeQueryBuilder.build(), excludedIds, excludeQueries);
@@ -1315,9 +1309,13 @@ public class QueryElevationComponent extends SearchComponent implements SolrCore
@Override
public String toString() {
return "{elevatedIds="
- + Collections2.transform(elevatedIds, BytesRef::utf8ToString)
+ + elevatedIds.stream()
+ .map(BytesRef::utf8ToString)
+ .collect(Collectors.toCollection(LinkedHashSet::new))
+ ", excludedIds="
- + Collections2.transform(excludedIds, BytesRef::utf8ToString)
+ + excludedIds.stream()
+ .map(BytesRef::utf8ToString)
+ .collect(Collectors.toCollection(LinkedHashSet::new))
+ "}";
}
}
@@ -1558,7 +1556,7 @@ public class QueryElevationComponent extends SearchComponent implements SolrCore
public Builder<E, M> addSubset(Collection<E> subset, M matchValue) {
if (!subset.isEmpty()) {
TrieSubsetMatcher.Node<E, M> node = root;
- for (E e : ImmutableSortedSet.copyOf(subset)) {
+ for (E e : new TreeSet<>(subset)) {
node = node.getOrCreateChild(e);
}
node.addMatchValue(matchValue);
@@ -1590,10 +1588,10 @@ public class QueryElevationComponent extends SearchComponent implements SolrCore
* Returns an iterator over all the subsets that are contained by the provided set. The returned
* iterator does not support removal.
*
- * @param set This set is copied to a new {@link ImmutableSortedSet} with natural ordering.
+ * @param set This set is copied to a new {@link SortedSet} with natural ordering.
*/
public Iterator<M> findSubsetsMatching(Collection<E> set) {
- return new MatchIterator(ImmutableSortedSet.copyOf(set));
+ return new MatchIterator(new TreeSet<>(set));
}
/** Trie node. */
@@ -1652,12 +1650,12 @@ public class QueryElevationComponent extends SearchComponent implements SolrCore
* memory usage and make it more efficient.
*/
void trimAndMakeImmutable() {
- if (children != null && !(children instanceof ImmutableMap)) {
+ if (children != null) {
for (Node<E, M> child : children.values()) child.trimAndMakeImmutable();
- children = ImmutableMap.copyOf(children);
+ children = Map.copyOf(children);
}
- if (matchValues != null && !(matchValues instanceof ImmutableList)) {
- matchValues = ImmutableList.copyOf(matchValues);
+ if (matchValues != null) {
+ matchValues = List.copyOf(matchValues);
}
}
}
diff --git a/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java b/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java
index 01fdf736193..b06116123e6 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java
@@ -21,7 +21,6 @@ import static org.apache.solr.common.params.CommonParams.ID;
import static org.apache.solr.common.params.CommonParams.VERSION_FIELD;
import static org.apache.solr.search.QueryUtils.makeQueryable;
-import com.google.common.collect.Lists;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
@@ -885,7 +884,7 @@ public class RealTimeGetComponent extends SearchComponent {
if (!fieldArrayListCreated && doc.getFieldValue(fname) instanceof Collection) {
// previous value was array so we must return as an array even if was a single value
// array
- out.setField(fname, Lists.newArrayList(val));
+ out.setField(fname, new ArrayList<>(List.of(val)));
fieldArrayListCreated = true;
continue;
}
@@ -1001,16 +1000,16 @@ public class RealTimeGetComponent extends SearchComponent {
if (solrInputField.getFirstValue() instanceof SolrInputDocument) {
// is child doc
Object val = solrInputField.getValue();
- Iterator<SolrDocument> childDocs =
+ List<SolrDocument> childDocs =
solrInputField.getValues().stream()
.map(x -> toSolrDoc((SolrInputDocument) x, schema))
- .iterator();
+ .collect(Collectors.toList());
if (val instanceof Collection) {
// add as collection even if single element collection
- solrDoc.setField(solrInputField.getName(), Lists.newArrayList(childDocs));
+ solrDoc.setField(solrInputField.getName(), childDocs);
} else {
// single child doc
- solrDoc.setField(solrInputField.getName(), childDocs.next());
+ solrDoc.setField(solrInputField.getName(), childDocs.get(0));
}
}
}
diff --git a/solr/core/src/java/org/apache/solr/handler/component/ShardHandlerFactory.java b/solr/core/src/java/org/apache/solr/handler/component/ShardHandlerFactory.java
index 40130864f63..c135e17d1d8 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/ShardHandlerFactory.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/ShardHandlerFactory.java
@@ -16,9 +16,9 @@
*/
package org.apache.solr.handler.component;
-import com.google.common.collect.ImmutableMap;
import java.util.Collections;
import java.util.Locale;
+import java.util.Map;
import org.apache.solr.common.SolrException;
import org.apache.solr.core.PluginInfo;
import org.apache.solr.core.SolrResourceLoader;
@@ -69,7 +69,7 @@ public abstract class ShardHandlerFactory {
public static final PluginInfo DEFAULT_SHARDHANDLER_INFO =
new PluginInfo(
"shardHandlerFactory",
- ImmutableMap.of("class", HttpShardHandlerFactory.class.getName()),
+ Map.of("class", HttpShardHandlerFactory.class.getName()),
null,
Collections.<PluginInfo>emptyList());
}
diff --git a/solr/core/src/java/org/apache/solr/handler/configsets/DeleteConfigSetAPI.java b/solr/core/src/java/org/apache/solr/handler/configsets/DeleteConfigSetAPI.java
index 8c93871e6af..56c63f75f51 100644
--- a/solr/core/src/java/org/apache/solr/handler/configsets/DeleteConfigSetAPI.java
+++ b/solr/core/src/java/org/apache/solr/handler/configsets/DeleteConfigSetAPI.java
@@ -20,7 +20,7 @@ import static org.apache.solr.client.solrj.SolrRequest.METHOD.DELETE;
import static org.apache.solr.common.params.CommonParams.NAME;
import static org.apache.solr.security.PermissionNameProvider.Name.CONFIG_EDIT_PERM;
-import com.google.common.collect.Maps;
+import java.util.HashMap;
import java.util.Map;
import org.apache.solr.api.EndPoint;
import org.apache.solr.common.SolrException;
@@ -54,7 +54,7 @@ public class DeleteConfigSetAPI extends ConfigSetAPIBase {
throw new SolrException(
SolrException.ErrorCode.BAD_REQUEST, "No configset name provided to delete");
}
- final Map<String, Object> configsetCommandMsg = Maps.newHashMap();
+ final Map<String, Object> configsetCommandMsg = new HashMap<>();
configsetCommandMsg.put(NAME, configSetName);
runConfigSetCommand(rsp, ConfigSetParams.ConfigSetAction.DELETE, configsetCommandMsg);
diff --git a/solr/core/src/java/org/apache/solr/handler/designer/DefaultSchemaSuggester.java b/solr/core/src/java/org/apache/solr/handler/designer/DefaultSchemaSuggester.java
index 82cf8273440..38c2d96aa65 100644
--- a/solr/core/src/java/org/apache/solr/handler/designer/DefaultSchemaSuggester.java
+++ b/solr/core/src/java/org/apache/solr/handler/designer/DefaultSchemaSuggester.java
@@ -20,7 +20,6 @@ package org.apache.solr.handler.designer;
import static org.apache.solr.common.params.CommonParams.VERSION_FIELD;
import static org.apache.solr.update.processor.ParseDateFieldUpdateProcessorFactory.validateFormatter;
-import com.google.common.collect.Sets;
import java.io.IOException;
import java.math.RoundingMode;
import java.text.NumberFormat;
@@ -298,7 +297,7 @@ public class DefaultSchemaSuggester implements SchemaSuggester {
|| maxTerms > 12
|| (maxTerms > 4
&& values.size() >= 10
- && ((float) Sets.newHashSet(values).size() / values.size()) > 0.9f));
+ && ((float) Set.of(values).size() / values.size()) > 0.9f));
}
protected String isFloatOrDouble(List<Object> values, Locale locale) {
diff --git a/solr/core/src/java/org/apache/solr/handler/designer/ManagedSchemaDiff.java b/solr/core/src/java/org/apache/solr/handler/designer/ManagedSchemaDiff.java
index 18b327a165f..17e26923c2e 100644
--- a/solr/core/src/java/org/apache/solr/handler/designer/ManagedSchemaDiff.java
+++ b/solr/core/src/java/org/apache/solr/handler/designer/ManagedSchemaDiff.java
@@ -28,6 +28,7 @@ import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.solr.common.util.SimpleOrderedMap;
+import org.apache.solr.common.util.SuppressForbidden;
import org.apache.solr.schema.FieldType;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.schema.ManagedIndexSchema;
@@ -215,7 +216,7 @@ public class ManagedSchemaDiff {
* @param simpleOrderedMap2 Map to treat as "right" map
* @return List containing the left diff and right diff
*/
- @SuppressWarnings("unchecked")
+ @SuppressForbidden(reason = "Maps.difference")
private static List<Map<String, Object>> getMapDifference(
SimpleOrderedMap<Object> simpleOrderedMap1, SimpleOrderedMap<Object> simpleOrderedMap2) {
Map<String, Object> map1 = simpleOrderedMap1.toMap(new HashMap<>());
diff --git a/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java b/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java
index 35fdae660f1..044b9cef96c 100644
--- a/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java
+++ b/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java
@@ -27,7 +27,6 @@ import static org.apache.solr.schema.IndexSchema.NEST_PATH_FIELD_NAME;
import static org.apache.solr.schema.IndexSchema.ROOT_FIELD_NAME;
import static org.apache.solr.schema.ManagedIndexSchemaFactory.DEFAULT_MANAGED_SCHEMA_RESOURCE_NAME;
-import com.google.common.collect.Sets;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -806,7 +805,10 @@ class SchemaDesignerConfigSetHelper implements SchemaDesignerConstants {
schema.getCopyFieldsList(fieldName).stream()
.map(cf -> cf.getDestination().getName())
.collect(Collectors.toSet());
- Set<String> add = Sets.difference(desired, existing);
+ Set<String> add =
+ desired.stream()
+ .filter(e -> !existing.contains(e))
+ .collect(Collectors.toUnmodifiableSet());
if (!add.isEmpty()) {
SchemaRequest.AddCopyField addAction =
new SchemaRequest.AddCopyField(fieldName, new ArrayList<>(add));
@@ -818,7 +820,10 @@ class SchemaDesignerConfigSetHelper implements SchemaDesignerConstants {
updated = true;
} // no additions ...
- Set<String> del = Sets.difference(existing, desired);
+ Set<String> del =
+ existing.stream()
+ .filter(e -> !desired.contains(e))
+ .collect(Collectors.toUnmodifiableSet());
if (!del.isEmpty()) {
SchemaRequest.DeleteCopyField delAction =
new SchemaRequest.DeleteCopyField(fieldName, new ArrayList<>(del));
diff --git a/solr/core/src/java/org/apache/solr/handler/loader/XMLLoader.java b/solr/core/src/java/org/apache/solr/handler/loader/XMLLoader.java
index 05dbbc2b31d..a48d00fceaf 100644
--- a/solr/core/src/java/org/apache/solr/handler/loader/XMLLoader.java
+++ b/solr/core/src/java/org/apache/solr/handler/loader/XMLLoader.java
@@ -19,7 +19,6 @@ package org.apache.solr.handler.loader;
import static org.apache.solr.common.params.CommonParams.ID;
import static org.apache.solr.common.params.CommonParams.NAME;
-import com.google.common.collect.Lists;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -431,7 +430,7 @@ public class XMLLoader extends ContentStreamLoader {
doc.addField(subdocName, readDoc(parser, true));
} else { // unnamed <doc> enclosed in <doc>
if (subDocs == null) {
- subDocs = Lists.newArrayList();
+ subDocs = new ArrayList<>();
}
subDocs.add(readDoc(parser));
}
diff --git a/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.java b/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.java
index 94d6cb54573..66af682f621 100644
--- a/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.java
+++ b/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.java
@@ -19,7 +19,6 @@ package org.apache.solr.packagemanager;
import static org.apache.solr.packagemanager.PackageUtils.getMapper;
-import com.google.common.base.Strings;
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.PathNotFoundException;
import java.io.Closeable;
@@ -53,6 +52,7 @@ import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.util.Pair;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.common.util.Utils;
import org.apache.solr.filestore.DistribPackageStore;
import org.apache.solr.handler.admin.ContainerPluginsApi;
@@ -251,7 +251,7 @@ public class PackageManager implements Closeable {
if (packages == null) return Collections.emptyMap();
Map<String, SolrPackageInstance> ret = new HashMap<>();
for (String packageName : packages.keySet()) {
- if (Strings.isNullOrEmpty(packageName) == false
+ if (StrUtils.isNullOrEmpty(packageName) == false
&& // There can be an empty key, storing the version here
packages.get(packageName)
!= null) { // null means the package was undeployed from this package before
@@ -312,7 +312,7 @@ public class PackageManager implements Closeable {
}
Map<String, SolrPackageInstance> ret = new HashMap<>();
for (String packageName : packageVersions.keySet()) {
- if (Strings.isNullOrEmpty(packageName) == false
+ if (StrUtils.isNullOrEmpty(packageName) == false
&& // There can be an empty key, storing the version here
packageVersions.get(packageName)
!= null) { // null means the package was undeployed from this package before
@@ -489,7 +489,7 @@ public class PackageManager implements Closeable {
plugin.name);
Command cmd = plugin.setupCommand;
- if (cmd != null && !Strings.isNullOrEmpty(cmd.method)) {
+ if (cmd != null && !StrUtils.isNullOrEmpty(cmd.method)) {
if ("POST".equalsIgnoreCase(cmd.method)) {
try {
String payload =
@@ -644,7 +644,7 @@ public class PackageManager implements Closeable {
"plugin-name",
plugin.name);
Command cmd = plugin.setupCommand;
- if (cmd != null && !Strings.isNullOrEmpty(cmd.method)) {
+ if (cmd != null && !StrUtils.isNullOrEmpty(cmd.method)) {
if ("POST".equalsIgnoreCase(cmd.method)) {
try {
Map<String, String> overridesMap = getParameterOverrides(overrides);
@@ -767,7 +767,7 @@ public class PackageManager implements Closeable {
boolean success = true;
for (Plugin plugin : pkg.plugins) {
Command cmd = plugin.verifyCommand;
- if (plugin.verifyCommand != null && !Strings.isNullOrEmpty(cmd.path)) {
+ if (plugin.verifyCommand != null && !StrUtils.isNullOrEmpty(cmd.path)) {
if ("cluster".equalsIgnoreCase(plugin.type)) {
if (!shouldDeployClusterPlugins) continue; // Plugins of type "cluster"
Map<String, String> overridesMap = getParameterOverrides(overrides);
@@ -1001,7 +1001,7 @@ public class PackageManager implements Closeable {
"plugin-name",
plugin.name);
Command cmd = plugin.uninstallCommand;
- if (cmd != null && !Strings.isNullOrEmpty(cmd.method)) {
+ if (cmd != null && !StrUtils.isNullOrEmpty(cmd.method)) {
if ("POST".equalsIgnoreCase(cmd.method)) {
try {
String payload =
@@ -1057,7 +1057,7 @@ public class PackageManager implements Closeable {
"plugin-name",
plugin.name);
Command cmd = plugin.uninstallCommand;
- if (cmd != null && !Strings.isNullOrEmpty(cmd.method)) {
+ if (cmd != null && !StrUtils.isNullOrEmpty(cmd.method)) {
if ("POST".equalsIgnoreCase(cmd.method)) {
try {
String payload =
diff --git a/solr/core/src/java/org/apache/solr/parser/SolrQueryParserBase.java b/solr/core/src/java/org/apache/solr/parser/SolrQueryParserBase.java
index 410b59efceb..7c5c1615978 100644
--- a/solr/core/src/java/org/apache/solr/parser/SolrQueryParserBase.java
+++ b/solr/core/src/java/org/apache/solr/parser/SolrQueryParserBase.java
@@ -18,7 +18,6 @@ package org.apache.solr.parser;
import static org.apache.solr.parser.SolrQueryParserBase.SynonymQueryStyle.AS_SAME_TERM;
-import com.google.common.base.Strings;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Collections;
@@ -60,6 +59,7 @@ import org.apache.lucene.util.automaton.Operations;
import org.apache.solr.analysis.ReversedWildcardFilterFactory;
import org.apache.solr.analysis.TokenizerChain;
import org.apache.solr.common.SolrException;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.parser.QueryParser.Operator;
import org.apache.solr.query.FilterQuery;
import org.apache.solr.schema.FieldType;
@@ -291,7 +291,7 @@ public abstract class SolrQueryParserBase extends QueryBuilder {
/** Handles the default field if null is passed */
public String getField(String fieldName) {
explicitField = fieldName;
- return !Strings.isNullOrEmpty(fieldName) ? fieldName : this.defaultField;
+ return !StrUtils.isNullOrEmpty(fieldName) ? fieldName : this.defaultField;
}
/**
@@ -1024,7 +1024,7 @@ public abstract class SolrQueryParserBase extends QueryBuilder {
}
private void checkNullField(String field) throws SolrException {
- if (Strings.isNullOrEmpty(field) && Strings.isNullOrEmpty(defaultField)) {
+ if (StrUtils.isNullOrEmpty(field) && StrUtils.isNullOrEmpty(defaultField)) {
throw new SolrException(
SolrException.ErrorCode.BAD_REQUEST,
"no field name specified in query and no default specified via 'df' param");
diff --git a/solr/core/src/java/org/apache/solr/response/TabularResponseWriter.java b/solr/core/src/java/org/apache/solr/response/TabularResponseWriter.java
index 05caec757b0..c05f6cef833 100644
--- a/solr/core/src/java/org/apache/solr/response/TabularResponseWriter.java
+++ b/solr/core/src/java/org/apache/solr/response/TabularResponseWriter.java
@@ -17,8 +17,6 @@
package org.apache.solr.response;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Sets;
import java.io.IOException;
import java.io.Writer;
import java.util.Collection;
@@ -27,6 +25,8 @@ import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.util.NamedList;
@@ -63,16 +63,18 @@ public abstract class TabularResponseWriter extends TextResponseWriter {
} else {
// get the list of fields from the index
Iterable<String> all = req.getSearcher().getFieldNames();
+ Set<String> allSet =
+ StreamSupport.stream(all.spliterator(), false).collect(Collectors.toSet());
if (fields == null) {
- fields = Sets.newHashSet(all);
+ fields = allSet;
} else {
- Iterables.addAll(fields, all);
+ fields.addAll(allSet);
}
}
if (explicitReqFields != null) {
// add explicit requested fields
- Iterables.addAll(fields, explicitReqFields);
+ fields.addAll(explicitReqFields);
}
if (returnFields.wantsScore()) {
diff --git a/solr/core/src/java/org/apache/solr/response/transform/RawValueTransformerFactory.java b/solr/core/src/java/org/apache/solr/response/transform/RawValueTransformerFactory.java
index 911210c9eeb..67cbb7a7cd2 100644
--- a/solr/core/src/java/org/apache/solr/response/transform/RawValueTransformerFactory.java
+++ b/solr/core/src/java/org/apache/solr/response/transform/RawValueTransformerFactory.java
@@ -16,7 +16,6 @@
*/
package org.apache.solr.response.transform;
-import com.google.common.base.Strings;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
@@ -25,6 +24,7 @@ import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.QueryResponseWriter;
@@ -69,7 +69,7 @@ public class RawValueTransformerFactory extends TransformerFactory
Map<String, String> renamedFields,
Set<String> reqFieldNames) {
String field = params.get("f");
- if (Strings.isNullOrEmpty(field)) {
+ if (StrUtils.isNullOrEmpty(field)) {
field = display;
}
field = renamedFields.getOrDefault(field, field);
diff --git a/solr/core/src/java/org/apache/solr/schema/AbstractSpatialFieldType.java b/solr/core/src/java/org/apache/solr/schema/AbstractSpatialFieldType.java
index 22f335d3618..d94e4fc32b3 100644
--- a/solr/core/src/java/org/apache/solr/schema/AbstractSpatialFieldType.java
+++ b/solr/core/src/java/org/apache/solr/schema/AbstractSpatialFieldType.java
@@ -16,9 +16,8 @@
*/
package org.apache.solr.schema;
-import com.google.common.base.Throwables;
-import com.google.common.cache.Cache;
-import com.google.common.cache.CacheBuilder;
+import com.github.benmanes.caffeine.cache.Cache;
+import com.github.benmanes.caffeine.cache.Caffeine;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.text.ParseException;
@@ -29,7 +28,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
-import java.util.concurrent.ExecutionException;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.StoredField;
import org.apache.lucene.index.IndexableField;
@@ -104,7 +102,7 @@ public abstract class AbstractSpatialFieldType<T extends SpatialStrategy> extend
protected ShapeWriter shapeWriter;
protected ShapeReader shapeReader;
- private final Cache<String, T> fieldStrategyCache = CacheBuilder.newBuilder().build();
+ private final Cache<String, T> fieldStrategyCache = Caffeine.newBuilder().build();
protected DistanceUnits distanceUnits;
@@ -463,11 +461,7 @@ public abstract class AbstractSpatialFieldType<T extends SpatialStrategy> extend
* @return Non-null.
*/
public T getStrategy(final String fieldName) {
- try {
- return fieldStrategyCache.get(fieldName, () -> newSpatialStrategy(fieldName));
- } catch (ExecutionException e) {
- throw Throwables.propagate(e.getCause());
- }
+ return fieldStrategyCache.get(fieldName, k -> newSpatialStrategy(fieldName));
}
/**
diff --git a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
index 2c7a521cb2f..98bfcc4f83e 100644
--- a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
+++ b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
@@ -20,7 +20,6 @@ import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap;
-import com.google.common.collect.ImmutableSet;
import java.io.IOException;
import java.io.Writer;
import java.lang.invoke.MethodHandles;
@@ -137,8 +136,8 @@ public class IndexSchema {
return dynamicFields;
}
- private static final Set<String> FIELDTYPE_KEYS = ImmutableSet.of("fieldtype", "fieldType");
- private static final Set<String> FIELD_KEYS = ImmutableSet.of("dynamicField", "field");
+ private static final Set<String> FIELDTYPE_KEYS = Set.of("fieldtype", "fieldType");
+ private static final Set<String> FIELD_KEYS = Set.of("dynamicField", "field");
protected Cache<String, SchemaField> dynamicFieldCache =
new ConcurrentLRUCache<>(10000, 8000, 9000, 100, false, false, null);
diff --git a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
index 77c452add7c..9764f3861cb 100644
--- a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
+++ b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
@@ -17,7 +17,6 @@
package org.apache.solr.search;
import com.codahale.metrics.Gauge;
-import com.google.common.collect.Iterables;
import java.io.Closeable;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
@@ -38,6 +37,8 @@ import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.atomic.LongAdder;
import java.util.function.Supplier;
+import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.ExitableDirectoryReader;
@@ -615,7 +616,9 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
/** Returns a collection of all field names the index reader knows about. */
public Iterable<String> getFieldNames() {
- return Iterables.transform(getFieldInfos(), fieldInfo -> fieldInfo.name);
+ return StreamSupport.stream(getFieldInfos().spliterator(), false)
+ .map(fieldInfo -> fieldInfo.name)
+ .collect(Collectors.toUnmodifiableList());
}
public SolrCache<Query, DocSet> getFilterCache() {
diff --git a/solr/core/src/java/org/apache/solr/search/facet/FacetRequest.java b/solr/core/src/java/org/apache/solr/search/facet/FacetRequest.java
index 2b56d8596cc..65b2f3f5ea3 100644
--- a/solr/core/src/java/org/apache/solr/search/facet/FacetRequest.java
+++ b/solr/core/src/java/org/apache/solr/search/facet/FacetRequest.java
@@ -18,7 +18,6 @@ package org.apache.solr.search.facet;
import static org.apache.solr.search.facet.FacetRequest.RefineMethod.NONE;
-import com.google.common.collect.Sets;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.List;
@@ -187,7 +186,7 @@ public abstract class FacetRequest {
private static final String TO_PARAM = "to";
private static final String METHOD_PARAM = "method";
private static final Set<String> SUPPORTED_JOIN_PROPERTIES =
- Sets.newHashSet(FROM_PARAM, TO_PARAM, METHOD_PARAM);
+ Set.of(FROM_PARAM, TO_PARAM, METHOD_PARAM);
public final String from;
public final String to;
diff --git a/solr/core/src/java/org/apache/solr/security/BasicAuthPlugin.java b/solr/core/src/java/org/apache/solr/security/BasicAuthPlugin.java
index 87abbb0f1e4..f6dfbfe29f5 100644
--- a/solr/core/src/java/org/apache/solr/security/BasicAuthPlugin.java
+++ b/solr/core/src/java/org/apache/solr/security/BasicAuthPlugin.java
@@ -16,7 +16,6 @@
*/
package org.apache.solr.security;
-import com.google.common.collect.ImmutableSet;
import java.io.IOException;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
@@ -274,7 +273,7 @@ public class BasicAuthPlugin extends AuthenticationPlugin
public static final String PROPERTY_REALM = "realm";
public static final String FORWARD_CREDENTIALS = "forwardCredentials";
private static final Set<String> PROPS =
- ImmutableSet.of(PROPERTY_BLOCK_UNKNOWN, PROPERTY_REALM, FORWARD_CREDENTIALS);
+ Set.of(PROPERTY_BLOCK_UNKNOWN, PROPERTY_REALM, FORWARD_CREDENTIALS);
/**
* Check if the request is an AJAX request, i.e. from the Admin UI or other SPA front
diff --git a/solr/core/src/java/org/apache/solr/security/Permission.java b/solr/core/src/java/org/apache/solr/security/Permission.java
index a634aea0481..982772ad7bf 100644
--- a/solr/core/src/java/org/apache/solr/security/Permission.java
+++ b/solr/core/src/java/org/apache/solr/security/Permission.java
@@ -21,7 +21,6 @@ import static java.util.Collections.singleton;
import static java.util.Collections.singletonList;
import static org.apache.solr.common.params.CommonParams.NAME;
-import com.google.common.collect.ImmutableSet;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
@@ -161,7 +160,6 @@ class Permission {
}
static final Set<String> knownKeys =
- ImmutableSet.of("collection", "role", "params", "path", "method", NAME, "index");
- public static final Set<String> HTTP_METHODS =
- ImmutableSet.of("GET", "POST", "DELETE", "PUT", "HEAD");
+ Set.of("collection", "role", "params", "path", "method", NAME, "index");
+ public static final Set<String> HTTP_METHODS = Set.of("GET", "POST", "DELETE", "PUT", "HEAD");
}
diff --git a/solr/core/src/java/org/apache/solr/security/Sha256AuthenticationProvider.java b/solr/core/src/java/org/apache/solr/security/Sha256AuthenticationProvider.java
index cc9ca3220b9..ea00f1c4607 100644
--- a/solr/core/src/java/org/apache/solr/security/Sha256AuthenticationProvider.java
+++ b/solr/core/src/java/org/apache/solr/security/Sha256AuthenticationProvider.java
@@ -18,7 +18,6 @@ package org.apache.solr.security;
import static org.apache.solr.handler.admin.SecurityConfHandler.getMapValue;
-import com.google.common.collect.ImmutableSet;
import java.lang.invoke.MethodHandles;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
@@ -180,5 +179,5 @@ public class Sha256AuthenticationProvider
return apis.get(0).getSpec();
}
- static final Set<String> supported_ops = ImmutableSet.of("set-user", "delete-user");
+ static final Set<String> supported_ops = Set.of("set-user", "delete-user");
}
diff --git a/solr/core/src/java/org/apache/solr/update/DocumentBuilder.java b/solr/core/src/java/org/apache/solr/update/DocumentBuilder.java
index 4a6a5308c59..64ae65239d8 100644
--- a/solr/core/src/java/org/apache/solr/update/DocumentBuilder.java
+++ b/solr/core/src/java/org/apache/solr/update/DocumentBuilder.java
@@ -16,8 +16,8 @@
*/
package org.apache.solr.update;
-import com.google.common.collect.Sets;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -133,7 +133,7 @@ public class DocumentBuilder {
final String uniqueKeyFieldName = null == uniqueKeyField ? null : uniqueKeyField.getName();
Document out = new Document();
- Set<String> usedFields = Sets.newHashSet();
+ Set<String> usedFields = new HashSet<>();
// Load fields from SolrDocument to Document
for (SolrInputField field : doc) {
diff --git a/solr/core/src/java/org/apache/solr/util/CryptoKeys.java b/solr/core/src/java/org/apache/solr/util/CryptoKeys.java
index 2d87aa2e38a..ea6cc20bc4f 100644
--- a/solr/core/src/java/org/apache/solr/util/CryptoKeys.java
+++ b/solr/core/src/java/org/apache/solr/util/CryptoKeys.java
@@ -16,7 +16,6 @@
*/
package org.apache.solr.util;
-import com.google.common.collect.ImmutableMap;
import java.io.IOException;
import java.io.InputStream;
import java.lang.invoke.MethodHandles;
@@ -66,7 +65,7 @@ public final class CryptoKeys {
for (Map.Entry<String, byte[]> e : trustedKeys.entrySet()) {
m.put(e.getKey(), getX509PublicKey(e.getValue()));
}
- this.keys = ImmutableMap.copyOf(m);
+ this.keys = Map.copyOf(m);
}
/** Try with all signatures and return the name of the signature that matched */
diff --git a/solr/core/src/java/org/apache/solr/util/DistanceUnits.java b/solr/core/src/java/org/apache/solr/util/DistanceUnits.java
index 8c0bc91fd24..3636aff9f4f 100644
--- a/solr/core/src/java/org/apache/solr/util/DistanceUnits.java
+++ b/solr/core/src/java/org/apache/solr/util/DistanceUnits.java
@@ -16,7 +16,6 @@
*/
package org.apache.solr.util;
-import com.google.common.collect.ImmutableMap;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -47,7 +46,7 @@ public class DistanceUnits {
// volatile so other threads see when we replace when copy-on-write
private static volatile Map<String, DistanceUnits> instances =
- ImmutableMap.of(
+ Map.of(
KILOMETERS_PARAM, KILOMETERS,
MILES_PARAM, MILES,
DEGREES_PARAM, DEGREES);
@@ -121,7 +120,7 @@ public class DistanceUnits {
// copy-on-write.
Map<String, DistanceUnits> map = new HashMap<>(instances);
map.put(strId, new DistanceUnits(strId, earthRadius, multiplierThisToDegrees));
- instances = ImmutableMap.copyOf(map);
+ instances = Map.copyOf(map);
}
@Override
diff --git a/solr/core/src/java/org/apache/solr/util/ExportTool.java b/solr/core/src/java/org/apache/solr/util/ExportTool.java
index 90181fdc429..1f611a8e03e 100644
--- a/solr/core/src/java/org/apache/solr/util/ExportTool.java
+++ b/solr/core/src/java/org/apache/solr/util/ExportTool.java
@@ -23,7 +23,6 @@ import static org.apache.solr.common.params.CommonParams.Q;
import static org.apache.solr.common.params.CommonParams.SORT;
import static org.apache.solr.common.util.JavaBinCodec.SOLRINPUTDOC;
-import com.google.common.collect.ImmutableSet;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
@@ -174,7 +173,7 @@ public class ExportTool extends SolrCLI.ToolBase {
}
}
- static Set<String> formats = ImmutableSet.of(JAVABIN, "jsonl");
+ static Set<String> formats = Set.of(JAVABIN, "jsonl");
@Override
protected void runImpl(CommandLine cli) throws Exception {
diff --git a/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java b/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java
index 88d3044fda5..dd23d37ceec 100644
--- a/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java
+++ b/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java
@@ -22,7 +22,6 @@ import static org.apache.solr.core.PluginInfo.DEFAULTS;
import static org.apache.solr.core.PluginInfo.INVARIANTS;
import static org.apache.solr.core.RequestParams.USEPARAM;
-import com.google.common.collect.ImmutableMap;
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
@@ -115,8 +114,7 @@ public class SolrPluginUtils {
purposes = Collections.unmodifiableMap(map);
}
- private static final MapSolrParams maskUseParams =
- new MapSolrParams(ImmutableMap.<String, String>builder().put(USEPARAM, "").build());
+ private static final MapSolrParams maskUseParams = new MapSolrParams(Map.of(USEPARAM, ""));
/**
* Set default-ish params on a SolrQueryRequest.
diff --git a/solr/core/src/java/org/apache/solr/util/configuration/SSLCredentialProviderFactory.java b/solr/core/src/java/org/apache/solr/util/configuration/SSLCredentialProviderFactory.java
index 10ae9f27f3a..a0c79eec230 100644
--- a/solr/core/src/java/org/apache/solr/util/configuration/SSLCredentialProviderFactory.java
+++ b/solr/core/src/java/org/apache/solr/util/configuration/SSLCredentialProviderFactory.java
@@ -17,7 +17,6 @@
package org.apache.solr.util.configuration;
-import com.google.common.collect.ImmutableMap;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
@@ -36,7 +35,7 @@ public class SSLCredentialProviderFactory {
public static final String PROVIDER_CHAIN_KEY = "solr.ssl.credential.provider.chain";
private static final Map<String, Class<? extends SSLCredentialProvider>> defaultProviders =
- ImmutableMap.of(
+ Map.of(
"env", EnvSSLCredentialProvider.class,
"sysprop", SysPropSSLCredentialProvider.class);
diff --git a/solr/core/src/java/org/apache/solr/util/configuration/providers/AbstractSSLCredentialProvider.java b/solr/core/src/java/org/apache/solr/util/configuration/providers/AbstractSSLCredentialProvider.java
index d6ddbc72515..1c135dc28c7 100644
--- a/solr/core/src/java/org/apache/solr/util/configuration/providers/AbstractSSLCredentialProvider.java
+++ b/solr/core/src/java/org/apache/solr/util/configuration/providers/AbstractSSLCredentialProvider.java
@@ -22,16 +22,15 @@ import static org.apache.solr.util.configuration.SSLCredentialProvider.Credentia
import static org.apache.solr.util.configuration.SSLCredentialProvider.CredentialType.SSL_KEY_STORE_PASSWORD;
import static org.apache.solr.util.configuration.SSLCredentialProvider.CredentialType.SSL_TRUST_STORE_PASSWORD;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
import java.util.EnumMap;
+import java.util.Map;
import org.apache.solr.util.configuration.SSLCredentialProvider;
/** Abstract provider with default implementation */
public abstract class AbstractSSLCredentialProvider implements SSLCredentialProvider {
public static final EnumMap<CredentialType, String> DEFAULT_CREDENTIAL_KEY_MAP =
- Maps.newEnumMap(
- ImmutableMap.of(
+ new EnumMap<>(
+ Map.of(
SSL_KEY_STORE_PASSWORD, "solr.jetty.keystore.password",
SSL_TRUST_STORE_PASSWORD, "solr.jetty.truststore.password",
SSL_CLIENT_KEY_STORE_PASSWORD, "javax.net.ssl.keyStorePassword",
diff --git a/solr/core/src/java/org/apache/solr/util/configuration/providers/EnvSSLCredentialProvider.java b/solr/core/src/java/org/apache/solr/util/configuration/providers/EnvSSLCredentialProvider.java
index 06bac86b932..00bd693e789 100644
--- a/solr/core/src/java/org/apache/solr/util/configuration/providers/EnvSSLCredentialProvider.java
+++ b/solr/core/src/java/org/apache/solr/util/configuration/providers/EnvSSLCredentialProvider.java
@@ -23,8 +23,6 @@ import static org.apache.solr.util.configuration.SSLCredentialProvider.Credentia
import static org.apache.solr.util.configuration.SSLCredentialProvider.CredentialType.SSL_TRUST_STORE_PASSWORD;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
import java.util.EnumMap;
import java.util.Map;
@@ -48,8 +46,8 @@ public class EnvSSLCredentialProvider extends AbstractSSLCredentialProvider {
@Override
protected EnumMap<CredentialType, String> getCredentialKeyMap() {
- return Maps.newEnumMap(
- ImmutableMap.of(
+ return new EnumMap<>(
+ Map.of(
SSL_KEY_STORE_PASSWORD, EnvVars.SOLR_SSL_KEY_STORE_PASSWORD,
SSL_TRUST_STORE_PASSWORD, EnvVars.SOLR_SSL_TRUST_STORE_PASSWORD,
SSL_CLIENT_KEY_STORE_PASSWORD, EnvVars.SOLR_SSL_CLIENT_KEY_STORE_PASSWORD,
diff --git a/solr/core/src/test/org/apache/solr/TestCrossCoreJoin.java b/solr/core/src/test/org/apache/solr/TestCrossCoreJoin.java
index a2b8e08e27b..83f91365294 100644
--- a/solr/core/src/test/org/apache/solr/TestCrossCoreJoin.java
+++ b/solr/core/src/test/org/apache/solr/TestCrossCoreJoin.java
@@ -16,9 +16,9 @@
*/
package org.apache.solr;
-import com.google.common.collect.ImmutableMap;
import java.io.StringWriter;
import java.util.Collections;
+import java.util.Map;
import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.core.CoreContainer;
@@ -50,7 +50,7 @@ public class TestCrossCoreJoin extends SolrTestCaseJ4 {
initCore("solrconfig.xml", "schema12.xml", TEST_HOME(), "collection1");
final CoreContainer coreContainer = h.getCoreContainer();
- fromCore = coreContainer.create("fromCore", ImmutableMap.of("configSet", "minimal"));
+ fromCore = coreContainer.create("fromCore", Map.of("configSet", "minimal"));
assertU(
add(
diff --git a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java
index 7effdefa65b..40b822a3773 100644
--- a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java
@@ -23,7 +23,6 @@ import static org.apache.solr.common.cloud.ZkStateReader.NUM_SHARDS_PROP;
import static org.apache.solr.common.params.CollectionAdminParams.COLLECTION;
import static org.apache.solr.common.params.CollectionAdminParams.DEFAULTS;
-import com.google.common.collect.ImmutableList;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.nio.file.Path;
@@ -148,12 +147,12 @@ public class CollectionsAPISolrJTest extends SolrCloudTestCase {
Object clusterProperty =
cluster
.getZkStateReader()
- .getClusterProperty(ImmutableList.of(DEFAULTS, COLLECTION, NUM_SHARDS_PROP), null);
+ .getClusterProperty(List.of(DEFAULTS, COLLECTION, NUM_SHARDS_PROP), null);
assertEquals("2", String.valueOf(clusterProperty));
clusterProperty =
cluster
.getZkStateReader()
- .getClusterProperty(ImmutableList.of(DEFAULTS, COLLECTION, NRT_REPLICAS), null);
+ .getClusterProperty(List.of(DEFAULTS, COLLECTION, NRT_REPLICAS), null);
assertEquals("2", String.valueOf(clusterProperty));
CollectionAdminResponse response =
CollectionAdminRequest.createCollection(COLL_NAME, "conf", null, null, null, null)
@@ -193,14 +192,14 @@ public class CollectionsAPISolrJTest extends SolrCloudTestCase {
clusterProperty =
cluster
.getZkStateReader()
- .getClusterProperty(ImmutableList.of(DEFAULTS, COLLECTION, NRT_REPLICAS), null);
+ .getClusterProperty(List.of(DEFAULTS, COLLECTION, NRT_REPLICAS), null);
if (clusterProperty == null) break;
}
assertNull(clusterProperty);
clusterProperty =
cluster
.getZkStateReader()
- .getClusterProperty(ImmutableList.of(COLLECTION_DEF, NRT_REPLICAS), null);
+ .getClusterProperty(List.of(COLLECTION_DEF, NRT_REPLICAS), null);
assertNull(clusterProperty);
// delete all defaults the old way
@@ -216,14 +215,14 @@ public class CollectionsAPISolrJTest extends SolrCloudTestCase {
clusterProperty =
cluster
.getZkStateReader()
- .getClusterProperty(ImmutableList.of(DEFAULTS, COLLECTION, NUM_SHARDS_PROP), null);
+ .getClusterProperty(List.of(DEFAULTS, COLLECTION, NUM_SHARDS_PROP), null);
if (clusterProperty == null) break;
}
assertNull(clusterProperty);
clusterProperty =
cluster
.getZkStateReader()
- .getClusterProperty(ImmutableList.of(COLLECTION_DEF, NUM_SHARDS_PROP), null);
+ .getClusterProperty(List.of(COLLECTION_DEF, NUM_SHARDS_PROP), null);
assertNull(clusterProperty);
} finally {
// clean up in case there was an exception during the test
@@ -256,12 +255,12 @@ public class CollectionsAPISolrJTest extends SolrCloudTestCase {
Object clusterProperty =
cluster
.getZkStateReader()
- .getClusterProperty(ImmutableList.of(DEFAULTS, COLLECTION, NUM_SHARDS_PROP), null);
+ .getClusterProperty(List.of(DEFAULTS, COLLECTION, NUM_SHARDS_PROP), null);
assertEquals("2", String.valueOf(clusterProperty));
clusterProperty =
cluster
.getZkStateReader()
- .getClusterProperty(ImmutableList.of(DEFAULTS, COLLECTION, NRT_REPLICAS), null);
+ .getClusterProperty(List.of(DEFAULTS, COLLECTION, NRT_REPLICAS), null);
assertEquals("2", String.valueOf(clusterProperty));
CollectionAdminResponse response =
CollectionAdminRequest.createCollection(COLL_NAME, "conf", null, null, null, null)
@@ -302,7 +301,7 @@ public class CollectionsAPISolrJTest extends SolrCloudTestCase {
clusterProperty =
cluster
.getZkStateReader()
- .getClusterProperty(ImmutableList.of(DEFAULTS, COLLECTION, NRT_REPLICAS), null);
+ .getClusterProperty(List.of(DEFAULTS, COLLECTION, NRT_REPLICAS), null);
if (clusterProperty == null) break;
}
assertNull(clusterProperty);
@@ -319,14 +318,14 @@ public class CollectionsAPISolrJTest extends SolrCloudTestCase {
clusterProperty =
cluster
.getZkStateReader()
- .getClusterProperty(ImmutableList.of(DEFAULTS, COLLECTION, NUM_SHARDS_PROP), null);
+ .getClusterProperty(List.of(DEFAULTS, COLLECTION, NUM_SHARDS_PROP), null);
if (clusterProperty == null) break;
}
assertNull(clusterProperty);
clusterProperty =
cluster
.getZkStateReader()
- .getClusterProperty(ImmutableList.of(COLLECTION_DEF, NUM_SHARDS_PROP), null);
+ .getClusterProperty(List.of(COLLECTION_DEF, NUM_SHARDS_PROP), null);
assertNull(clusterProperty);
} finally {
V2Response rsp =
diff --git a/solr/core/src/test/org/apache/solr/cloud/NestedShardedAtomicUpdateTest.java b/solr/core/src/test/org/apache/solr/cloud/NestedShardedAtomicUpdateTest.java
index 990f760bf55..e99032c7520 100644
--- a/solr/core/src/test/org/apache/solr/cloud/NestedShardedAtomicUpdateTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/NestedShardedAtomicUpdateTest.java
@@ -18,6 +18,7 @@
package org.apache.solr.cloud;
import java.io.IOException;
+import java.lang.invoke.MethodHandles;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
@@ -39,21 +40,28 @@ import org.junit.BeforeClass;
import org.junit.Test;
public class NestedShardedAtomicUpdateTest extends SolrCloudTestCase {
- private static final String DEFAULT_COLLECTION = "col1";
+ private static final String DEBUG_LABEL = MethodHandles.lookup().lookupClass().getName();
+ private static final String DEFAULT_COLLECTION = DEBUG_LABEL + "_collection";
+
private static CloudSolrClient cloudClient;
private static List<SolrClient> clients; // not CloudSolrClient
@BeforeClass
public static void beforeClass() throws Exception {
- configureCluster(1).addConfig("_default", configset("cloud-minimal")).configure();
- // replace schema.xml with schema-test.xml
- Path schemaPath = TEST_COLL1_CONF().resolve("schema-nest.xml");
- cluster.getZkClient().setData("/configs/_default/schema.xml", schemaPath, true);
+ final String configName = DEBUG_LABEL + "_config-set";
+ final Path configDir = TEST_COLL1_CONF();
+
+ configureCluster(1).addConfig(configName, configDir).configure();
cloudClient = cluster.getSolrClient();
cloudClient.setDefaultCollection(DEFAULT_COLLECTION);
- CollectionAdminRequest.createCollection(DEFAULT_COLLECTION, 4, 1).process(cloudClient);
+ CollectionAdminRequest.createCollection(DEFAULT_COLLECTION, configName, 4, 1)
+ .withProperty("config", "solrconfig-tlog.xml")
+ .withProperty("schema", "schema-nest.xml")
+ .process(cloudClient);
+
+ cluster.waitForActiveCollection(DEFAULT_COLLECTION, 4, 4);
clients = new ArrayList<>();
ClusterState clusterState = cloudClient.getClusterState();
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPI.java b/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPI.java
index ba97eb6371d..0a26e358cbe 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPI.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPI.java
@@ -21,7 +21,6 @@ import static org.apache.solr.common.params.CommonParams.NAME;
import static org.apache.solr.core.ConfigSetProperties.DEFAULT_FILENAME;
import static org.hamcrest.CoreMatchers.containsString;
-import com.google.common.collect.ImmutableMap;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -184,14 +183,14 @@ public class TestConfigSetsAPI extends SolrCloudTestCase {
"baseConfigSet2",
"configSet2",
null,
- ImmutableMap.<String, String>of("immutable", "true", "key1", "value1"),
+ Map.of("immutable", "true", "key1", "value1"),
"solr");
// old, no new
verifyCreate(
"baseConfigSet3",
"configSet3",
- ImmutableMap.<String, String>of("immutable", "false", "key2", "value2"),
+ Map.of("immutable", "false", "key2", "value2"),
null,
"solr");
@@ -199,8 +198,8 @@ public class TestConfigSetsAPI extends SolrCloudTestCase {
verifyCreate(
"baseConfigSet4",
"configSet4",
- ImmutableMap.<String, String>of("immutable", "true", "onlyOld", "onlyOldValue"),
- ImmutableMap.<String, String>of("immutable", "false", "onlyNew", "onlyNewValue"),
+ Map.of("immutable", "true", "onlyOld", "onlyOldValue"),
+ Map.of("immutable", "false", "onlyNew", "onlyNewValue"),
"solr");
}
@@ -1882,7 +1881,7 @@ public class TestConfigSetsAPI extends SolrCloudTestCase {
FileUtils.copyDirectory(configDir, tmpConfigDir);
FileUtils.write(
new File(tmpConfigDir, "configsetprops.json"),
- getConfigSetProps(ImmutableMap.<String, String>of("immutable", "true")),
+ getConfigSetProps(Map.of("immutable", "true")),
UTF_8);
getConfigSetService().uploadConfig("configSet", tmpConfigDir.toPath());
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPIZkFailure.java b/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPIZkFailure.java
index 3183f2e15ce..f5043df7abb 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPIZkFailure.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPIZkFailure.java
@@ -18,7 +18,6 @@ package org.apache.solr.cloud;
import static org.apache.solr.cloud.ZkConfigSetService.CONFIGS_ZKNODE;
-import com.google.common.collect.ImmutableMap;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
@@ -113,7 +112,7 @@ public class TestConfigSetsAPIZkFailure extends SolrTestCaseJ4 {
final ConfigSetService configSetService =
solrCluster.getOpenOverseer().getCoreContainer().getConfigSetService();
- final Map<String, String> oldProps = ImmutableMap.of("immutable", "true");
+ final Map<String, String> oldProps = Map.of("immutable", "true");
setupBaseConfigSet(BASE_CONFIGSET_NAME, oldProps);
SolrZkClient zkClient =
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestLockTree.java b/solr/core/src/test/org/apache/solr/cloud/TestLockTree.java
index 5696134315a..33455cc2f0c 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestLockTree.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestLockTree.java
@@ -22,7 +22,6 @@ import static org.apache.solr.common.params.CollectionParams.CollectionAction.DE
import static org.apache.solr.common.params.CollectionParams.CollectionAction.MODIFYCOLLECTION;
import static org.apache.solr.common.params.CollectionParams.CollectionAction.SPLITSHARD;
-import com.google.common.collect.ImmutableSet;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
import java.util.Arrays;
@@ -72,9 +71,9 @@ public class TestLockTree extends SolrTestCaseJ4 {
List<Set<String>> orderOfExecution =
Arrays.asList(
- ImmutableSet.of("coll1/shard1/core_node2", "coll2/shard2"),
- ImmutableSet.of("coll1", "coll2"),
- ImmutableSet.of("coll1/shard1", "coll2/shard1"));
+ Set.of("coll1/shard1/core_node2", "coll2/shard2"),
+ Set.of("coll1", "coll2"),
+ Set.of("coll1/shard1", "coll2/shard1"));
lockTree = new LockTree();
for (int counter = 0; counter < orderOfExecution.size(); counter++) {
LockTree.Session session = lockTree.getSession();
diff --git a/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionAPI.java b/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionAPI.java
index 4cf897aaa4b..760d3b73d02 100644
--- a/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionAPI.java
+++ b/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionAPI.java
@@ -16,7 +16,6 @@
*/
package org.apache.solr.cloud.api.collections;
-import com.google.common.collect.Lists;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -628,7 +627,7 @@ public class TestCollectionAPI extends ReplicaPropertiesBase {
Map<String, Object> collection = (Map<String, Object>) collections.get(DEFAULT_COLLECTION);
assertEquals("conf1", collection.get("configName"));
List<String> collAlias = (List<String>) collection.get("aliases");
- assertEquals("Aliases not found", Lists.newArrayList("myalias"), collAlias);
+ assertEquals("Aliases not found", List.of("myalias"), collAlias);
// status request on the alias itself
params = new ModifiableSolrParams();
diff --git a/solr/core/src/test/org/apache/solr/core/TestConfigSets.java b/solr/core/src/test/org/apache/solr/core/TestConfigSets.java
index cedd92b40c8..458e0e8eb1c 100644
--- a/solr/core/src/test/org/apache/solr/core/TestConfigSets.java
+++ b/solr/core/src/test/org/apache/solr/core/TestConfigSets.java
@@ -22,11 +22,11 @@ import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.StringContains.containsString;
import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
-import com.google.common.collect.ImmutableMap;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.Map;
import org.apache.commons.io.FileUtils;
import org.apache.solr.SolrTestCaseJ4;
import org.hamcrest.MatcherAssert;
@@ -79,7 +79,7 @@ public class TestConfigSets extends SolrTestCaseJ4 {
container = setupContainer(TEST_PATH().resolve("configsets").toString());
Path solrHome = Paths.get(container.getSolrHome());
- SolrCore core1 = container.create("core1", ImmutableMap.of("configSet", "configset-2"));
+ SolrCore core1 = container.create("core1", Map.of("configSet", "configset-2"));
MatcherAssert.assertThat(core1.getCoreDescriptor().getName(), is("core1"));
MatcherAssert.assertThat(
Paths.get(core1.getDataDir()).toString(),
@@ -98,7 +98,7 @@ public class TestConfigSets extends SolrTestCaseJ4 {
Exception.class,
"Expected core creation to fail",
() -> {
- container.create("core1", ImmutableMap.of("configSet", "nonexistent"));
+ container.create("core1", Map.of("configSet", "nonexistent"));
});
Throwable wrappedException = getWrappedException(thrown);
MatcherAssert.assertThat(wrappedException.getMessage(), containsString("nonexistent"));
@@ -121,7 +121,7 @@ public class TestConfigSets extends SolrTestCaseJ4 {
container.load();
// We initially don't have a /dump handler defined
- SolrCore core = container.create("core1", ImmutableMap.of("configSet", "configset-2"));
+ SolrCore core = container.create("core1", Map.of("configSet", "configset-2"));
MatcherAssert.assertThat(
"No /dump handler should be defined in the initial configuration",
core.getRequestHandler("/dump"),
diff --git a/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java b/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java
index 41eeb5e78a0..29f4864685f 100644
--- a/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java
+++ b/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java
@@ -24,7 +24,6 @@ import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsInstanceOf.instanceOf;
import com.google.common.base.Throwables;
-import com.google.common.collect.ImmutableMap;
import java.io.File;
import java.io.FileOutputStream;
import java.nio.file.Files;
@@ -117,8 +116,8 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
CoreContainer cores = init(CONFIGSETS_SOLR_XML);
try {
- SolrCore core1 = cores.create("core1", ImmutableMap.of("configSet", "minimal"));
- SolrCore core2 = cores.create("core2", ImmutableMap.of("configSet", "minimal"));
+ SolrCore core1 = cores.create("core1", Map.of("configSet", "minimal"));
+ SolrCore core2 = cores.create("core2", Map.of("configSet", "minimal"));
assertSame(core1.getLatestSchema(), core2.getLatestSchema());
@@ -132,7 +131,7 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
public void testReloadSequential() throws Exception {
final CoreContainer cc = init(CONFIGSETS_SOLR_XML);
try {
- cc.create("core1", ImmutableMap.of("configSet", "minimal"));
+ cc.create("core1", Map.of("configSet", "minimal"));
cc.reload("core1");
cc.reload("core1");
cc.reload("core1");
@@ -159,7 +158,7 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
@Test
public void testReloadThreaded() throws Exception {
final CoreContainer cc = init(CONFIGSETS_SOLR_XML);
- cc.create("core1", ImmutableMap.of("configSet", "minimal"));
+ cc.create("core1", Map.of("configSet", "minimal"));
List<Thread> threads = new ArrayList<>();
int numThreads = 4;
@@ -192,7 +191,7 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
@Override
public void run() {
try {
- core = cc.create(coreName, ImmutableMap.of("configSet", "minimal"));
+ core = cc.create(coreName, Map.of("configSet", "minimal"));
} catch (SolrException e) {
String msg = e.getMessage();
foundExpectedError =
@@ -249,13 +248,12 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
// we didn't leave the record of trying to create this core around.
// NOTE: unloading the core closes it too.
cc.unload(testName, true, true, true);
- cc.create(testName, ImmutableMap.of("configSet", "minimal"));
+ cc.create(testName, Map.of("configSet", "minimal"));
// This call should fail with a different error because the core was
// created successfully.
SolrException thrown =
expectThrows(
- SolrException.class,
- () -> cc.create(testName, ImmutableMap.of("configSet", "minimal")));
+ SolrException.class, () -> cc.create(testName, Map.of("configSet", "minimal")));
assertTrue(
"Should have 'already exists' error", thrown.getMessage().contains("already exists"));
@@ -274,7 +272,7 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
assertEquals("There should not be cores", 0, cores.getCores().size());
// add a new core
- cores.create("core1", ImmutableMap.of("configSet", "minimal"));
+ cores.create("core1", Map.of("configSet", "minimal"));
// assert one registered core
@@ -345,7 +343,7 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
MatcherAssert.assertThat(cc.getCoreInitFailures().size(), is(0));
// can we create the core now with a good config?
- SolrCore core = cc.create("badcore", ImmutableMap.of("configSet", "minimal"));
+ SolrCore core = cc.create("badcore", Map.of("configSet", "minimal"));
MatcherAssert.assertThat(core, not(nullValue()));
} finally {
@@ -361,7 +359,7 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
ClassLoader baseLoader = SolrResourceLoader.class.getClassLoader();
assertSame(baseLoader, sharedLoader.getParent());
- SolrCore core1 = cc.create("core1", ImmutableMap.of("configSet", "minimal"));
+ SolrCore core1 = cc.create("core1", Map.of("configSet", "minimal"));
ClassLoader coreLoader = core1.getResourceLoader().getClassLoader();
assertSame(sharedLoader, coreLoader.getParent());
@@ -832,7 +830,7 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
expectThrows(
SolrException.class,
() -> {
- cc.create("bogus", ImmutableMap.of("configSet", "bogus_path"));
+ cc.create("bogus", Map.of("configSet", "bogus_path"));
});
Throwable rootCause = Throwables.getRootCause(thrown);
assertTrue(
@@ -935,7 +933,7 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
FileUtils.copyFile(
getFile("solr/collection1/conf/schema-minimal.xml"),
FileUtils.getFile(cc.getSolrHome(), "col_bad", "conf", "schema.xml"));
- cc.create("col_bad", ImmutableMap.of());
+ cc.create("col_bad", Map.of());
// check that we have the cores we expect
cores = cc.getLoadedCoreNames();
@@ -958,7 +956,7 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
expectThrows(
SolrException.class,
() -> {
- cc.create("bogus", ImmutableMap.of("configSet", "bogus_path"));
+ cc.create("bogus", Map.of("configSet", "bogus_path"));
});
assertTrue(
"init exception doesn't mention bogus dir: " + thrown.getCause().getCause().getMessage(),
diff --git a/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java b/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java
index cf5b75d77e7..7840646becf 100644
--- a/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java
+++ b/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java
@@ -22,7 +22,6 @@ import static org.apache.solr.core.CoreContainer.LOAD_COMPLETE;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.core.StringContains.containsString;
-import com.google.common.collect.ImmutableMap;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -35,6 +34,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import org.apache.commons.io.FileUtils;
@@ -262,7 +262,7 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {
// Creating a core successfully should create a core.properties file
Path corePropFile = Paths.get(solrHomeDirectory.toString(), "corep3", "core.properties");
assertFalse("Should not be a properties file yet", Files.exists(corePropFile));
- cc.create("corep3", ImmutableMap.of("configSet", "minimal"));
+ cc.create("corep3", Map.of("configSet", "minimal"));
assertTrue("Should be a properties file for newly created core", Files.exists(corePropFile));
// Failing to create a core should _not_ leave a core.properties file hanging around.
@@ -275,7 +275,7 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {
() -> {
cc.create(
"corep4",
- ImmutableMap.of(
+ Map.of(
CoreDescriptor.CORE_NAME, "corep4",
CoreDescriptor.CORE_SCHEMA, "not-there.xml",
CoreDescriptor.CORE_CONFIG, "solrconfig-minimal.xml",
@@ -292,7 +292,7 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {
corePropFile = Paths.get(solrHomeDirectory.toString(), "corep5", "core.properties");
assertFalse("Should not be a properties file yet for corep5", Files.exists(corePropFile));
- cc.create("corep5", ImmutableMap.of("configSet", "minimal"));
+ cc.create("corep5", Map.of("configSet", "minimal"));
assertTrue(
"corep5 should have left a core.properties file on disk", Files.exists(corePropFile));
@@ -466,7 +466,7 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {
assertNull(cc.getCore("core0"));
- SolrCore core3 = cc.create("core3", ImmutableMap.of("configSet", "minimal"));
+ SolrCore core3 = cc.create("core3", Map.of("configSet", "minimal"));
MatcherAssert.assertThat(
core3.getCoreDescriptor().getInstanceDir().toString(), containsString("relative"));
diff --git a/solr/core/src/test/org/apache/solr/core/TestLazyCores.java b/solr/core/src/test/org/apache/solr/core/TestLazyCores.java
index a94d806279f..cc76cefd791 100644
--- a/solr/core/src/test/org/apache/solr/core/TestLazyCores.java
+++ b/solr/core/src/test/org/apache/solr/core/TestLazyCores.java
@@ -16,7 +16,6 @@
*/
package org.apache.solr.core;
-import com.google.common.collect.ImmutableList;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@@ -81,7 +80,7 @@ public class TestLazyCores extends SolrTestCaseJ4 {
new ReadOnlyCoresLocator() {
@Override
public List<CoreDescriptor> discover(CoreContainer cc) {
- return ImmutableList.of(
+ return List.of(
makeCoreDescriptor(cc, "collection1", "false", "true"),
makeCoreDescriptor(cc, "collection2", "true", "true"),
makeCoreDescriptor(cc, "collection3", "on", "false"),
diff --git a/solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java b/solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java
index 415eb0c31c8..339bca8d122 100644
--- a/solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java
+++ b/solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java
@@ -19,7 +19,6 @@ package org.apache.solr.core;
import static java.util.Arrays.asList;
import static org.apache.solr.common.util.Utils.getObjectByPath;
-import com.google.common.collect.ImmutableList;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -639,18 +638,18 @@ public class TestSolrConfigHandler extends RestTestBase {
TIMEOUT_S);
assertEquals(
"solr.search.CaffeineCache",
- getObjectByPath(map, true, ImmutableList.of("overlay", "cache", "perSegFilter", "class")));
+ getObjectByPath(map, true, List.of("overlay", "cache", "perSegFilter", "class")));
map =
getRespMap("/dump101?cacheNames=lfuCacheDecayFalse&cacheNames=perSegFilter", writeHarness);
assertEquals(
"Actual output " + Utils.toJSONString(map),
"org.apache.solr.search.CaffeineCache",
- getObjectByPath(map, true, ImmutableList.of("caches", "perSegFilter")));
+ getObjectByPath(map, true, List.of("caches", "perSegFilter")));
assertEquals(
"Actual output " + Utils.toJSONString(map),
"org.apache.solr.search.CaffeineCache",
- getObjectByPath(map, true, ImmutableList.of("caches", "lfuCacheDecayFalse")));
+ getObjectByPath(map, true, List.of("caches", "lfuCacheDecayFalse")));
}
public void testFailures() throws Exception {
diff --git a/solr/core/src/test/org/apache/solr/handler/V2ClusterAPIMappingTest.java b/solr/core/src/test/org/apache/solr/handler/V2ClusterAPIMappingTest.java
index a7723c6e09f..94f091fba2a 100644
--- a/solr/core/src/test/org/apache/solr/handler/V2ClusterAPIMappingTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/V2ClusterAPIMappingTest.java
@@ -24,7 +24,6 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
-import com.google.common.collect.Maps;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -159,7 +158,7 @@ public class V2ClusterAPIMappingTest extends SolrTestCaseJ4 {
final Api api = apiBag.lookup(path, method, parts);
final SolrQueryResponse rsp = new SolrQueryResponse();
final LocalSolrQueryRequest req =
- new LocalSolrQueryRequest(null, Maps.newHashMap()) {
+ new LocalSolrQueryRequest(null, Map.of()) {
@Override
public List<CommandOperation> getCommands(boolean validateInput) {
if (v2RequestBody == null) return Collections.emptyList();
diff --git a/solr/core/src/test/org/apache/solr/handler/V2UpdateAPIMappingTest.java b/solr/core/src/test/org/apache/solr/handler/V2UpdateAPIMappingTest.java
index ae4b31c9d9d..f030525fb03 100644
--- a/solr/core/src/test/org/apache/solr/handler/V2UpdateAPIMappingTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/V2UpdateAPIMappingTest.java
@@ -20,7 +20,6 @@ package org.apache.solr.handler;
import static org.apache.solr.common.params.CommonParams.PATH;
import static org.mockito.Mockito.mock;
-import com.google.common.collect.Maps;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -91,7 +90,7 @@ public class V2UpdateAPIMappingTest extends SolrTestCaseJ4 {
final Api api = apiBag.lookup(path, "POST", parts);
final SolrQueryResponse rsp = new SolrQueryResponse();
final LocalSolrQueryRequest req =
- new LocalSolrQueryRequest(null, Maps.newHashMap()) {
+ new LocalSolrQueryRequest(null, Map.of()) {
@Override
public List<CommandOperation> getCommands(boolean validateInput) {
return Collections.emptyList();
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminOperationTest.java b/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminOperationTest.java
index 797dabd04a9..928e2e94862 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminOperationTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminOperationTest.java
@@ -19,7 +19,7 @@ package org.apache.solr.handler.admin;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import com.google.common.collect.Maps;
+import java.util.HashMap;
import java.util.Map;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException;
@@ -78,7 +78,7 @@ public class CoreAdminOperationTest extends SolrTestCaseJ4 {
@Test
public void testUnloadMissingCoreNameResultsIn400SolrException() {
- whenCoreAdminOpHasParams(Maps.newHashMap());
+ whenCoreAdminOpHasParams(new HashMap<>());
Exception ex =
expectThrows(Exception.class, () -> CoreAdminOperation.UNLOAD_OP.execute(callInfo));
@@ -97,7 +97,7 @@ public class CoreAdminOperationTest extends SolrTestCaseJ4 {
@Test
public void testReloadMissingCoreNameResultsIn400SolrException() {
- whenCoreAdminOpHasParams(Maps.newHashMap());
+ whenCoreAdminOpHasParams(new HashMap<>());
Exception ex =
expectThrows(Exception.class, () -> CoreAdminOperation.RELOAD_OP.execute(callInfo));
@@ -116,7 +116,7 @@ public class CoreAdminOperationTest extends SolrTestCaseJ4 {
@Test
public void testCreateMissingCoreNameResultsIn400SolrException() {
- whenCoreAdminOpHasParams(Maps.newHashMap());
+ whenCoreAdminOpHasParams(new HashMap<>());
Exception ex =
expectThrows(Exception.class, () -> CoreAdminOperation.CREATE_OP.execute(callInfo));
@@ -135,7 +135,7 @@ public class CoreAdminOperationTest extends SolrTestCaseJ4 {
@Test
public void testSwapMissingCoreParamResultsIn400SolrException() {
- final Map<String, String> params = Maps.newHashMap();
+ final Map<String, String> params = new HashMap<>();
params.put("other", "some-core-name");
whenCoreAdminOpHasParams(params);
@@ -146,7 +146,7 @@ public class CoreAdminOperationTest extends SolrTestCaseJ4 {
@Test
public void testSwapMissingOtherParamResultsIn400SolrException() {
- final Map<String, String> params = Maps.newHashMap();
+ final Map<String, String> params = new HashMap<>();
params.put("core", "some-core-name");
whenCoreAdminOpHasParams(params);
@@ -167,7 +167,7 @@ public class CoreAdminOperationTest extends SolrTestCaseJ4 {
@Test
public void testRenameMissingCoreParamResultsIn400SolrException() {
- final Map<String, String> params = Maps.newHashMap();
+ final Map<String, String> params = new HashMap<>();
params.put("other", "some-core-name");
whenCoreAdminOpHasParams(params);
@@ -178,7 +178,7 @@ public class CoreAdminOperationTest extends SolrTestCaseJ4 {
@Test
public void testRenameMissingOtherParamResultsIn400SolrException() {
- final Map<String, String> params = Maps.newHashMap();
+ final Map<String, String> params = new HashMap<>();
params.put("core", "some-core-name");
whenCoreAdminOpHasParams(params);
@@ -199,7 +199,7 @@ public class CoreAdminOperationTest extends SolrTestCaseJ4 {
@Test
public void testMergeMissingCoreParamResultsIn400SolrException() {
- final Map<String, String> params = Maps.newHashMap();
+ final Map<String, String> params = new HashMap<>();
params.put("indexDir", "some/index/dir");
whenCoreAdminOpHasParams(params);
@@ -220,7 +220,7 @@ public class CoreAdminOperationTest extends SolrTestCaseJ4 {
@Test
public void testSplitMissingCoreParamResultsIn400SolrException() {
- whenCoreAdminOpHasParams(Maps.newHashMap());
+ whenCoreAdminOpHasParams(new HashMap<>());
Exception ex =
expectThrows(Exception.class, () -> CoreAdminOperation.SPLIT_OP.execute(callInfo));
@@ -250,7 +250,7 @@ public class CoreAdminOperationTest extends SolrTestCaseJ4 {
@Test
public void testRequestRecoveryMissingCoreParamResultsIn400SolrException() {
- whenCoreAdminOpHasParams(Maps.newHashMap());
+ whenCoreAdminOpHasParams(new HashMap<>());
Exception ex =
expectThrows(
@@ -271,7 +271,7 @@ public class CoreAdminOperationTest extends SolrTestCaseJ4 {
@Test
public void testRequestSyncMissingCoreParamResultsIn400SolrException() {
- whenCoreAdminOpHasParams(Maps.newHashMap());
+ whenCoreAdminOpHasParams(new HashMap<>());
Exception ex =
expectThrows(
@@ -292,7 +292,7 @@ public class CoreAdminOperationTest extends SolrTestCaseJ4 {
@Test
public void testRequestBufferUpdatesMissingCoreParamResultsIn400SolrException() {
- whenCoreAdminOpHasParams(Maps.newHashMap());
+ whenCoreAdminOpHasParams(new HashMap<>());
Exception ex =
expectThrows(
@@ -313,7 +313,7 @@ public class CoreAdminOperationTest extends SolrTestCaseJ4 {
@Test
public void testRequestApplyUpdatesMissingCoreParamResultsIn400SolrException() {
- whenCoreAdminOpHasParams(Maps.newHashMap());
+ whenCoreAdminOpHasParams(new HashMap<>());
Exception ex =
expectThrows(
@@ -343,7 +343,7 @@ public class CoreAdminOperationTest extends SolrTestCaseJ4 {
@Test
public void testRequestStatusMissingRequestIdParamResultsIn400SolrException() {
- whenCoreAdminOpHasParams(Maps.newHashMap());
+ whenCoreAdminOpHasParams(new HashMap<>());
Exception ex =
expectThrows(Exception.class, () -> CoreAdminOperation.REQUESTSTATUS_OP.execute(callInfo));
@@ -373,7 +373,7 @@ public class CoreAdminOperationTest extends SolrTestCaseJ4 {
@Test
public void testBackupMissingCoreParamResultsIn400SolrException() {
- final Map<String, String> params = Maps.newHashMap();
+ final Map<String, String> params = new HashMap<>();
params.put("name", "any-name-param");
whenCoreAdminOpHasParams(params);
@@ -384,7 +384,7 @@ public class CoreAdminOperationTest extends SolrTestCaseJ4 {
@Test
public void testBackupMissingNameParamResultsIn400SolrException() {
- final Map<String, String> params = Maps.newHashMap();
+ final Map<String, String> params = new HashMap<>();
params.put("core", "any-core-param");
whenCoreAdminOpHasParams(params);
@@ -405,7 +405,7 @@ public class CoreAdminOperationTest extends SolrTestCaseJ4 {
@Test
public void testRestoreMissingCoreParamResultsIn400SolrException() {
- final Map<String, String> params = Maps.newHashMap();
+ final Map<String, String> params = new HashMap<>();
params.put("name", "any-name-param");
whenCoreAdminOpHasParams(params);
@@ -416,7 +416,7 @@ public class CoreAdminOperationTest extends SolrTestCaseJ4 {
@Test
public void testRestoreMissingNameParamResultsIn400SolrException() {
- final Map<String, String> params = Maps.newHashMap();
+ final Map<String, String> params = new HashMap<>();
params.put("core", "any-core-param");
whenCoreAdminOpHasParams(params);
@@ -437,7 +437,7 @@ public class CoreAdminOperationTest extends SolrTestCaseJ4 {
@Test
public void testCreateSnapshotMissingCoreParamResultsIn400SolrException() {
- final Map<String, String> params = Maps.newHashMap();
+ final Map<String, String> params = new HashMap<>();
params.put("commitName", "anyCommitName");
whenCoreAdminOpHasParams(params);
@@ -448,7 +448,7 @@ public class CoreAdminOperationTest extends SolrTestCaseJ4 {
@Test
public void testCreateSnapshotMissingCommitNameParamResultsIn400SolrException() {
- final Map<String, String> params = Maps.newHashMap();
+ final Map<String, String> params = new HashMap<>();
params.put("core", "any-core-param");
whenCoreAdminOpHasParams(params);
@@ -469,7 +469,7 @@ public class CoreAdminOperationTest extends SolrTestCaseJ4 {
@Test
public void testDeleteSnapshotMissingCoreParamResultsIn400SolrException() {
- final Map<String, String> params = Maps.newHashMap();
+ final Map<String, String> params = new HashMap<>();
params.put("commitName", "anyCommitName");
whenCoreAdminOpHasParams(params);
@@ -480,7 +480,7 @@ public class CoreAdminOperationTest extends SolrTestCaseJ4 {
@Test
public void testDeleteSnapshotMissingCommitNameParamResultsIn400SolrException() {
- final Map<String, String> params = Maps.newHashMap();
+ final Map<String, String> params = new HashMap<>();
params.put("core", "any-core-param");
whenCoreAdminOpHasParams(params);
@@ -501,7 +501,7 @@ public class CoreAdminOperationTest extends SolrTestCaseJ4 {
@Test
public void testListSnapshotMissingCoreParamResultsIn400SolrException() {
- whenCoreAdminOpHasParams(Maps.newHashMap());
+ whenCoreAdminOpHasParams(new HashMap<>());
Exception ex =
expectThrows(Exception.class, () -> CoreAdminOperation.LISTSNAPSHOTS_OP.execute(callInfo));
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/V2ApiMappingTest.java b/solr/core/src/test/org/apache/solr/handler/admin/V2ApiMappingTest.java
index 78ac3dbd342..bb36cf353d8 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/V2ApiMappingTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/V2ApiMappingTest.java
@@ -21,7 +21,6 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
-import com.google.common.collect.Maps;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -113,7 +112,7 @@ public abstract class V2ApiMappingTest<T extends RequestHandlerBase> extends Sol
final Api api = apiBag.lookup(v2Path, v2Method, parts);
final SolrQueryResponse rsp = new SolrQueryResponse();
final LocalSolrQueryRequest req =
- new LocalSolrQueryRequest(null, Maps.newHashMap()) {
+ new LocalSolrQueryRequest(null, Map.of()) {
@Override
public List<CommandOperation> getCommands(boolean validateInput) {
if (v2RequestBody == null) return Collections.emptyList();
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/api/V2NodeAPIMappingTest.java b/solr/core/src/test/org/apache/solr/handler/admin/api/V2NodeAPIMappingTest.java
index 23e2702e3af..6e1181a5709 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/api/V2NodeAPIMappingTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/api/V2NodeAPIMappingTest.java
@@ -23,7 +23,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import com.google.common.collect.Maps;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -230,7 +229,7 @@ public class V2NodeAPIMappingTest extends SolrTestCaseJ4 {
RequestHandlerBase mockHandler)
throws Exception {
final HashMap<String, String> parts = new HashMap<>();
- final Map<String, String[]> inputParamsMap = Maps.newHashMap();
+ final Map<String, String[]> inputParamsMap = new HashMap<>();
inputParams.stream()
.forEach(
e -> {
diff --git a/solr/core/src/test/org/apache/solr/handler/designer/TestSchemaDesignerAPI.java b/solr/core/src/test/org/apache/solr/handler/designer/TestSchemaDesignerAPI.java
index b615bb2b907..57d5a6b47a8 100644
--- a/solr/core/src/test/org/apache/solr/handler/designer/TestSchemaDesignerAPI.java
+++ b/solr/core/src/test/org/apache/solr/handler/designer/TestSchemaDesignerAPI.java
@@ -24,7 +24,6 @@ import static org.apache.solr.response.RawResponseWriter.CONTENT;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import com.google.common.collect.ImmutableMap;
import java.io.File;
import java.util.Arrays;
import java.util.Collection;
@@ -892,9 +891,9 @@ public class TestSchemaDesignerAPI extends SolrCloudTestCase implements SchemaDe
Map<String, Object> mapDiff = (Map<String, Object>) fieldsDiff.get("updated");
assertEquals(
Arrays.asList(
- ImmutableMap.of(
+ Map.of(
"omitTermFreqAndPositions", true, "useDocValuesAsStored", true, "docValues", true),
- ImmutableMap.of(
+ Map.of(
"omitTermFreqAndPositions",
false,
"useDocValuesAsStored",
diff --git a/solr/core/src/test/org/apache/solr/response/transform/TestChildDocTransformerHierarchy.java b/solr/core/src/test/org/apache/solr/response/transform/TestChildDocTransformerHierarchy.java
index 18aef3a7c93..9f99dd7aba7 100644
--- a/solr/core/src/test/org/apache/solr/response/transform/TestChildDocTransformerHierarchy.java
+++ b/solr/core/src/test/org/apache/solr/response/transform/TestChildDocTransformerHierarchy.java
@@ -16,12 +16,13 @@
*/
package org.apache.solr.response.transform;
-import com.google.common.collect.Iterables;
import java.util.Collection;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
+import java.util.stream.Stream;
import org.apache.lucene.index.IndexableField;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrDocument;
@@ -38,7 +39,8 @@ public class TestChildDocTransformerHierarchy extends SolrTestCaseJ4 {
private static AtomicInteger idCounter = new AtomicInteger();
private static final String[] types = {"donut", "cake"};
private static final String[] ingredients = {"flour", "cocoa", "vanilla"};
- private static final Iterator<String> ingredientsCycler = Iterables.cycle(ingredients).iterator();
+ private static final Iterator<String> ingredientsCycler =
+ Stream.generate(() -> List.of(ingredients)).flatMap(Collection::stream).iterator();
private static final String[] names = {"Yaz", "Jazz", "Costa"};
private static final String[] fieldsToRemove = {"_nest_parent_", "_nest_path_", "_root_"};
private static final int sumOfDocsPerNestedDocument = 8;
diff --git a/solr/core/src/test/org/apache/solr/response/transform/TestSubQueryTransformerCrossCore.java b/solr/core/src/test/org/apache/solr/response/transform/TestSubQueryTransformerCrossCore.java
index 674a9b9a396..b8fffc2b445 100644
--- a/solr/core/src/test/org/apache/solr/response/transform/TestSubQueryTransformerCrossCore.java
+++ b/solr/core/src/test/org/apache/solr/response/transform/TestSubQueryTransformerCrossCore.java
@@ -16,7 +16,7 @@
*/
package org.apache.solr.response.transform;
-import com.google.common.collect.ImmutableMap;
+import java.util.Map;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException;
import org.apache.solr.core.CoreContainer;
@@ -41,7 +41,7 @@ public class TestSubQueryTransformerCrossCore extends SolrTestCaseJ4 {
coreContainer.create(
"fromCore", // FileSystems.getDefault().getPath( TEST_HOME()),
// ImmutableMap.of("config","solrconfig-basic.xml","schema","schema-docValuesJoin.xml"
- ImmutableMap.of("configSet", "minimal"));
+ Map.of("configSet", "minimal"));
assertU(
add(
doc(
diff --git a/solr/core/src/test/org/apache/solr/schema/TestPointFields.java b/solr/core/src/test/org/apache/solr/schema/TestPointFields.java
index 5a4351b04ba..0fe2cdc8a87 100644
--- a/solr/core/src/test/org/apache/solr/schema/TestPointFields.java
+++ b/solr/core/src/test/org/apache/solr/schema/TestPointFields.java
@@ -16,7 +16,6 @@
*/
package org.apache.solr.schema;
-import com.google.common.collect.ImmutableMap;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -1322,13 +1321,13 @@ public class TestPointFields extends SolrTestCaseJ4 {
assertU(adoc(sdoc("id", "1", field, String.valueOf(number1))));
assertU(commit());
- assertU(adoc(sdoc("id", "1", field, ImmutableMap.of("inc", (float) inc1))));
+ assertU(adoc(sdoc("id", "1", field, Map.of("inc", (float) inc1))));
assertU(commit());
assertQ(req("q", "id:1"), "//result/doc[1]/float[@name='" + field + "'][.='" + number2 + "']");
float number3 = getRandomFloats(1, false).get(0);
- assertU(adoc(sdoc("id", "1", field, ImmutableMap.of("set", number3))));
+ assertU(adoc(sdoc("id", "1", field, Map.of("set", number3))));
assertU(commit());
assertQ(req("q", "id:1"), "//result/doc[1]/float[@name='" + field + "'][.='" + number3 + "']");
@@ -1349,13 +1348,13 @@ public class TestPointFields extends SolrTestCaseJ4 {
assertU(adoc(sdoc("id", "1", field, String.valueOf(number1))));
assertU(commit());
- assertU(adoc(sdoc("id", "1", field, ImmutableMap.of("inc", inc1.doubleValue()))));
+ assertU(adoc(sdoc("id", "1", field, Map.of("inc", inc1.doubleValue()))));
assertU(commit());
assertQ(req("q", "id:1"), "//result/doc[1]/double[@name='" + field + "'][.='" + number2 + "']");
double number3 = getRandomDoubles(1, false).get(0);
- assertU(adoc(sdoc("id", "1", field, ImmutableMap.of("set", number3))));
+ assertU(adoc(sdoc("id", "1", field, Map.of("set", number3))));
assertU(commit());
assertQ(req("q", "id:1"), "//result/doc[1]/double[@name='" + field + "'][.='" + number3 + "']");
@@ -4663,7 +4662,7 @@ public class TestPointFields extends SolrTestCaseJ4 {
"//result/doc[1]/arr[@name='" + field + "']/" + type + "[.='" + values[0] + "']",
"count(//result/doc[1]/arr[@name='" + field + "']/" + type + ")=1");
- assertU(adoc(sdoc("id", "1", field, ImmutableMap.of("add", values[1]))));
+ assertU(adoc(sdoc("id", "1", field, Map.of("add", values[1]))));
assertU(commit());
assertQ(
@@ -4672,7 +4671,7 @@ public class TestPointFields extends SolrTestCaseJ4 {
"//result/doc[1]/arr[@name='" + field + "']/" + type + "[.='" + values[1] + "']",
"count(//result/doc[1]/arr[@name='" + field + "']/" + type + ")=2");
- assertU(adoc(sdoc("id", "1", field, ImmutableMap.of("remove", values[0]))));
+ assertU(adoc(sdoc("id", "1", field, Map.of("remove", values[0]))));
assertU(commit());
assertQ(
@@ -4680,7 +4679,7 @@ public class TestPointFields extends SolrTestCaseJ4 {
"//result/doc[1]/arr[@name='" + field + "']/" + type + "[.='" + values[1] + "']",
"count(//result/doc[1]/arr[@name='" + field + "']/" + type + ")=1");
- assertU(adoc(sdoc("id", "1", field, ImmutableMap.of("set", Arrays.asList(values)))));
+ assertU(adoc(sdoc("id", "1", field, Map.of("set", Arrays.asList(values)))));
assertU(commit());
assertQ(
@@ -4690,7 +4689,7 @@ public class TestPointFields extends SolrTestCaseJ4 {
"//result/doc[1]/arr[@name='" + field + "']/" + type + "[.='" + values[2] + "']",
"count(//result/doc[1]/arr[@name='" + field + "']/" + type + ")=3");
- assertU(adoc(sdoc("id", "1", field, ImmutableMap.of("removeregex", ".*"))));
+ assertU(adoc(sdoc("id", "1", field, Map.of("removeregex", ".*"))));
assertU(commit());
assertQ(req("q", "id:1"), "count(//result/doc[1]/arr[@name='" + field + "']/" + type + ")=0");
@@ -4710,13 +4709,13 @@ public class TestPointFields extends SolrTestCaseJ4 {
assertU(adoc(sdoc("id", "1", field, String.valueOf(number1))));
assertU(commit());
- assertU(adoc(sdoc("id", "1", field, ImmutableMap.of("inc", (int) inc1))));
+ assertU(adoc(sdoc("id", "1", field, Map.of("inc", (int) inc1))));
assertU(commit());
assertQ(req("q", "id:1"), "//result/doc[1]/int[@name='" + field + "'][.='" + number2 + "']");
int number3 = random().nextInt();
- assertU(adoc(sdoc("id", "1", field, ImmutableMap.of("set", number3))));
+ assertU(adoc(sdoc("id", "1", field, Map.of("set", number3))));
assertU(commit());
assertQ(req("q", "id:1"), "//result/doc[1]/int[@name='" + field + "'][.='" + number3 + "']");
@@ -4736,13 +4735,13 @@ public class TestPointFields extends SolrTestCaseJ4 {
assertU(adoc(sdoc("id", "1", field, String.valueOf(number1))));
assertU(commit());
- assertU(adoc(sdoc("id", "1", field, ImmutableMap.of("inc", inc1.longValueExact()))));
+ assertU(adoc(sdoc("id", "1", field, Map.of("inc", inc1.longValueExact()))));
assertU(commit());
assertQ(req("q", "id:1"), "//result/doc[1]/long[@name='" + field + "'][.='" + number2 + "']");
long number3 = random().nextLong();
- assertU(adoc(sdoc("id", "1", field, ImmutableMap.of("set", number3))));
+ assertU(adoc(sdoc("id", "1", field, Map.of("set", number3))));
assertU(commit());
assertQ(req("q", "id:1"), "//result/doc[1]/long[@name='" + field + "'][.='" + number3 + "']");
@@ -5716,7 +5715,7 @@ public class TestPointFields extends SolrTestCaseJ4 {
assertQ(req("q", "id:1"), "//result/doc[1]/date[@name='" + field + "'][.='" + date1 + "']");
- assertU(adoc(sdoc("id", "1", field, ImmutableMap.of("set", date1 + gap))));
+ assertU(adoc(sdoc("id", "1", field, Map.of("set", date1 + gap))));
assertU(commit());
assertQ(req("q", "id:1"), "//result/doc[1]/date[@name='" + field + "'][.='" + date2 + "']");
diff --git a/solr/core/src/test/org/apache/solr/search/TestIndexSearcher.java b/solr/core/src/test/org/apache/solr/search/TestIndexSearcher.java
index e59cb2a109e..25975ce80e8 100644
--- a/solr/core/src/test/org/apache/solr/search/TestIndexSearcher.java
+++ b/solr/core/src/test/org/apache/solr/search/TestIndexSearcher.java
@@ -18,7 +18,6 @@ package org.apache.solr.search;
import com.codahale.metrics.Gauge;
import com.codahale.metrics.Metric;
-import com.google.common.collect.ImmutableMap;
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.Date;
@@ -243,7 +242,7 @@ public class TestIndexSearcher extends SolrTestCaseJ4 {
cores.create(
"core1",
cd.getInstanceDir(),
- ImmutableMap.of("config", "solrconfig-searcher-listeners1.xml"),
+ Map.of("config", "solrconfig-searcher-listeners1.xml"),
false);
// validate that the new core was created with the correct solrconfig
@@ -303,7 +302,7 @@ public class TestIndexSearcher extends SolrTestCaseJ4 {
cores.create(
"core1",
cd.getInstanceDir(),
- ImmutableMap.of("config", "solrconfig-searcher-listeners1.xml"),
+ Map.of("config", "solrconfig-searcher-listeners1.xml"),
false);
coreCreated = true;
@@ -376,7 +375,7 @@ public class TestIndexSearcher extends SolrTestCaseJ4 {
cores.create(
"core1",
cd.getInstanceDir(),
- ImmutableMap.of("config", "solrconfig-searcher-listeners1.xml"),
+ Map.of("config", "solrconfig-searcher-listeners1.xml"),
false);
coreCreated = true;
diff --git a/solr/core/src/test/org/apache/solr/update/SolrIndexSplitterTest.java b/solr/core/src/test/org/apache/solr/update/SolrIndexSplitterTest.java
index c538b89a52f..2796233ea0b 100644
--- a/solr/core/src/test/org/apache/solr/update/SolrIndexSplitterTest.java
+++ b/solr/core/src/test/org/apache/solr/update/SolrIndexSplitterTest.java
@@ -16,12 +16,11 @@
*/
package org.apache.solr.update;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
import java.io.File;
import java.lang.invoke.MethodHandles;
import java.nio.charset.StandardCharsets;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.Term;
@@ -102,7 +101,7 @@ public class SolrIndexSplitterTest extends SolrTestCaseJ4 {
new SplitIndexCommand(
request,
rsp,
- Lists.newArrayList(indexDir1.getAbsolutePath(), indexDir2.getAbsolutePath()),
+ List.of(indexDir1.getAbsolutePath(), indexDir2.getAbsolutePath()),
null,
ranges,
new PlainIdRouter(),
@@ -192,7 +191,7 @@ public class SolrIndexSplitterTest extends SolrTestCaseJ4 {
new SplitIndexCommand(
request,
rsp,
- Lists.newArrayList(indexDir1.getAbsolutePath(), indexDir2.getAbsolutePath()),
+ List.of(indexDir1.getAbsolutePath(), indexDir2.getAbsolutePath()),
null,
ranges,
new PlainIdRouter(),
@@ -268,14 +267,12 @@ public class SolrIndexSplitterTest extends SolrTestCaseJ4 {
h.getCoreContainer()
.create(
"split1",
- ImmutableMap.of(
- "dataDir", indexDir1.getAbsolutePath(), "configSet", "cloud-minimal"));
+ Map.of("dataDir", indexDir1.getAbsolutePath(), "configSet", "cloud-minimal"));
core2 =
h.getCoreContainer()
.create(
"split2",
- ImmutableMap.of(
- "dataDir", indexDir2.getAbsolutePath(), "configSet", "cloud-minimal"));
+ Map.of("dataDir", indexDir2.getAbsolutePath(), "configSet", "cloud-minimal"));
LocalSolrQueryRequest request = null;
try {
@@ -286,7 +283,7 @@ public class SolrIndexSplitterTest extends SolrTestCaseJ4 {
request,
rsp,
null,
- Lists.newArrayList(core1, core2),
+ List.of(core1, core2),
ranges,
new PlainIdRouter(),
null,
@@ -352,7 +349,7 @@ public class SolrIndexSplitterTest extends SolrTestCaseJ4 {
new SplitIndexCommand(
request,
rsp,
- Lists.newArrayList(
+ List.of(
indexDir1.getAbsolutePath(),
indexDir2.getAbsolutePath(),
indexDir3.getAbsolutePath()),
@@ -458,9 +455,9 @@ public class SolrIndexSplitterTest extends SolrTestCaseJ4 {
new SplitIndexCommand(
request,
rsp,
- Lists.newArrayList(indexDir.getAbsolutePath()),
+ List.of(indexDir.getAbsolutePath()),
null,
- Lists.newArrayList(splitKeyRange),
+ List.of(splitKeyRange),
new CompositeIdRouter(),
null,
splitKey,
diff --git a/solr/core/src/test/org/apache/solr/update/processor/AbstractAtomicUpdatesMultivalueTestBase.java b/solr/core/src/test/org/apache/solr/update/processor/AbstractAtomicUpdatesMultivalueTestBase.java
index 72370e04d23..d0ce6058dbe 100644
--- a/solr/core/src/test/org/apache/solr/update/processor/AbstractAtomicUpdatesMultivalueTestBase.java
+++ b/solr/core/src/test/org/apache/solr/update/processor/AbstractAtomicUpdatesMultivalueTestBase.java
@@ -20,7 +20,6 @@ import static org.apache.solr.SolrTestCaseJ4.sdoc;
import static org.hamcrest.CoreMatchers.hasItems;
import static org.hamcrest.CoreMatchers.not;
-import com.google.common.collect.ImmutableMap;
import java.io.IOException;
import java.nio.file.Paths;
import java.time.ZonedDateTime;
@@ -28,6 +27,7 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.List;
+import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.function.Function;
@@ -104,8 +104,7 @@ public abstract class AbstractAtomicUpdatesMultivalueTestBase extends EmbeddedSo
fieldValues, hasItems(vc.apply(values[1]), vc.apply(values[2]), vc.apply(values[3])));
MatcherAssert.assertThat(fieldValues, not(hasItems(vc.apply(values[0]))));
- getSolrClient()
- .add(sdoc("id", "20000", fieldName, ImmutableMap.of("remove", List.of(values[0]))));
+ getSolrClient().add(sdoc("id", "20000", fieldName, Map.of("remove", List.of(values[0]))));
getSolrClient().commit(true, true);
if (queries != null) {
@@ -131,7 +130,7 @@ public abstract class AbstractAtomicUpdatesMultivalueTestBase extends EmbeddedSo
"id",
"20001",
fieldName,
- ImmutableMap.of("remove", List.of(values[0], values[1], values[2]))));
+ Map.of("remove", List.of(values[0], values[1], values[2]))));
getSolrClient().commit(true, true);
if (queries != null) {
@@ -158,13 +157,12 @@ public abstract class AbstractAtomicUpdatesMultivalueTestBase extends EmbeddedSo
"id",
"20000",
fieldName,
- ImmutableMap.of(
- "add", List.of(values[0]), "remove", List.of(values[1], values[2]))),
+ Map.of("add", List.of(values[0]), "remove", List.of(values[1], values[2]))),
sdoc(
"id",
"20001",
fieldName,
- ImmutableMap.of("add", List.of(values[0]), "remove", List.of(values[3])))));
+ Map.of("add", List.of(values[0]), "remove", List.of(values[3])))));
getSolrClient().commit(true, true);
if (queries != null) {
@@ -192,12 +190,12 @@ public abstract class AbstractAtomicUpdatesMultivalueTestBase extends EmbeddedSo
"id",
"20000",
fieldName,
- ImmutableMap.of("set", List.of(values[0], values[1], values[2], values[3]))),
+ Map.of("set", List.of(values[0], values[1], values[2], values[3]))),
sdoc(
"id",
"20001",
fieldName,
- ImmutableMap.of("set", List.of(values[0], values[1], values[2], values[3])))));
+ Map.of("set", List.of(values[0], values[1], values[2], values[3])))));
getSolrClient().commit(true, true);
if (queries != null) {
@@ -282,7 +280,7 @@ public abstract class AbstractAtomicUpdatesMultivalueTestBase extends EmbeddedSo
assertEquals(2, fieldValues.size());
MatcherAssert.assertThat(fieldValues, hasItems(true, false));
- getSolrClient().add(sdoc("id", "20000", fieldName, ImmutableMap.of("remove", List.of(false))));
+ getSolrClient().add(sdoc("id", "20000", fieldName, Map.of("remove", List.of(false))));
getSolrClient().commit(true, true);
assertQR(fieldName, "true", 2);
@@ -295,8 +293,7 @@ public abstract class AbstractAtomicUpdatesMultivalueTestBase extends EmbeddedSo
assertEquals(2, fieldValues.size());
MatcherAssert.assertThat(fieldValues, hasItems(true, false));
- getSolrClient()
- .add(sdoc("id", "20001", fieldName, ImmutableMap.of("remove", List.of(true, false))));
+ getSolrClient().add(sdoc("id", "20001", fieldName, Map.of("remove", List.of(true, false))));
getSolrClient().commit(true, true);
assertQR(fieldName, "true", 1);
@@ -310,9 +307,7 @@ public abstract class AbstractAtomicUpdatesMultivalueTestBase extends EmbeddedSo
assertNull(fieldValues);
getSolrClient()
- .add(
- Arrays.asList(
- sdoc("id", "20000", fieldName, ImmutableMap.of("add", List.of(false, false)))));
+ .add(Arrays.asList(sdoc("id", "20000", fieldName, Map.of("add", List.of(false, false)))));
getSolrClient().commit(true, true);
assertQR(fieldName, "true", 1);
@@ -327,8 +322,8 @@ public abstract class AbstractAtomicUpdatesMultivalueTestBase extends EmbeddedSo
getSolrClient()
.add(
Arrays.asList(
- sdoc("id", "20000", fieldName, ImmutableMap.of("set", List.of(true, false))),
- sdoc("id", "20001", fieldName, ImmutableMap.of("set", List.of(false, true)))));
+ sdoc("id", "20000", fieldName, Map.of("set", List.of(true, false))),
+ sdoc("id", "20001", fieldName, Map.of("set", List.of(false, true)))));
getSolrClient().commit(true, true);
assertQR(fieldName, "true", 2);
diff --git a/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdatesTest.java b/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdatesTest.java
index 19f7cf82b83..ef81af271a9 100644
--- a/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdatesTest.java
+++ b/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdatesTest.java
@@ -18,11 +18,11 @@ package org.apache.solr.update.processor;
import static org.hamcrest.core.StringContains.containsString;
-import com.google.common.collect.ImmutableMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
+import java.util.Map;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrInputDocument;
@@ -82,8 +82,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
List<String> removeList = new ArrayList<>();
removeList.add("bbb");
removeList.add("ccc");
- doc.setField(
- "cat", ImmutableMap.of("remove", removeList)); // behavior when hitting Solr through ZK
+ doc.setField("cat", Map.of("remove", removeList)); // behavior when hitting Solr through ZK
assertU(adoc(doc));
assertU(commit());
@@ -98,8 +97,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
removeList = new ArrayList<>();
removeList.add("bbb");
removeList.add("ccc");
- doc.setField(
- "cat", ImmutableMap.of("remove", removeList)); // behavior when hitting Solr through ZK
+ doc.setField("cat", Map.of("remove", removeList)); // behavior when hitting Solr through ZK
assertU(adoc(doc));
assertU(commit());
@@ -108,7 +106,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
doc = new SolrInputDocument();
doc.setField("id", "1");
- doc.setField("cat", ImmutableMap.of("remove", "aaa")); // behavior when hitting Solr directly
+ doc.setField("cat", Map.of("remove", "aaa")); // behavior when hitting Solr directly
assertU(adoc(doc));
assertU(commit());
@@ -154,8 +152,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
removeList.add(222L);
removeList.add(333L);
doc.setField(
- "intRemove",
- ImmutableMap.of("remove", removeList)); // behavior when hitting Solr through ZK
+ "intRemove", Map.of("remove", removeList)); // behavior when hitting Solr through ZK
assertU(adoc(doc));
assertU(commit());
@@ -171,8 +168,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
removeList.add(222L);
removeList.add(333L);
doc.setField(
- "intRemove",
- ImmutableMap.of("remove", removeList)); // behavior when hitting Solr through ZK
+ "intRemove", Map.of("remove", removeList)); // behavior when hitting Solr through ZK
assertU(adoc(doc));
assertU(commit());
@@ -181,8 +177,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
doc = new SolrInputDocument();
doc.setField("id", "1001");
- doc.setField(
- "intRemove", ImmutableMap.of("remove", 111)); // behavior when hitting Solr directly
+ doc.setField("intRemove", Map.of("remove", 111)); // behavior when hitting Solr directly
assertU(adoc(doc));
assertU(commit());
@@ -199,7 +194,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
doc = new SolrInputDocument();
doc.setField("id", "4242");
- doc.setField("values_is", ImmutableMap.of("remove", 111));
+ doc.setField("values_is", Map.of("remove", 111));
assertU(adoc(doc));
assertU(commit());
@@ -245,8 +240,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
removeList.add(222L);
removeList.add(333L);
doc.setField(
- "intRemove",
- ImmutableMap.of("remove", removeList)); // behavior when hitting Solr through ZK
+ "intRemove", Map.of("remove", removeList)); // behavior when hitting Solr through ZK
assertU(adoc(doc));
assertU(commit());
@@ -262,8 +256,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
removeList.add(222L);
removeList.add(333L);
doc.setField(
- "intRemove",
- ImmutableMap.of("remove", removeList)); // behavior when hitting Solr through ZK
+ "intRemove", Map.of("remove", removeList)); // behavior when hitting Solr through ZK
assertU(adoc(doc));
assertU(commit());
@@ -272,8 +265,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
doc = new SolrInputDocument();
doc.setField("id", "1001");
- doc.setField(
- "intRemove", ImmutableMap.of("remove", 111)); // behavior when hitting Solr directly
+ doc.setField("intRemove", Map.of("remove", 111)); // behavior when hitting Solr directly
assertU(adoc(doc));
assertU(commit());
@@ -290,7 +282,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
doc = new SolrInputDocument();
doc.setField("id", "4242");
- doc.setField("values_is", ImmutableMap.of("remove", 111));
+ doc.setField("values_is", Map.of("remove", 111));
assertU(adoc(doc));
assertU(commit());
@@ -334,8 +326,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
removeList.add("222");
removeList.add("333");
doc.setField(
- "intRemove",
- ImmutableMap.of("remove", removeList)); // behavior when hitting Solr through ZK
+ "intRemove", Map.of("remove", removeList)); // behavior when hitting Solr through ZK
assertU(adoc(doc));
assertU(commit());
@@ -351,8 +342,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
removeList.add("222");
removeList.add("333");
doc.setField(
- "intRemove",
- ImmutableMap.of("remove", removeList)); // behavior when hitting Solr through ZK
+ "intRemove", Map.of("remove", removeList)); // behavior when hitting Solr through ZK
assertU(adoc(doc));
assertU(commit());
@@ -361,8 +351,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
doc = new SolrInputDocument();
doc.setField("id", "1001");
- doc.setField(
- "intRemove", ImmutableMap.of("remove", "111")); // behavior when hitting Solr directly
+ doc.setField("intRemove", Map.of("remove", "111")); // behavior when hitting Solr directly
assertU(adoc(doc));
assertU(commit());
@@ -407,8 +396,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
removeList.add(222L);
removeList.add(333L);
doc.setField(
- "intRemove",
- ImmutableMap.of("remove", removeList)); // behavior when hitting Solr through ZK
+ "intRemove", Map.of("remove", removeList)); // behavior when hitting Solr through ZK
assertU(adoc(doc));
assertU(commit());
@@ -424,8 +412,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
removeList.add(222L);
removeList.add(333L);
doc.setField(
- "intRemove",
- ImmutableMap.of("remove", removeList)); // behavior when hitting Solr through ZK
+ "intRemove", Map.of("remove", removeList)); // behavior when hitting Solr through ZK
assertU(adoc(doc));
assertU(commit());
@@ -434,8 +421,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
doc = new SolrInputDocument();
doc.setField("id", "1001");
- doc.setField(
- "intRemove", ImmutableMap.of("remove", 111L)); // behavior when hitting Solr directly
+ doc.setField("intRemove", Map.of("remove", 111L)); // behavior when hitting Solr directly
assertU(adoc(doc));
assertU(commit());
@@ -499,8 +485,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
removeList.add(222.20F);
removeList.add(333.30F);
doc.setField(
- "intRemove",
- ImmutableMap.of("remove", removeList)); // behavior when hitting Solr through ZK
+ "intRemove", Map.of("remove", removeList)); // behavior when hitting Solr through ZK
assertU(adoc(doc));
assertU(commit());
@@ -516,8 +501,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
removeList.add(222.20F);
removeList.add(333.30F);
doc.setField(
- "intRemove",
- ImmutableMap.of("remove", removeList)); // behavior when hitting Solr through ZK
+ "intRemove", Map.of("remove", removeList)); // behavior when hitting Solr through ZK
assertU(adoc(doc));
assertU(commit());
@@ -526,8 +510,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
doc = new SolrInputDocument();
doc.setField("id", "1001");
- doc.setField(
- "intRemove", ImmutableMap.of("remove", 111L)); // behavior when hitting Solr directly
+ doc.setField("intRemove", Map.of("remove", 111L)); // behavior when hitting Solr directly
assertU(adoc(doc));
assertU(commit());
@@ -574,8 +557,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
removeList.add(22222222D);
removeList.add(33333333D);
doc.setField(
- "intRemove",
- ImmutableMap.of("remove", removeList)); // behavior when hitting Solr through ZK
+ "intRemove", Map.of("remove", removeList)); // behavior when hitting Solr through ZK
assertU(adoc(doc));
assertU(commit());
@@ -591,8 +573,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
removeList.add(22222222D);
removeList.add(33333333D);
doc.setField(
- "intRemove",
- ImmutableMap.of("remove", removeList)); // behavior when hitting Solr through ZK
+ "intRemove", Map.of("remove", removeList)); // behavior when hitting Solr through ZK
assertU(adoc(doc));
assertU(commit());
@@ -601,8 +582,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
doc = new SolrInputDocument();
doc.setField("id", "1001");
- doc.setField(
- "intRemove", ImmutableMap.of("remove", 11111111D)); // behavior when hitting Solr directly
+ doc.setField("intRemove", Map.of("remove", 11111111D)); // behavior when hitting Solr directly
assertU(adoc(doc));
assertU(commit());
@@ -678,8 +658,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
removeList.add("2014-09-03T12:00:00Z");
doc.setField(
- "dateRemove",
- ImmutableMap.of("remove", removeList)); // behavior when hitting Solr through ZK
+ "dateRemove", Map.of("remove", removeList)); // behavior when hitting Solr through ZK
assertU(adoc(doc));
assertU(commit());
@@ -698,8 +677,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
removeList.add("2014-09-02T12:00:00Z");
removeList.add("2014-09-03T12:00:00Z");
doc.setField(
- "dateRemove",
- ImmutableMap.of("remove", removeList)); // behavior when hitting Solr through ZK
+ "dateRemove", Map.of("remove", removeList)); // behavior when hitting Solr through ZK
assertU(adoc(doc));
assertU(commit());
@@ -716,7 +694,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
doc.setField("id", "10001");
doc.setField(
"dateRemove",
- ImmutableMap.of("remove", "2014-09-01T12:00:00Z")); // behavior when hitting Solr directly
+ Map.of("remove", "2014-09-01T12:00:00Z")); // behavior when hitting Solr directly
assertU(adoc(doc));
assertU(commit());
@@ -806,8 +784,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
removeList.add(DateMathParser.parseMath(null, "2014-09-03T12:00:00Z"));
doc.setField(
- "dateRemove",
- ImmutableMap.of("remove", removeList)); // behavior when hitting Solr through ZK
+ "dateRemove", Map.of("remove", removeList)); // behavior when hitting Solr through ZK
assertU(adoc(doc));
assertU(commit());
@@ -825,8 +802,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
removeList.add(DateMathParser.parseMath(null, "2014-09-02T12:00:00Z"));
removeList.add(DateMathParser.parseMath(null, "2014-09-03T12:00:00Z"));
doc.setField(
- "dateRemove",
- ImmutableMap.of("remove", removeList)); // behavior when hitting Solr through ZK
+ "dateRemove", Map.of("remove", removeList)); // behavior when hitting Solr through ZK
assertU(adoc(doc));
assertU(commit());
@@ -839,7 +815,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
doc.setField("id", "10001");
doc.setField(
"dateRemove",
- ImmutableMap.of(
+ Map.of(
"remove",
DateMathParser.parseMath(
null, "2014-09-01T12:00:00Z"))); // behavior when hitting Solr directly
@@ -890,8 +866,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
removeList.add(333.333F);
doc.setField(
- "floatRemove",
- ImmutableMap.of("remove", removeList)); // behavior when hitting Solr through ZK
+ "floatRemove", Map.of("remove", removeList)); // behavior when hitting Solr through ZK
assertU(adoc(doc));
assertU(commit());
@@ -904,8 +879,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
removeList.add(222.222F);
removeList.add(333.333F);
doc.setField(
- "floatRemove",
- ImmutableMap.of("remove", removeList)); // behavior when hitting Solr through ZK
+ "floatRemove", Map.of("remove", removeList)); // behavior when hitting Solr through ZK
assertU(adoc(doc));
assertU(commit());
@@ -914,8 +888,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
doc = new SolrInputDocument();
doc.setField("id", "10001");
- doc.setField(
- "floatRemove", ImmutableMap.of("remove", "111.111")); // behavior when hitting Solr directly
+ doc.setField("floatRemove", Map.of("remove", "111.111")); // behavior when hitting Solr directly
assertU(adoc(doc));
assertU(commit());
@@ -964,8 +937,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
removeList.add("333.333");
doc.setField(
- "floatRemove",
- ImmutableMap.of("remove", removeList)); // behavior when hitting Solr through ZK
+ "floatRemove", Map.of("remove", removeList)); // behavior when hitting Solr through ZK
assertU(adoc(doc));
assertU(commit());
@@ -981,8 +953,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
removeList.add("222.222");
removeList.add("333.333");
doc.setField(
- "floatRemove",
- ImmutableMap.of("remove", removeList)); // behavior when hitting Solr through ZK
+ "floatRemove", Map.of("remove", removeList)); // behavior when hitting Solr through ZK
assertU(adoc(doc));
assertU(commit());
@@ -991,8 +962,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
doc = new SolrInputDocument();
doc.setField("id", "10001");
- doc.setField(
- "floatRemove", ImmutableMap.of("remove", "111.111")); // behavior when hitting Solr directly
+ doc.setField("floatRemove", Map.of("remove", "111.111")); // behavior when hitting Solr directly
assertU(adoc(doc));
assertU(commit());
@@ -1036,8 +1006,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
List<String> removeList = new ArrayList<>();
removeList.add(".b.");
removeList.add("c+c");
- doc.setField(
- "cat", ImmutableMap.of("removeregex", removeList)); // behavior when hitting Solr through ZK
+ doc.setField("cat", Map.of("removeregex", removeList)); // behavior when hitting Solr through ZK
assertU(adoc(doc));
assertU(commit());
@@ -1052,8 +1021,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
removeList = new ArrayList<>();
removeList.add("bb*");
removeList.add("cc+");
- doc.setField(
- "cat", ImmutableMap.of("removeregex", removeList)); // behavior when hitting Solr through ZK
+ doc.setField("cat", Map.of("removeregex", removeList)); // behavior when hitting Solr through ZK
assertU(adoc(doc));
assertU(commit());
@@ -1062,8 +1030,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
doc = new SolrInputDocument();
doc.setField("id", "1");
- doc.setField(
- "cat", ImmutableMap.of("removeregex", "a.a")); // behavior when hitting Solr directly
+ doc.setField("cat", Map.of("removeregex", "a.a")); // behavior when hitting Solr directly
assertU(adoc(doc));
assertU(commit());
@@ -1089,8 +1056,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
doc.setField("id", "1");
List<String> removeList = new ArrayList<>();
removeList.add("bb");
- doc.setField(
- "cat", ImmutableMap.of("removeregex", removeList)); // behavior when hitting Solr through ZK
+ doc.setField("cat", Map.of("removeregex", removeList)); // behavior when hitting Solr through ZK
assertU(adoc(doc));
assertU(commit());
@@ -1103,8 +1069,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
doc.setField("id", "1");
removeList = new ArrayList<>();
removeList.add("bbb");
- doc.setField(
- "cat", ImmutableMap.of("removeregex", removeList)); // behavior when hitting Solr through ZK
+ doc.setField("cat", Map.of("removeregex", removeList)); // behavior when hitting Solr through ZK
assertU(adoc(doc));
assertU(commit());
@@ -1137,7 +1102,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
doc = new SolrInputDocument();
doc.setField("id", "3");
- doc.setField("cat", ImmutableMap.of("add", "bbb"));
+ doc.setField("cat", Map.of("add", "bbb"));
assertU(adoc(doc));
assertU(commit());
@@ -1165,8 +1130,8 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
doc = new SolrInputDocument();
doc.setField("id", "3");
- doc.setField("cat", ImmutableMap.of("add-distinct", "bbb"));
- doc.setField("atomic_is", ImmutableMap.of("add-distinct", 10));
+ doc.setField("cat", Map.of("add-distinct", "bbb"));
+ doc.setField("atomic_is", Map.of("add-distinct", 10));
assertU(adoc(doc));
assertU(commit());
@@ -1179,8 +1144,8 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
doc = new SolrInputDocument();
doc.setField("id", "3");
- doc.setField("cat", ImmutableMap.of("add-distinct", Arrays.asList("bbb", "bbb")));
- doc.setField("atomic_is", ImmutableMap.of("add-distinct", Arrays.asList(10, 34)));
+ doc.setField("cat", Map.of("add-distinct", Arrays.asList("bbb", "bbb")));
+ doc.setField("atomic_is", Map.of("add-distinct", Arrays.asList(10, 34)));
assertU(adoc(doc));
assertU(commit());
@@ -1193,7 +1158,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
doc = new SolrInputDocument();
doc.setField("id", "5");
- doc.setField("cat", ImmutableMap.of("add-distinct", "bbb"));
+ doc.setField("cat", Map.of("add-distinct", "bbb"));
assertU(adoc(doc));
assertU(commit());
@@ -1216,7 +1181,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
doc = new SolrInputDocument();
doc.setField("id", "3");
- doc.setField("cat", ImmutableMap.of("add", "bbb"));
+ doc.setField("cat", Map.of("add", "bbb"));
assertU(adoc(doc));
assertU(commit());
@@ -1225,7 +1190,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
doc = new SolrInputDocument();
doc.setField("id", "3");
- doc.setField("cat", ImmutableMap.of("add", "bbb"));
+ doc.setField("cat", Map.of("add", "bbb"));
assertU(adoc(doc));
assertU(commit());
@@ -1236,7 +1201,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
doc = new SolrInputDocument();
doc.setField("id", "3");
- doc.setField("cat", ImmutableMap.of("remove", "bbb"));
+ doc.setField("cat", Map.of("remove", "bbb"));
assertU(adoc(doc));
assertU(commit());
@@ -1247,7 +1212,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
doc = new SolrInputDocument();
doc.setField("id", "3");
- doc.setField("cat", ImmutableMap.of("remove", "bbb"));
+ doc.setField("cat", Map.of("remove", "bbb"));
assertU(adoc(doc));
assertU(commit());
@@ -1280,7 +1245,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
doc = new SolrInputDocument();
doc.setField("id", "5");
- doc.setField("cat", ImmutableMap.of("set", "bbb"));
+ doc.setField("cat", Map.of("set", "bbb"));
assertU(adoc(doc));
assertU(commit());
@@ -1291,7 +1256,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
// update on id
doc = new SolrInputDocument();
- doc.setField("id", ImmutableMap.of("set", "1001"));
+ doc.setField("id", Map.of("set", "1001"));
assertFailedU(adoc(doc));
}
@@ -1316,40 +1281,35 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
// none (this can fail with Invalid Date String exception)
doc = new SolrInputDocument();
doc.setField("id", "6");
- doc.setField(
- "other_i", ImmutableMap.of("set", "43")); // set the independent field to another value
+ doc.setField("other_i", Map.of("set", "43")); // set the independent field to another value
assertU(adoc(doc));
if (dateFieldName.endsWith("s")) {
// add
doc = new SolrInputDocument();
doc.setField("id", "6");
- doc.setField(
- "other_i", ImmutableMap.of("set", "43")); // set the independent field to another value
- doc.setField(dateFieldName, ImmutableMap.of("add", "1987-01-01T00:00:00Z"));
+ doc.setField("other_i", Map.of("set", "43")); // set the independent field to another value
+ doc.setField(dateFieldName, Map.of("add", "1987-01-01T00:00:00Z"));
assertU(adoc(doc));
// remove
doc = new SolrInputDocument();
doc.setField("id", "6");
- doc.setField(
- "other_i", ImmutableMap.of("set", "43")); // set the independent field to another value
- doc.setField(dateFieldName, ImmutableMap.of("remove", "1987-01-01T00:00:00Z"));
+ doc.setField("other_i", Map.of("set", "43")); // set the independent field to another value
+ doc.setField(dateFieldName, Map.of("remove", "1987-01-01T00:00:00Z"));
assertU(adoc(doc));
} else {
// set
doc = new SolrInputDocument();
doc.setField("id", "6");
- doc.setField(
- "other_i", ImmutableMap.of("set", "43")); // set the independent field to another value
- doc.setField(dateFieldName, ImmutableMap.of("set", "1987-01-01T00:00:00Z"));
+ doc.setField("other_i", Map.of("set", "43")); // set the independent field to another value
+ doc.setField(dateFieldName, Map.of("set", "1987-01-01T00:00:00Z"));
assertU(adoc(doc));
// unset
doc = new SolrInputDocument();
doc.setField("id", "6");
- doc.setField(
- "other_i", ImmutableMap.of("set", "43")); // set the independent field to another value
+ doc.setField("other_i", Map.of("set", "43")); // set the independent field to another value
doc.setField(dateFieldName, map("set", null));
assertU(adoc(doc));
}
@@ -1372,24 +1332,10 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
assertU(commit());
assertU(
- adoc(
- sdoc(
- "id",
- 2,
- "title",
- ImmutableMap.of("set", "newtitle2"),
- "single_i_dvo",
- ImmutableMap.of("inc", 1))));
+ adoc(sdoc("id", 2, "title", Map.of("set", "newtitle2"), "single_i_dvo", Map.of("inc", 1))));
assertU(
- adoc(
- sdoc(
- "id",
- 3,
- "title",
- ImmutableMap.of("set", "newtitle3"),
- "single_d_dvo",
- ImmutableMap.of("inc", 1))));
- assertU(adoc(sdoc("id", 4, "single_i_dvo", ImmutableMap.of("inc", 1))));
+ adoc(sdoc("id", 3, "title", Map.of("set", "newtitle3"), "single_d_dvo", Map.of("inc", 1))));
+ assertU(adoc(sdoc("id", 4, "single_i_dvo", Map.of("inc", 1))));
assertU(commit());
assertJQ(
@@ -1413,7 +1359,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
"/response/docs/[0]/single_i_dvo==2");
// test that non stored docvalues was carried forward for a non-docvalue update
- assertU(adoc(sdoc("id", 3, "title", ImmutableMap.of("set", "newertitle3"))));
+ assertU(adoc(sdoc("id", 3, "title", Map.of("set", "newertitle3"))));
assertU(commit());
assertJQ(
req("q", "id:3"),
@@ -1438,7 +1384,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
Integer.MAX_VALUE)));
assertU(commit());
- assertU(adoc(sdoc("id", 1, "title", ImmutableMap.of("set", "newtitle1"))));
+ assertU(adoc(sdoc("id", 1, "title", Map.of("set", "newtitle1"))));
assertU(commit());
// test that non stored multivalued docvalues was carried forward for a non docvalues update
@@ -1466,19 +1412,19 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
"id",
101,
"title",
- ImmutableMap.of("set", "newtitle2"),
+ Map.of("set", "newtitle2"),
"single_i_dvn",
- ImmutableMap.of("inc", 1))));
+ Map.of("inc", 1))));
assertU(
adoc(
sdoc(
"id",
102,
"title",
- ImmutableMap.of("set", "newtitle3"),
+ Map.of("set", "newtitle3"),
"single_d_dvn",
- ImmutableMap.of("inc", 1))));
- assertU(adoc(sdoc("id", 103, "single_i_dvn", ImmutableMap.of("inc", 1))));
+ Map.of("inc", 1))));
+ assertU(adoc(sdoc("id", 103, "single_i_dvn", Map.of("inc", 1))));
}
assertU(commit());
@@ -1508,9 +1454,9 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
"id",
103,
"single_s_dvn",
- ImmutableMap.of("set", "abcupdate"),
+ Map.of("set", "abcupdate"),
"single_i_dvn",
- ImmutableMap.of("set", 5))));
+ Map.of("set", 5))));
assertU(commit());
assertJQ(
req("q", "id:103"),
@@ -1534,7 +1480,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
doc = new SolrInputDocument();
doc.setField("id", "7");
- doc.setField("cat", ImmutableMap.of("whatever", "bbb"));
+ doc.setField("cat", Map.of("whatever", "bbb"));
assertFailedU(adoc(doc));
assertU(commit());
@@ -1546,7 +1492,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
// add a nested document;
doc = new SolrInputDocument();
doc.setField("id", "123");
- doc.setField("cat", ImmutableMap.of("whatever", "ddd"));
+ doc.setField("cat", Map.of("whatever", "ddd"));
SolrInputDocument childDoc = new SolrInputDocument();
childDoc.setField("id", "1231");
@@ -1586,7 +1532,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
// inc op on non-numeric field
SolrInputDocument invalidDoc = new SolrInputDocument();
invalidDoc.setField("id", "7");
- invalidDoc.setField("cat", ImmutableMap.of("inc", "bbb"));
+ invalidDoc.setField("cat", Map.of("inc", "bbb"));
SolrException e = expectThrows(SolrException.class, () -> assertU(adoc(invalidDoc)));
assertEquals(SolrException.ErrorCode.BAD_REQUEST.code, e.code());
@@ -1612,7 +1558,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
"//doc/arr[@name='multiDefault']/str[.='muLti-Default']");
// do atomic update
- assertU(adoc(sdoc("id", "7", fieldToUpdate, ImmutableMap.of("inc", -555))));
+ assertU(adoc(sdoc("id", "7", fieldToUpdate, Map.of("inc", -555))));
assertQ(
fieldToUpdate + ": RTG after atomic update",
req("qt", "/get", "id", "7"),
@@ -1646,7 +1592,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
clearIndex();
// doc where we immediately attempt to inc the default value
- assertU(adoc(sdoc("id", "7", fieldToUpdate, ImmutableMap.of("inc", "666"))));
+ assertU(adoc(sdoc("id", "7", fieldToUpdate, Map.of("inc", "666"))));
assertQ(
fieldToUpdate + ": initial RTG#7",
req("qt", "/get", "id", "7"),
@@ -1659,7 +1605,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
"//doc/date[@name='timestamp']",
"//doc/arr[@name='multiDefault']/str[.='muLti-Default']");
// do atomic update
- assertU(adoc(sdoc("id", "7", fieldToUpdate, ImmutableMap.of("inc", -555))));
+ assertU(adoc(sdoc("id", "7", fieldToUpdate, Map.of("inc", -555))));
assertQ(
fieldToUpdate + ": RTG#7 after atomic update",
req("qt", "/get", "id", "7"),
@@ -1673,7 +1619,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
"//doc/arr[@name='multiDefault']/str[.='muLti-Default']");
// diff doc where we check that we can overwrite the default value
- assertU(adoc(sdoc("id", "8", fieldToUpdate, ImmutableMap.of("set", "666"))));
+ assertU(adoc(sdoc("id", "8", fieldToUpdate, Map.of("set", "666"))));
assertQ(
fieldToUpdate + ": initial RTG#8",
req("qt", "/get", "id", "8"),
@@ -1686,7 +1632,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
"//doc/date[@name='timestamp']",
"//doc/arr[@name='multiDefault']/str[.='muLti-Default']");
// do atomic update
- assertU(adoc(sdoc("id", "8", fieldToUpdate, ImmutableMap.of("inc", -555))));
+ assertU(adoc(sdoc("id", "8", fieldToUpdate, Map.of("inc", -555))));
assertQ(
fieldToUpdate + ": RTG after atomic update",
req("qt", "/get", "id", "8"),
@@ -1744,7 +1690,7 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
doc = new SolrInputDocument();
doc.setField("id", "5005");
- doc.setField("intRemove", ImmutableMap.of("remove", List.of(111L, 222L), "add-distinct", 333L));
+ doc.setField("intRemove", Map.of("remove", List.of(111L, 222L), "add-distinct", 333L));
assertU(adoc(doc));
assertU(commit());
diff --git a/solr/core/src/test/org/apache/solr/update/processor/SkipExistingDocumentsProcessorFactoryTest.java b/solr/core/src/test/org/apache/solr/update/processor/SkipExistingDocumentsProcessorFactoryTest.java
index f48fce7c9bf..bea8bd507a4 100644
--- a/solr/core/src/test/org/apache/solr/update/processor/SkipExistingDocumentsProcessorFactoryTest.java
+++ b/solr/core/src/test/org/apache/solr/update/processor/SkipExistingDocumentsProcessorFactoryTest.java
@@ -20,8 +20,8 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
-import com.google.common.collect.ImmutableMap;
import java.io.IOException;
+import java.util.Map;
import org.apache.lucene.util.BytesRef;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException;
@@ -340,7 +340,7 @@ public class SkipExistingDocumentsProcessorFactoryTest extends SolrTestCaseJ4 {
AddUpdateCommand cmd = new AddUpdateCommand(req);
cmd.setIndexedId(docId);
cmd.solrDoc = new SolrInputDocument();
- cmd.solrDoc.addField("last_name", ImmutableMap.of("set", "Smith"));
+ cmd.solrDoc.addField("last_name", Map.of("set", "Smith"));
assertTrue(AtomicUpdateDocumentMerger.isAtomicUpdate(cmd));
return cmd;
}
diff --git a/solr/core/src/test/org/apache/solr/update/processor/TestPartialUpdateDeduplication.java b/solr/core/src/test/org/apache/solr/update/processor/TestPartialUpdateDeduplication.java
index 500f2e33579..fecba56e1f9 100644
--- a/solr/core/src/test/org/apache/solr/update/processor/TestPartialUpdateDeduplication.java
+++ b/solr/core/src/test/org/apache/solr/update/processor/TestPartialUpdateDeduplication.java
@@ -16,7 +16,6 @@
*/
package org.apache.solr.update.processor;
-import com.google.common.collect.Maps;
import java.util.Map;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.request.UpdateRequest;
@@ -37,8 +36,7 @@ public class TestPartialUpdateDeduplication extends SolrTestCaseJ4 {
// partial update
SolrInputDocument doc = new SolrInputDocument();
doc.addField("id", "2a");
- Map<String, Object> map = Maps.newHashMap();
- map.put("set", "Hello Dude man!");
+ Map<String, Object> map = Map.of("set", "Hello Dude man!");
doc.addField("v_t", map);
UpdateRequest req = new UpdateRequest();
req.add(doc);
@@ -56,8 +54,7 @@ public class TestPartialUpdateDeduplication extends SolrTestCaseJ4 {
addDoc(adoc("id", "2a", "v_t", "Hello Dude man!", "name", "ali babi'"), chain);
doc = new SolrInputDocument();
doc.addField("id", "2a");
- map = Maps.newHashMap();
- map.put("set", "name changed");
+ map = Map.of("set", "name changed");
doc.addField("name", map);
req = new UpdateRequest();
req.add(doc);
diff --git a/solr/core/src/test/org/apache/solr/util/TestUtils.java b/solr/core/src/test/org/apache/solr/util/TestUtils.java
index 698e6843281..c2a0f85d146 100644
--- a/solr/core/src/test/org/apache/solr/util/TestUtils.java
+++ b/solr/core/src/test/org/apache/solr/util/TestUtils.java
@@ -23,7 +23,6 @@ import static org.apache.solr.common.cloud.ZkStateReader.NRT_REPLICAS;
import static org.apache.solr.common.cloud.ZkStateReader.NUM_SHARDS_PROP;
import static org.apache.solr.common.util.Utils.fromJSONString;
-import com.google.common.collect.ImmutableList;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.StringReader;
@@ -353,9 +352,7 @@ public class TestUtils extends SolrTestCaseJ4 {
sink,
(Map<String, Object>)
Utils.fromJSONString("collectionDefaults:{numShards:3 , nrtReplicas:2}")));
- assertEquals(
- 3L, Utils.getObjectByPath(sink, true, ImmutableList.of(COLLECTION_DEF, NUM_SHARDS_PROP)));
- assertEquals(
- 2L, Utils.getObjectByPath(sink, true, ImmutableList.of(COLLECTION_DEF, NRT_REPLICAS)));
+ assertEquals(3L, Utils.getObjectByPath(sink, true, List.of(COLLECTION_DEF, NUM_SHARDS_PROP)));
+ assertEquals(2L, Utils.getObjectByPath(sink, true, List.of(COLLECTION_DEF, NRT_REPLICAS)));
}
}
diff --git a/solr/core/src/test/org/apache/solr/util/configuration/providers/EnvSSLCredentialProviderTest.java b/solr/core/src/test/org/apache/solr/util/configuration/providers/EnvSSLCredentialProviderTest.java
index 7680e3ed78b..e0bd1452cd2 100644
--- a/solr/core/src/test/org/apache/solr/util/configuration/providers/EnvSSLCredentialProviderTest.java
+++ b/solr/core/src/test/org/apache/solr/util/configuration/providers/EnvSSLCredentialProviderTest.java
@@ -20,7 +20,6 @@ package org.apache.solr.util.configuration.providers;
import static org.apache.solr.util.configuration.providers.AbstractSSLCredentialProvider.DEFAULT_CREDENTIAL_KEY_MAP;
import static org.hamcrest.core.Is.is;
-import com.google.common.collect.ImmutableMap;
import java.util.Map;
import org.apache.solr.SolrTestCase;
import org.apache.solr.util.configuration.SSLCredentialProvider;
@@ -34,7 +33,7 @@ public class EnvSSLCredentialProviderTest extends SolrTestCase {
public void testGetCredentials() {
int cnt = 0;
Map<String, String> envvars =
- ImmutableMap.of(
+ Map.of(
EnvSSLCredentialProvider.EnvVars.SOLR_SSL_KEY_STORE_PASSWORD, "pw" + ++cnt,
EnvSSLCredentialProvider.EnvVars.SOLR_SSL_TRUST_STORE_PASSWORD, "pw" + ++cnt,
EnvSSLCredentialProvider.EnvVars.SOLR_SSL_CLIENT_KEY_STORE_PASSWORD, "pw" + ++cnt,
diff --git a/solr/modules/analytics/build.gradle b/solr/modules/analytics/build.gradle
index 8289a94b9fe..8e5b0d403c3 100644
--- a/solr/modules/analytics/build.gradle
+++ b/solr/modules/analytics/build.gradle
@@ -28,7 +28,6 @@ dependencies {
implementation 'com.fasterxml.jackson.core:jackson-annotations'
implementation 'com.fasterxml.jackson.core:jackson-core'
implementation 'com.fasterxml.jackson.core:jackson-databind'
- implementation 'com.google.guava:guava'
testImplementation project(':solr:test-framework')
testImplementation 'com.carrotsearch.randomizedtesting:randomizedtesting-runner'
diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/SortableFacet.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/SortableFacet.java
index ca78978eb26..10905adb978 100644
--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/SortableFacet.java
+++ b/solr/modules/analytics/src/java/org/apache/solr/analytics/facet/SortableFacet.java
@@ -16,12 +16,12 @@
*/
package org.apache.solr.analytics.facet;
-import com.google.common.collect.Iterables;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
import org.apache.solr.analytics.facet.compare.FacetResultsComparator;
import org.apache.solr.analytics.util.AnalyticsResponseHeadings;
import org.apache.solr.common.util.NamedList;
@@ -82,17 +82,18 @@ public abstract class SortableFacet extends AnalyticsFacet {
Comparator<FacetBucket> comp = sort.getComparator();
facetResults.sort(comp);
- Iterable<FacetBucket> facetResultsIter = facetResults;
// apply the limit
if (sort.getLimit() > 0) {
if (sort.getOffset() > 0) {
- facetResultsIter = Iterables.skip(facetResultsIter, sort.getOffset());
+ facetResults =
+ facetResults.stream().skip(sort.getOffset()).collect(Collectors.toUnmodifiableList());
}
- facetResultsIter = Iterables.limit(facetResultsIter, sort.getLimit());
+ facetResults =
+ facetResults.stream().limit(sort.getLimit()).collect(Collectors.toUnmodifiableList());
} else if (sort.getLimit() == 0) {
return new ArrayList<>();
}
- return facetResultsIter;
+ return facetResults;
}
/** Specifies how to sort the buckets of a sortable facet. */
diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/LegacyAbstractAnalyticsTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/LegacyAbstractAnalyticsTest.java
index 5a75adc982b..fbb978beb4c 100644
--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/LegacyAbstractAnalyticsTest.java
+++ b/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/LegacyAbstractAnalyticsTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.solr.analytics.legacy;
-import com.google.common.collect.ObjectArrays;
import java.io.ByteArrayInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -24,10 +23,12 @@ import java.io.InputStream;
import java.lang.invoke.MethodHandles;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
+import java.util.stream.Stream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
@@ -227,18 +228,21 @@ public class LegacyAbstractAnalyticsTest extends SolrTestCaseJ4 {
}
public static SolrQueryRequest request(String... args) {
- return SolrTestCaseJ4.req(ObjectArrays.concat(BASEPARMS, args, String.class));
+ return SolrTestCaseJ4.req(
+ Stream.concat(Arrays.stream(BASEPARMS), Arrays.stream(args)).toArray(String[]::new));
}
public static SolrQueryRequest request(String[] args, String... additional) {
- return SolrTestCaseJ4.req(ObjectArrays.concat(BASEPARMS, args, String.class), additional);
+ return SolrTestCaseJ4.req(
+ Stream.concat(Arrays.stream(BASEPARMS), Arrays.stream(args)).toArray(String[]::new),
+ additional);
}
public static String[] fileToStringArr(Class<?> clazz, String fileName)
throws FileNotFoundException {
InputStream in = clazz.getResourceAsStream("/solr/analytics/legacy/" + fileName);
if (in == null) throw new FileNotFoundException("Resource not found: " + fileName);
- Scanner file = new Scanner(in, "UTF-8");
+ Scanner file = new Scanner(in, StandardCharsets.UTF_8);
try {
ArrayList<String> strList = new ArrayList<>();
while (file.hasNextLine()) {
diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyAbstractAnalyticsFacetTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyAbstractAnalyticsFacetTest.java
index ad5f1d8eb9a..3ac1f46b1c9 100644
--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyAbstractAnalyticsFacetTest.java
+++ b/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyAbstractAnalyticsFacetTest.java
@@ -16,19 +16,20 @@
*/
package org.apache.solr.analytics.legacy.facet;
-import com.google.common.collect.ObjectArrays;
import java.io.ByteArrayInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
+import java.util.stream.Stream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
@@ -269,8 +270,7 @@ public class LegacyAbstractAnalyticsFacetTest extends SolrTestCaseJ4 {
} else if (stat.equals("unique")) {
result = new ArrayList<Long>();
for (List<T> list : lists) {
- HashSet<T> set = new HashSet<>();
- set.addAll(list);
+ HashSet<T> set = new HashSet<>(list);
result.add((long) set.size());
}
} else if (stat.equals("max")) {
@@ -306,7 +306,8 @@ public class LegacyAbstractAnalyticsFacetTest extends SolrTestCaseJ4 {
}
public static SolrQueryRequest request(String... args) {
- return SolrTestCaseJ4.req(ObjectArrays.concat(BASEPARMS, args, String.class));
+ return SolrTestCaseJ4.req(
+ Stream.concat(Arrays.stream(BASEPARMS), Arrays.stream(args)).toArray(String[]::new));
}
public static final String[] BASEPARMS =
@@ -316,7 +317,7 @@ public class LegacyAbstractAnalyticsFacetTest extends SolrTestCaseJ4 {
throws FileNotFoundException {
InputStream in = clazz.getResourceAsStream("/solr/analytics/legacy/" + fileName);
if (in == null) throw new FileNotFoundException("Resource not found: " + fileName);
- Scanner file = new Scanner(in, "UTF-8");
+ Scanner file = new Scanner(in, StandardCharsets.UTF_8);
try {
ArrayList<String> strList = new ArrayList<>();
while (file.hasNextLine()) {
@@ -343,7 +344,7 @@ public class LegacyAbstractAnalyticsFacetTest extends SolrTestCaseJ4 {
protected void removeNodes(String xPath, List<Double> string) throws XPathExpressionException {
NodeList missingNodes = getNodes(xPath);
- List<Double> result = new ArrayList<Double>();
+ List<Double> result = new ArrayList<>();
for (int idx = 0; idx < missingNodes.getLength(); ++idx) {
result.add(Double.parseDouble(missingNodes.item(idx).getTextContent()));
}
@@ -351,8 +352,6 @@ public class LegacyAbstractAnalyticsFacetTest extends SolrTestCaseJ4 {
}
protected NodeList getNodes(String xPath) throws XPathExpressionException {
- StringBuilder sb = new StringBuilder(xPath);
- return (NodeList)
- xPathFact.newXPath().compile(sb.toString()).evaluate(doc, XPathConstants.NODESET);
+ return (NodeList) xPathFact.newXPath().compile(xPath).evaluate(doc, XPathConstants.NODESET);
}
}
diff --git a/solr/modules/gcs-repository/build.gradle b/solr/modules/gcs-repository/build.gradle
index ea6eb9322b6..6d381cfb92a 100644
--- a/solr/modules/gcs-repository/build.gradle
+++ b/solr/modules/gcs-repository/build.gradle
@@ -39,6 +39,5 @@ dependencies {
testImplementation 'com.carrotsearch.randomizedtesting:randomizedtesting-runner'
testImplementation 'junit:junit'
- testImplementation 'com.google.guava:guava'
testImplementation 'com.google.cloud:google-cloud-nio'
}
diff --git a/solr/modules/gcs-repository/src/test/org/apache/solr/gcs/LocalStorageGCSBackupRepository.java b/solr/modules/gcs-repository/src/test/org/apache/solr/gcs/LocalStorageGCSBackupRepository.java
index 994cd54dab0..43a17aac5ed 100644
--- a/solr/modules/gcs-repository/src/test/org/apache/solr/gcs/LocalStorageGCSBackupRepository.java
+++ b/solr/modules/gcs-repository/src/test/org/apache/solr/gcs/LocalStorageGCSBackupRepository.java
@@ -23,13 +23,12 @@ import com.google.cloud.storage.BlobId;
import com.google.cloud.storage.Storage;
import com.google.cloud.storage.StorageException;
import com.google.cloud.storage.contrib.nio.testing.LocalStorageHelper;
-import com.google.common.collect.Lists;
import java.io.IOException;
import java.net.URI;
import java.nio.file.NoSuchFileException;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import java.util.stream.Collectors;
public class LocalStorageGCSBackupRepository extends GCSBackupRepository {
@@ -61,9 +60,9 @@ public class LocalStorageGCSBackupRepository extends GCSBackupRepository {
@Override
public void delete(URI path, Collection<String> files, boolean ignoreNoSuchFileException)
throws IOException {
- final List<Boolean> results = Lists.newArrayList();
+ final List<Boolean> results = new ArrayList<>();
- final List<String> filesOrdered = files.stream().collect(Collectors.toList());
+ final List<String> filesOrdered = new ArrayList<>(files);
for (String file : filesOrdered) {
final String prefix = path.toString().endsWith("/") ? path.toString() : path.toString() + "/";
results.add(storage.delete(BlobId.of(bucketName, prefix + file)));
diff --git a/solr/modules/hdfs/src/java/org/apache/solr/hdfs/HdfsDirectoryFactory.java b/solr/modules/hdfs/src/java/org/apache/solr/hdfs/HdfsDirectoryFactory.java
index 89336902226..f80638517cb 100644
--- a/solr/modules/hdfs/src/java/org/apache/solr/hdfs/HdfsDirectoryFactory.java
+++ b/solr/modules/hdfs/src/java/org/apache/solr/hdfs/HdfsDirectoryFactory.java
@@ -18,21 +18,20 @@ package org.apache.solr.hdfs;
import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION;
+import com.github.benmanes.caffeine.cache.Caffeine;
+import com.github.benmanes.caffeine.cache.RemovalCause;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.RemovalListener;
-import com.google.common.cache.RemovalNotification;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Set;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileContext;
@@ -132,18 +131,12 @@ public class HdfsDirectoryFactory extends CachingDirectoryFactory
private static Boolean kerberosInit;
// we use this cache for FileSystem instances when we don't have access to a long lived instance
- private com.google.common.cache.Cache<String, FileSystem> tmpFsCache =
- CacheBuilder.newBuilder()
- .concurrencyLevel(10)
+ private final com.github.benmanes.caffeine.cache.Cache<String, FileSystem> tmpFsCache =
+ Caffeine.newBuilder()
.maximumSize(1000)
.expireAfterAccess(5, TimeUnit.MINUTES)
.removalListener(
- new RemovalListener<String, FileSystem>() {
- @Override
- public void onRemoval(RemovalNotification<String, FileSystem> rn) {
- IOUtils.closeQuietly(rn.getValue());
- }
- })
+ (String key, FileSystem fs, RemovalCause cause) -> IOUtils.closeQuietly(fs))
.build();
private static final class MetricsHolder {
@@ -472,9 +465,10 @@ public class HdfsDirectoryFactory extends CachingDirectoryFactory
String path;
if (cd.getCloudDescriptor() != null) {
path =
- URLEncoder.encode(cd.getCloudDescriptor().getCollectionName(), "UTF-8")
+ URLEncoder.encode(cd.getCloudDescriptor().getCollectionName(), StandardCharsets.UTF_8)
+ "/"
- + URLEncoder.encode(cd.getCloudDescriptor().getCoreNodeName(), "UTF-8");
+ + URLEncoder.encode(
+ cd.getCloudDescriptor().getCoreNodeName(), StandardCharsets.UTF_8);
} else {
path = cd.getName();
}
@@ -517,13 +511,17 @@ public class HdfsDirectoryFactory extends CachingDirectoryFactory
}
private FileSystem getCachedFileSystem(String pathStr) {
- try {
- // no need to close the fs, the cache will do it
- Path path = new Path(pathStr);
- return tmpFsCache.get(pathStr, () -> FileSystem.get(path.toUri(), getConf(path)));
- } catch (ExecutionException e) {
- throw new RuntimeException(e);
- }
+ // no need to close the fs, the cache will do it
+ Path path = new Path(pathStr);
+ return tmpFsCache.get(
+ pathStr,
+ k -> {
+ try {
+ return FileSystem.get(path.toUri(), getConf(path));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ });
}
public String getConfDir() {
diff --git a/solr/modules/hdfs/src/java/org/apache/solr/hdfs/backup/repository/HdfsBackupRepository.java b/solr/modules/hdfs/src/java/org/apache/solr/hdfs/backup/repository/HdfsBackupRepository.java
index bb0feff5266..c50b63e6752 100644
--- a/solr/modules/hdfs/src/java/org/apache/solr/hdfs/backup/repository/HdfsBackupRepository.java
+++ b/solr/modules/hdfs/src/java/org/apache/solr/hdfs/backup/repository/HdfsBackupRepository.java
@@ -17,7 +17,6 @@
package org.apache.solr.hdfs.backup.repository;
-import com.google.common.base.Preconditions;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.invoke.MethodHandles;
@@ -139,7 +138,9 @@ public class HdfsBackupRepository implements BackupRepository {
@Override
public URI resolve(URI baseUri, String... pathComponents) {
- Preconditions.checkArgument(baseUri.isAbsolute());
+ if (!baseUri.isAbsolute()) {
+ throw new IllegalArgumentException("baseUri must be absolute");
+ }
Path result = new Path(baseUri);
for (String path : pathComponents) {
diff --git a/solr/modules/hdfs/src/java/org/apache/solr/hdfs/snapshots/SolrSnapshotsTool.java b/solr/modules/hdfs/src/java/org/apache/solr/hdfs/snapshots/SolrSnapshotsTool.java
index 4ff0fde9c80..fba471e63a8 100644
--- a/solr/modules/hdfs/src/java/org/apache/solr/hdfs/snapshots/SolrSnapshotsTool.java
+++ b/solr/modules/hdfs/src/java/org/apache/solr/hdfs/snapshots/SolrSnapshotsTool.java
@@ -17,7 +17,6 @@
package org.apache.solr.hdfs.snapshots;
-import com.google.common.base.Preconditions;
import java.io.Closeable;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
@@ -121,9 +120,10 @@ public class SolrSnapshotsTool implements Closeable, CLIO {
CollectionAdminResponse resp;
try {
resp = createSnap.process(solrClient);
- Preconditions.checkState(
- resp.getStatus() == 0,
- "The CREATESNAPSHOT request failed. The status code is " + resp.getStatus());
+ if (resp.getStatus() != 0) {
+ throw new IllegalStateException(
+ "The CREATESNAPSHOT request failed. The status code is " + resp.getStatus());
+ }
CLIO.out(
"Successfully created snapshot with name "
+ snapshotName
@@ -152,9 +152,7 @@ public class SolrSnapshotsTool implements Closeable, CLIO {
CollectionAdminResponse resp;
try {
resp = deleteSnap.process(solrClient);
- Preconditions.checkState(
- resp.getStatus() == 0,
- "The DELETESNAPSHOT request failed. The status code is " + resp.getStatus());
+ checkResponse(resp, "DELETESNAPSHOT");
CLIO.out(
"Successfully deleted snapshot with name "
+ snapshotName
@@ -177,15 +175,20 @@ public class SolrSnapshotsTool implements Closeable, CLIO {
}
}
+ private static void checkResponse(CollectionAdminResponse resp, String requestType) {
+ if (resp.getStatus() != 0) {
+ throw new IllegalStateException(
+ "The " + requestType + " request failed. The status code is " + resp.getStatus());
+ }
+ }
+
public void listSnapshots(String collectionName) {
CollectionAdminRequest.ListSnapshots listSnaps =
new CollectionAdminRequest.ListSnapshots(collectionName);
CollectionAdminResponse resp;
try {
resp = listSnaps.process(solrClient);
- Preconditions.checkState(
- resp.getStatus() == 0,
- "The LISTSNAPSHOTS request failed. The status code is " + resp.getStatus());
+ checkResponse(resp, "LISTSNAPSHOTS");
NamedList<?> apiResult =
(NamedList<?>) resp.getResponse().get(SolrSnapshotManager.SNAPSHOTS_INFO);
@@ -327,8 +330,7 @@ public class SolrSnapshotsTool implements Closeable, CLIO {
backup.setIndexBackupStrategy(CollectionAdminParams.NO_INDEX_BACKUP_STRATEGY);
backup.setLocation(backupLoc);
CollectionAdminResponse resp = backup.process(solrClient);
- Preconditions.checkState(
- resp.getStatus() == 0, "The request failed. The status code is " + resp.getStatus());
+ checkResponse(resp, "BACKUP");
}
/**
@@ -569,7 +571,7 @@ public class SolrSnapshotsTool implements Closeable, CLIO {
new CollectionAdminRequest.ListSnapshots(collectionName);
CollectionAdminResponse resp = listSnapshots.process(solrClient);
- Preconditions.checkState(resp.getStatus() == 0);
+ checkResponse(resp, "LISTSNAPSHOTS");
NamedList<?> apiResult =
(NamedList<?>) resp.getResponse().get(SolrSnapshotManager.SNAPSHOTS_INFO);
diff --git a/solr/modules/s3-repository/src/java/org/apache/solr/s3/S3StorageClient.java b/solr/modules/s3-repository/src/java/org/apache/solr/s3/S3StorageClient.java
index 0b54cfe8cf7..13123e4d44b 100644
--- a/solr/modules/s3-repository/src/java/org/apache/solr/s3/S3StorageClient.java
+++ b/solr/modules/s3-repository/src/java/org/apache/solr/s3/S3StorageClient.java
@@ -32,6 +32,7 @@ import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.solr.common.StringUtils;
+import org.apache.solr.common.util.SuppressForbidden;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider;
@@ -422,6 +423,7 @@ public class S3StorageClient {
* @param batchSize number of deletes to send to S3 at a time
*/
@VisibleForTesting
+ @SuppressForbidden(reason = "Lists.partition")
Collection<String> deleteObjects(Collection<String> entries, int batchSize) throws S3Exception {
List<ObjectIdentifier> keysToDelete =
entries.stream()
diff --git a/solr/modules/sql/build.gradle b/solr/modules/sql/build.gradle
index b1053fad1b3..7afabae221c 100644
--- a/solr/modules/sql/build.gradle
+++ b/solr/modules/sql/build.gradle
@@ -27,8 +27,6 @@ dependencies {
implementation 'org.slf4j:slf4j-api'
- implementation 'com.google.guava:guava'
-
// SQL Parser via Calcite
implementation ('org.apache.calcite:calcite-core', {
exclude group: 'com.fasterxml.jackson.dataformat', module: 'jackson-dataformat-yaml'
diff --git a/solr/modules/sql/src/java/org/apache/solr/handler/sql/SolrFilter.java b/solr/modules/sql/src/java/org/apache/solr/handler/sql/SolrFilter.java
index 8c2afc51a76..d54f704148c 100644
--- a/solr/modules/sql/src/java/org/apache/solr/handler/sql/SolrFilter.java
+++ b/solr/modules/sql/src/java/org/apache/solr/handler/sql/SolrFilter.java
@@ -589,14 +589,15 @@ class SolrFilter extends Filter implements SolrRel {
if (left.getKind() == SqlKind.CAST && right.getKind() == SqlKind.CAST) {
return translateBinary2(
- ((RexCall) left).operands.get(0), ((RexCall) right).operands.get(0));
+ ((RexCall) left).getOperands().get(0), ((RexCall) right).getOperands().get(0));
}
// for WHERE clause like: pdatex >= '2021-07-13T15:12:10.037Z'
if (left.getKind() == SqlKind.INPUT_REF && right.getKind() == SqlKind.CAST) {
final RexCall cast = ((RexCall) right);
- if (cast.operands.size() == 1 && cast.operands.get(0).getKind() == SqlKind.LITERAL) {
- return translateBinary2(left, cast.operands.get(0));
+ if (cast.getOperands().size() == 1
+ && cast.getOperands().get(0).getKind() == SqlKind.LITERAL) {
+ return translateBinary2(left, cast.getOperands().get(0));
}
}
@@ -633,7 +634,7 @@ class SolrFilter extends Filter implements SolrRel {
String name = fieldNames.get(left1.getIndex());
return new Pair<>(name, rightLiteral);
case CAST:
- return translateBinary2(((RexCall) left).operands.get(0), right);
+ return translateBinary2(((RexCall) left).getOperands().get(0), right);
// case OTHER_FUNCTION:
// String itemName = SolrRules.isItem((RexCall) left);
// if (itemName != null) {
@@ -649,7 +650,8 @@ class SolrFilter extends Filter implements SolrRel {
final String fieldName = getSolrFieldName(condition);
RexCall expanded = (RexCall) RexUtil.expandSearch(builder, null, condition);
- final RexNode peekAt0 = !expanded.operands.isEmpty() ? expanded.operands.get(0) : null;
+ final RexNode peekAt0 =
+ !expanded.getOperands().isEmpty() ? expanded.getOperands().get(0) : null;
if (expanded.op.kind == SqlKind.AND) {
// See if NOT IN was translated into a big AND not
if (peekAt0 instanceof RexCall) {
@@ -679,7 +681,7 @@ class SolrFilter extends Filter implements SolrRel {
protected String toOrSetOnSameField(String solrField, RexCall search) {
String orClause =
- search.operands.stream()
+ search.getOperands().stream()
.map(
n -> {
RexCall next = (RexCall) n;
diff --git a/solr/modules/sql/src/java/org/apache/solr/handler/sql/SolrSchema.java b/solr/modules/sql/src/java/org/apache/solr/handler/sql/SolrSchema.java
index 02a02fe672d..6d63e67c3dc 100644
--- a/solr/modules/sql/src/java/org/apache/solr/handler/sql/SolrSchema.java
+++ b/solr/modules/sql/src/java/org/apache/solr/handler/sql/SolrSchema.java
@@ -16,7 +16,6 @@
*/
package org.apache.solr.handler.sql;
-import com.google.common.collect.ImmutableMap;
import java.io.Closeable;
import java.io.IOException;
import java.util.Date;
@@ -89,7 +88,7 @@ class SolrSchema extends AbstractSchema implements Closeable {
CloudSolrClient cloudSolrClient = solrClientCache.getCloudSolrClient(zk);
ClusterState clusterState = cloudSolrClient.getClusterState();
- final ImmutableMap.Builder<String, Table> builder = ImmutableMap.builder();
+ final Map<String, Table> builder = new HashMap<>();
Set<String> collections = clusterState.getCollectionsMap().keySet();
for (String collection : collections) {
@@ -104,7 +103,7 @@ class SolrSchema extends AbstractSchema implements Closeable {
}
}
- return builder.build();
+ return Map.copyOf(builder);
}
private Map<String, LukeResponse.FieldInfo> getFieldInfo(final String collection) {
diff --git a/solr/modules/sql/src/java/org/apache/solr/handler/sql/SolrToEnumerableConverter.java b/solr/modules/sql/src/java/org/apache/solr/handler/sql/SolrToEnumerableConverter.java
index 5bf837d6fb3..76049d10a60 100644
--- a/solr/modules/sql/src/java/org/apache/solr/handler/sql/SolrToEnumerableConverter.java
+++ b/solr/modules/sql/src/java/org/apache/solr/handler/sql/SolrToEnumerableConverter.java
@@ -16,11 +16,11 @@
*/
package org.apache.solr.handler.sql;
-import com.google.common.collect.Lists;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
import org.apache.calcite.adapter.enumerable.EnumerableRel;
import org.apache.calcite.adapter.enumerable.EnumerableRelImplementor;
import org.apache.calcite.adapter.enumerable.JavaRowFormat;
@@ -164,6 +164,6 @@ class SolrToEnumerableConverter extends ConverterImpl implements EnumerableRel {
* ConstantExpression("y")}".
*/
private static <T> List<Expression> constantList(List<T> values) {
- return Lists.transform(values, Expressions::constant);
+ return values.stream().map(Expressions::constant).collect(Collectors.toUnmodifiableList());
}
}
diff --git a/solr/solrj-zookeeper/src/test/org/apache/solr/common/cloud/TestPerReplicaStates.java b/solr/solrj-zookeeper/src/test/org/apache/solr/common/cloud/TestPerReplicaStates.java
index d0a46387320..99edf56cd69 100644
--- a/solr/solrj-zookeeper/src/test/org/apache/solr/common/cloud/TestPerReplicaStates.java
+++ b/solr/solrj-zookeeper/src/test/org/apache/solr/common/cloud/TestPerReplicaStates.java
@@ -17,8 +17,7 @@
package org.apache.solr.common.cloud;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
+import java.util.List;
import java.util.Set;
import org.apache.solr.cloud.SolrCloudTestCase;
import org.apache.solr.common.cloud.Replica.State;
@@ -50,20 +49,18 @@ public class TestPerReplicaStates extends SolrCloudTestCase {
public void testEntries() {
PerReplicaStates entries =
new PerReplicaStates(
- "state.json", 0, ImmutableList.of("R1:2:A", "R1:1:A:L", "R1:0:D", "R2:0:D", "R3:0:A"));
+ "state.json", 0, List.of("R1:2:A", "R1:1:A:L", "R1:0:D", "R2:0:D", "R3:0:A"));
assertEquals(2, entries.get("R1").version);
entries =
new PerReplicaStates(
- "state.json", 0, ImmutableList.of("R1:1:A:L", "R1:2:A", "R2:0:D", "R3:0:A", "R1:0:D"));
+ "state.json", 0, List.of("R1:1:A:L", "R1:2:A", "R2:0:D", "R3:0:A", "R1:0:D"));
assertEquals(2, entries.get("R1").version);
assertEquals(2, entries.get("R1").getDuplicates().size());
Set<String> modified =
PerReplicaStates.findModifiedReplicas(
entries,
new PerReplicaStates(
- "state.json",
- 0,
- ImmutableList.of("R1:1:A:L", "R1:2:A", "R2:0:D", "R3:1:A", "R1:0:D")));
+ "state.json", 0, List.of("R1:1:A:L", "R1:2:A", "R2:0:D", "R3:1:A", "R1:0:D")));
assertEquals(1, modified.size());
assertTrue(modified.contains("R3"));
modified =
@@ -72,7 +69,7 @@ public class TestPerReplicaStates extends SolrCloudTestCase {
new PerReplicaStates(
"state.json",
0,
- ImmutableList.of("R1:1:A:L", "R1:2:A", "R2:0:D", "R3:1:A", "R1:0:D", "R4:0:A")));
+ List.of("R1:1:A:L", "R1:2:A", "R2:0:D", "R3:1:A", "R1:0:D", "R4:0:A")));
assertEquals(2, modified.size());
assertTrue(modified.contains("R3"));
assertTrue(modified.contains("R4"));
@@ -80,9 +77,7 @@ public class TestPerReplicaStates extends SolrCloudTestCase {
PerReplicaStates.findModifiedReplicas(
entries,
new PerReplicaStates(
- "state.json",
- 0,
- ImmutableList.of("R1:1:A:L", "R1:2:A", "R3:1:A", "R1:0:D", "R4:0:A")));
+ "state.json", 0, List.of("R1:1:A:L", "R1:2:A", "R3:1:A", "R1:0:D", "R4:0:A")));
assertEquals(3, modified.size());
assertTrue(modified.contains("R3"));
assertTrue(modified.contains("R4"));
@@ -93,8 +88,7 @@ public class TestPerReplicaStates extends SolrCloudTestCase {
String root = "/testReplicaStateOperations";
cluster.getZkClient().create(root, null, CreateMode.PERSISTENT, true);
- ImmutableList<String> states =
- ImmutableList.of("R1:2:A", "R1:1:A:L", "R1:0:D", "R3:0:A", "R4:13:A");
+ List<String> states = List.of("R1:2:A", "R1:1:A:L", "R1:0:D", "R3:0:A", "R4:13:A");
for (String state : states) {
cluster.getZkClient().create(root + "/" + state, null, CreateMode.PERSISTENT, true);
@@ -132,13 +126,13 @@ public class TestPerReplicaStates extends SolrCloudTestCase {
rs = PerReplicaStatesFetcher.fetch(root, zkStateReader.getZkClient(), null);
assertEquals(3, rs.states.size());
- ops = PerReplicaStatesOps.flipLeader(ImmutableSet.of("R4", "R3", "R1"), "R4", rs);
+ ops = PerReplicaStatesOps.flipLeader(Set.of("R4", "R3", "R1"), "R4", rs);
assertEquals(2, ops.ops.size());
assertEquals(PerReplicaStates.Operation.Type.ADD, ops.ops.get(0).typ);
assertEquals(PerReplicaStates.Operation.Type.DELETE, ops.ops.get(1).typ);
ops.persist(root, cluster.getZkClient());
rs = PerReplicaStatesFetcher.fetch(root, zkStateReader.getZkClient(), null);
- ops = PerReplicaStatesOps.flipLeader(ImmutableSet.of("R4", "R3", "R1"), "R3", rs);
+ ops = PerReplicaStatesOps.flipLeader(Set.of("R4", "R3", "R1"), "R3", rs);
assertEquals(4, ops.ops.size());
ops.persist(root, cluster.getZkClient());
rs = PerReplicaStatesFetcher.fetch(root, zkStateReader.getZkClient(), null);
diff --git a/solr/solrj/build.gradle b/solr/solrj/build.gradle
index 38de67ba9f6..6c8d5405cbf 100644
--- a/solr/solrj/build.gradle
+++ b/solr/solrj/build.gradle
@@ -82,6 +82,5 @@ dependencies {
exclude group: "org.apache.logging.log4j", module: "log4j-api"
})
testImplementation 'org.apache.commons:commons-lang3'
- testImplementation 'com.google.guava:guava'
testImplementation 'io.dropwizard.metrics:metrics-core'
}
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/CollectionUtil.java b/solr/solrj/src/java/org/apache/solr/common/util/CollectionUtil.java
new file mode 100644
index 00000000000..06df651ebb7
--- /dev/null
+++ b/solr/solrj/src/java/org/apache/solr/common/util/CollectionUtil.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.common.util;
+
+import java.util.HashMap;
+import java.util.HashSet;
+
+/**
+ * Methods for creating collections with exact sizes.
+ *
+ * @lucene.internal
+ */
+public final class CollectionUtil {
+
+ private CollectionUtil() {} // no instance
+
+ /**
+ * Returns a new {@link HashMap} sized to contain {@code size} items without resizing the internal
+ * array.
+ */
+ public static <K, V> HashMap<K, V> newHashMap(int size) {
+ // With Lucene 9.5 - we should replace this with
+ // org.apache.lucene.util.CollectionUtil.newHashMap(int size)
+ // This should be replaced with HashMap.newHashMap when Solr moves to jdk19 minimum version
+ return new HashMap<>((int) (size / 0.75f) + 1);
+ }
+
+ /**
+ * Returns a new {@link HashSet} sized to contain {@code size} items without resizing the internal
+ * array.
+ */
+ public static <E> HashSet<E> newHashSet(int size) {
+ // With Lucene 9.5 - we should replace this with
+ // org.apache.lucene.util.CollectionUtil.newHashSet(int size)
+ // This should be replaced with HashSet.newHashSet when Solr moves to jdk19 minimum version
+ return new HashSet<>((int) (size / 0.75f) + 1);
+ }
+}
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/StrUtils.java b/solr/solrj/src/java/org/apache/solr/common/util/StrUtils.java
index 00afb515a14..684894d5422 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/StrUtils.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/StrUtils.java
@@ -358,4 +358,8 @@ public class StrUtils {
public static String formatString(String pattern, Object... args) {
return new MessageFormat(pattern, Locale.ROOT).format(args);
}
+
+ public static boolean isNullOrEmpty(String string) {
+ return string == null || string.isEmpty();
+ }
}
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/CollectionAdminRequestRequiredParamsTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/CollectionAdminRequestRequiredParamsTest.java
index 77493b85a49..243e16da9fa 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/CollectionAdminRequestRequiredParamsTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/CollectionAdminRequestRequiredParamsTest.java
@@ -24,7 +24,7 @@ import static org.apache.solr.common.params.CoreAdminParams.REPLICA;
import static org.apache.solr.common.params.CoreAdminParams.REQUESTID;
import static org.apache.solr.common.params.CoreAdminParams.SHARD;
-import com.google.common.collect.Sets;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.apache.solr.SolrTestCase;
@@ -239,19 +239,20 @@ public class CollectionAdminRequestRequiredParamsTest extends SolrTestCase {
}
private void assertContainsParams(SolrParams solrParams, String... requiredParams) {
- final Set<String> requiredParamsSet = Sets.newHashSet(requiredParams);
- final Set<String> solrParamsSet = Sets.newHashSet();
+ final Set<String> requiredParamsSet = Set.of(requiredParams);
+ final Set<String> solrParamsSet = new HashSet<>();
for (Iterator<String> iter = solrParams.getParameterNamesIterator(); iter.hasNext(); ) {
solrParamsSet.add(iter.next());
}
assertTrue(
"required params missing: required=" + requiredParamsSet + ", params=" + solrParamsSet,
solrParamsSet.containsAll(requiredParamsSet));
- assertTrue(
+ assertEquals(
"extra parameters included in request: required="
+ requiredParamsSet
+ ", params="
+ solrParams,
- Sets.difference(solrParamsSet, requiredParamsSet).isEmpty());
+ solrParamsSet,
+ requiredParamsSet);
}
}
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java
index b49199f5cd8..df55b78ab1e 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java
@@ -20,7 +20,6 @@ import static org.apache.solr.common.params.UpdateParams.ASSUME_CONTENT_TYPE;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.core.StringContains.containsString;
-import com.google.common.collect.Maps;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -2525,7 +2524,7 @@ public abstract class SolrExampleTests extends SolrExampleTestsBase {
solrClient.commit(true, true);
doc.removeField("single_s");
doc.removeField("multi_ss");
- Map<String, Object> map = Maps.newHashMap();
+ Map<String, Object> map = new HashMap<>();
map.put("set", null);
doc.addField("multi_ss", map);
solrClient.add(doc);
@@ -2548,7 +2547,7 @@ public abstract class SolrExampleTests extends SolrExampleTestsBase {
solrClient.add(doc);
solrClient.commit(true, true);
- Map<String, Object> map = Maps.newHashMap();
+ Map<String, Object> map = new HashMap<>();
map.put("set", null);
doc = new SolrInputDocument();
doc.addField("multi_ss", map);
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientBadInputTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientBadInputTest.java
index 20bd576ab9d..2b71bbf250c 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientBadInputTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientBadInputTest.java
@@ -17,7 +17,6 @@
package org.apache.solr.client.solrj.impl;
-import com.google.common.collect.Lists;
import java.util.ArrayList;
import java.util.List;
import org.apache.solr.client.solrj.SolrClient;
@@ -41,25 +40,25 @@ public class CloudHttp2SolrClientBadInputTest extends SolrCloudTestCase {
try (SolrClient client = getCloudHttp2SolrClient(cluster)) {
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "null"),
+ List.of("ids", "null"),
() -> {
client.deleteById(ANY_COLLECTION, NULL_STR_LIST);
});
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "empty"),
+ List.of("ids", "empty"),
() -> {
client.deleteById(ANY_COLLECTION, EMPTY_STR_LIST);
});
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "null"),
+ List.of("ids", "null"),
() -> {
client.deleteById(ANY_COLLECTION, NULL_STR_LIST, ANY_COMMIT_WITHIN_TIME);
});
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "empty"),
+ List.of("ids", "empty"),
() -> {
client.deleteById(ANY_COLLECTION, EMPTY_STR_LIST, ANY_COMMIT_WITHIN_TIME);
});
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java
index 92409833464..bc4a4941890 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java
@@ -18,9 +18,6 @@ package org.apache.solr.client.solrj.impl;
import static org.apache.solr.client.solrj.impl.CloudSolrClient.RouteResponse;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.net.URL;
@@ -338,7 +335,7 @@ public class CloudHttp2SolrClientTest extends SolrCloudTestCase {
// Track request counts on each node before query calls
ClusterState clusterState = cluster.getSolrClient().getClusterState();
DocCollection col = clusterState.getCollection("routing_collection");
- Map<String, Long> requestCountsMap = Maps.newHashMap();
+ Map<String, Long> requestCountsMap = new HashMap<>();
for (Slice slice : col.getSlices()) {
for (Replica replica : slice.getReplicas()) {
String baseURL = replica.getBaseUrl();
@@ -349,7 +346,7 @@ public class CloudHttp2SolrClientTest extends SolrCloudTestCase {
// Collect the base URLs of the replicas of shard that's expected to be hit
DocRouter router = col.getRouter();
Collection<Slice> expectedSlices = router.getSearchSlicesSingle("0", null, col);
- Set<String> expectedBaseURLs = Sets.newHashSet();
+ Set<String> expectedBaseURLs = new HashSet<>();
for (Slice expectedSlice : expectedSlices) {
for (Replica replica : expectedSlice.getReplicas()) {
String baseURL = replica.getBaseUrl();
@@ -372,7 +369,7 @@ public class CloudHttp2SolrClientTest extends SolrCloudTestCase {
n = random().nextInt(9) + 2;
}
- List<String> sameShardRoutes = Lists.newArrayList();
+ List<String> sameShardRoutes = new ArrayList<>();
List<Slice> expectedSlicesList = List.copyOf(expectedSlices);
sameShardRoutes.add("0");
for (int i = 1; i < n; i++) {
@@ -401,7 +398,7 @@ public class CloudHttp2SolrClientTest extends SolrCloudTestCase {
// no increase in unexpected nodes.
long increaseFromExpectedUrls = 0;
long increaseFromUnexpectedUrls = 0;
- Map<String, Long> numRequestsToUnexpectedUrls = Maps.newHashMap();
+ Map<String, Long> numRequestsToUnexpectedUrls = new HashMap<>();
for (Slice slice : col.getSlices()) {
for (Replica replica : slice.getReplicas()) {
String baseURL = replica.getBaseUrl();
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientBadInputTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientBadInputTest.java
index 4f498a0beb1..e6ba1b863ac 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientBadInputTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientBadInputTest.java
@@ -17,7 +17,6 @@
package org.apache.solr.client.solrj.impl;
-import com.google.common.collect.Lists;
import java.util.ArrayList;
import java.util.List;
import org.apache.solr.client.solrj.SolrClient;
@@ -41,25 +40,25 @@ public class CloudSolrClientBadInputTest extends SolrCloudTestCase {
try (SolrClient client = getCloudSolrClient(cluster)) {
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "null"),
+ List.of("ids", "null"),
() -> {
client.deleteById(ANY_COLLECTION, NULL_STR_LIST);
});
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "empty"),
+ List.of("ids", "empty"),
() -> {
client.deleteById(ANY_COLLECTION, EMPTY_STR_LIST);
});
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "null"),
+ List.of("ids", "null"),
() -> {
client.deleteById(ANY_COLLECTION, NULL_STR_LIST, ANY_COMMIT_WITHIN_TIME);
});
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "empty"),
+ List.of("ids", "empty"),
() -> {
client.deleteById(ANY_COLLECTION, EMPTY_STR_LIST, ANY_COMMIT_WITHIN_TIME);
});
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientCacheTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientCacheTest.java
index ae55799f199..8c3f74bdb13 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientCacheTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientCacheTest.java
@@ -22,7 +22,6 @@ import static org.mockito.Mockito.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import com.google.common.collect.ImmutableSet;
import java.net.ConnectException;
import java.net.SocketException;
import java.util.Collections;
@@ -85,7 +84,7 @@ public class CloudSolrClientCacheTest extends SolrTestCaseJ4 {
new RandomizingCloudSolrClientBuilder(clusterStateProvider)
.withLBHttpSolrClient(mockLbclient)
.build()) {
- livenodes.addAll(ImmutableSet.of("192.168.1.108:7574_solr", "192.168.1.108:8983_solr"));
+ livenodes.addAll(Set.of("192.168.1.108:7574_solr", "192.168.1.108:8983_solr"));
ClusterState cs =
ClusterState.createFromJson(1, coll1State.getBytes(UTF_8), Collections.emptySet(), null);
refs.put(collName, new Ref(collName));
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java
index 125c8a3580d..d033159bc75 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java
@@ -18,9 +18,6 @@ package org.apache.solr.client.solrj.impl;
import static org.apache.solr.client.solrj.SolrRequest.METHOD.POST;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.net.URL;
@@ -339,7 +336,7 @@ public class CloudSolrClientTest extends SolrCloudTestCase {
// Track request counts on each node before query calls
ClusterState clusterState = cluster.getSolrClient().getClusterState();
DocCollection col = clusterState.getCollection("routing_collection");
- Map<String, Long> requestCountsMap = Maps.newHashMap();
+ Map<String, Long> requestCountsMap = new HashMap<>();
for (Slice slice : col.getSlices()) {
for (Replica replica : slice.getReplicas()) {
String baseURL = replica.getBaseUrl();
@@ -350,7 +347,7 @@ public class CloudSolrClientTest extends SolrCloudTestCase {
// Collect the base URLs of the replicas of shard that's expected to be hit
DocRouter router = col.getRouter();
Collection<Slice> expectedSlices = router.getSearchSlicesSingle("0", null, col);
- Set<String> expectedBaseURLs = Sets.newHashSet();
+ Set<String> expectedBaseURLs = new HashSet<>();
for (Slice expectedSlice : expectedSlices) {
for (Replica replica : expectedSlice.getReplicas()) {
expectedBaseURLs.add(replica.getBaseUrl());
@@ -373,7 +370,7 @@ public class CloudSolrClientTest extends SolrCloudTestCase {
}
List<Slice> expectedSlicesList = List.copyOf(expectedSlices);
- List<String> sameShardRoutes = Lists.newArrayList();
+ List<String> sameShardRoutes = new ArrayList<>();
sameShardRoutes.add("0");
for (int i = 1; i < n; i++) {
String shardKey = Integer.toString(i);
@@ -401,7 +398,7 @@ public class CloudSolrClientTest extends SolrCloudTestCase {
// no increase in unexpected nodes.
long increaseFromExpectedUrls = 0;
long increaseFromUnexpectedUrls = 0;
- Map<String, Long> numRequestsToUnexpectedUrls = Maps.newHashMap();
+ Map<String, Long> numRequestsToUnexpectedUrls = new HashMap<>();
for (Slice slice : col.getSlices()) {
for (Replica replica : slice.getReplicas()) {
String baseURL = replica.getBaseUrl();
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClientBadInputTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClientBadInputTest.java
index c6edb82d0c5..0ded24475ab 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClientBadInputTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClientBadInputTest.java
@@ -17,7 +17,6 @@
package org.apache.solr.client.solrj.impl;
-import com.google.common.collect.Lists;
import java.util.ArrayList;
import java.util.List;
import org.apache.solr.SolrJettyTestBase;
@@ -53,25 +52,25 @@ public class ConcurrentUpdateHttp2SolrClientBadInputTest extends SolrJettyTestBa
.build()) {
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "null"),
+ List.of("ids", "null"),
() -> {
client.deleteById(NULL_STR_LIST);
});
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "empty"),
+ List.of("ids", "empty"),
() -> {
client.deleteById(EMPTY_STR_LIST);
});
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "null"),
+ List.of("ids", "null"),
() -> {
client.deleteById(NULL_STR_LIST, ANY_COMMIT_WITHIN_TIME);
});
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "empty"),
+ List.of("ids", "empty"),
() -> {
client.deleteById(EMPTY_STR_LIST, ANY_COMMIT_WITHIN_TIME);
});
@@ -86,25 +85,25 @@ public class ConcurrentUpdateHttp2SolrClientBadInputTest extends SolrJettyTestBa
.build()) {
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "null"),
+ List.of("ids", "null"),
() -> {
client.deleteById(ANY_COLLECTION, NULL_STR_LIST);
});
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "empty"),
+ List.of("ids", "empty"),
() -> {
client.deleteById(ANY_COLLECTION, EMPTY_STR_LIST);
});
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "null"),
+ List.of("ids", "null"),
() -> {
client.deleteById(ANY_COLLECTION, NULL_STR_LIST, ANY_COMMIT_WITHIN_TIME);
});
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "empty"),
+ List.of("ids", "empty"),
() -> {
client.deleteById(ANY_COLLECTION, EMPTY_STR_LIST, ANY_COMMIT_WITHIN_TIME);
});
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientBadInputTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientBadInputTest.java
index 0cecb2f62d1..45f438ab4bf 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientBadInputTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientBadInputTest.java
@@ -17,7 +17,6 @@
package org.apache.solr.client.solrj.impl;
-import com.google.common.collect.Lists;
import java.util.ArrayList;
import java.util.List;
import org.apache.solr.SolrJettyTestBase;
@@ -50,25 +49,25 @@ public class ConcurrentUpdateSolrClientBadInputTest extends SolrJettyTestBase {
ANY_MAX_NUM_THREADS)) {
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "null"),
+ List.of("ids", "null"),
() -> {
client.deleteById(NULL_STR_LIST);
});
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "empty"),
+ List.of("ids", "empty"),
() -> {
client.deleteById(EMPTY_STR_LIST);
});
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "null"),
+ List.of("ids", "null"),
() -> {
client.deleteById(NULL_STR_LIST, ANY_COMMIT_WITHIN_TIME);
});
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "empty"),
+ List.of("ids", "empty"),
() -> {
client.deleteById(EMPTY_STR_LIST, ANY_COMMIT_WITHIN_TIME);
});
@@ -79,25 +78,25 @@ public class ConcurrentUpdateSolrClientBadInputTest extends SolrJettyTestBase {
jetty.getBaseUrl().toString(), ANY_QUEUE_SIZE, ANY_MAX_NUM_THREADS)) {
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "null"),
+ List.of("ids", "null"),
() -> {
client.deleteById(ANY_COLLECTION, NULL_STR_LIST);
});
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "empty"),
+ List.of("ids", "empty"),
() -> {
client.deleteById(ANY_COLLECTION, EMPTY_STR_LIST);
});
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "null"),
+ List.of("ids", "null"),
() -> {
client.deleteById(ANY_COLLECTION, NULL_STR_LIST, ANY_COMMIT_WITHIN_TIME);
});
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "empty"),
+ List.of("ids", "empty"),
() -> {
client.deleteById(ANY_COLLECTION, EMPTY_STR_LIST, ANY_COMMIT_WITHIN_TIME);
});
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientBadInputTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientBadInputTest.java
index cf7721d9b13..fc1fd5c05dc 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientBadInputTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientBadInputTest.java
@@ -17,7 +17,6 @@
package org.apache.solr.client.solrj.impl;
-import com.google.common.collect.Lists;
import java.util.ArrayList;
import java.util.List;
import org.apache.solr.SolrJettyTestBase;
@@ -46,25 +45,25 @@ public class HttpSolrClientBadInputTest extends SolrJettyTestBase {
getHttpSolrClient(jetty.getBaseUrl().toString() + "/" + ANY_COLLECTION)) {
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "null"),
+ List.of("ids", "null"),
() -> {
client.deleteById(NULL_STR_LIST);
});
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "empty"),
+ List.of("ids", "empty"),
() -> {
client.deleteById(EMPTY_STR_LIST);
});
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "null"),
+ List.of("ids", "null"),
() -> {
client.deleteById(NULL_STR_LIST, ANY_COMMIT_WITHIN_TIME);
});
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "empty"),
+ List.of("ids", "empty"),
() -> {
client.deleteById(EMPTY_STR_LIST, ANY_COMMIT_WITHIN_TIME);
});
@@ -73,25 +72,25 @@ public class HttpSolrClientBadInputTest extends SolrJettyTestBase {
try (SolrClient client = getHttpSolrClient(jetty.getBaseUrl().toString())) {
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "null"),
+ List.of("ids", "null"),
() -> {
client.deleteById(ANY_COLLECTION, NULL_STR_LIST);
});
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "empty"),
+ List.of("ids", "empty"),
() -> {
client.deleteById(ANY_COLLECTION, EMPTY_STR_LIST);
});
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "null"),
+ List.of("ids", "null"),
() -> {
client.deleteById(ANY_COLLECTION, NULL_STR_LIST, ANY_COMMIT_WITHIN_TIME);
});
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "empty"),
+ List.of("ids", "empty"),
() -> {
client.deleteById(ANY_COLLECTION, EMPTY_STR_LIST, ANY_COMMIT_WITHIN_TIME);
});
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/LBHttpSolrClientBadInputTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/LBHttpSolrClientBadInputTest.java
index 2b496a71cf1..0d32f168315 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/LBHttpSolrClientBadInputTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/LBHttpSolrClientBadInputTest.java
@@ -17,7 +17,6 @@
package org.apache.solr.client.solrj.impl;
-import com.google.common.collect.Lists;
import java.util.ArrayList;
import java.util.List;
import org.apache.solr.SolrJettyTestBase;
@@ -45,25 +44,25 @@ public class LBHttpSolrClientBadInputTest extends SolrJettyTestBase {
getLBHttpSolrClient(jetty.getBaseUrl().toString() + "/" + ANY_COLLECTION)) {
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "null"),
+ List.of("ids", "null"),
() -> {
client.deleteById(NULL_STR_LIST);
});
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "empty"),
+ List.of("ids", "empty"),
() -> {
client.deleteById(EMPTY_STR_LIST);
});
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "null"),
+ List.of("ids", "null"),
() -> {
client.deleteById(NULL_STR_LIST, ANY_COMMIT_WITHIN_TIME);
});
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "empty"),
+ List.of("ids", "empty"),
() -> {
client.deleteById(EMPTY_STR_LIST, ANY_COMMIT_WITHIN_TIME);
});
@@ -72,25 +71,25 @@ public class LBHttpSolrClientBadInputTest extends SolrJettyTestBase {
try (SolrClient client = getLBHttpSolrClient(jetty.getBaseUrl().toString())) {
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "null"),
+ List.of("ids", "null"),
() -> {
client.deleteById(ANY_COLLECTION, NULL_STR_LIST);
});
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "empty"),
+ List.of("ids", "empty"),
() -> {
client.deleteById(ANY_COLLECTION, EMPTY_STR_LIST);
});
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "null"),
+ List.of("ids", "null"),
() -> {
client.deleteById(ANY_COLLECTION, NULL_STR_LIST, ANY_COMMIT_WITHIN_TIME);
});
assertExceptionThrownWithMessageContaining(
IllegalArgumentException.class,
- Lists.newArrayList("ids", "empty"),
+ List.of("ids", "empty"),
() -> {
client.deleteById(ANY_COLLECTION, EMPTY_STR_LIST, ANY_COMMIT_WITHIN_TIME);
});
diff --git a/solr/solrj/src/test/org/apache/solr/common/util/TestPathTrie.java b/solr/solrj/src/test/org/apache/solr/common/util/TestPathTrie.java
index 35158c231ff..ad7e9066ad3 100644
--- a/solr/solrj/src/test/org/apache/solr/common/util/TestPathTrie.java
+++ b/solr/solrj/src/test/org/apache/solr/common/util/TestPathTrie.java
@@ -21,7 +21,6 @@ import static java.util.Collections.emptyMap;
import static java.util.Collections.singletonMap;
import static org.apache.solr.api.ApiBag.HANDLER_NAME;
-import com.google.common.collect.ImmutableSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
@@ -30,7 +29,7 @@ import org.apache.solr.SolrTestCaseJ4;
public class TestPathTrie extends SolrTestCaseJ4 {
public void testPathTrie() {
- PathTrie<String> pathTrie = new PathTrie<>(ImmutableSet.of("_introspect"));
+ PathTrie<String> pathTrie = new PathTrie<>(Set.of("_introspect"));
pathTrie.insert("/", emptyMap(), "R");
pathTrie.insert("/aa", emptyMap(), "d");
pathTrie.insert("/aa/bb/{cc}/dd", emptyMap(), "a");
@@ -54,7 +53,7 @@ public class TestPathTrie extends SolrTestCaseJ4 {
pathTrie.lookup("/aa", templateValues, subPaths);
assertEquals(3, subPaths.size());
- pathTrie = new PathTrie<>(ImmutableSet.of("_introspect"));
+ pathTrie = new PathTrie<>(Set.of("_introspect"));
pathTrie.insert("/aa/bb/{cc}/tt/*", emptyMap(), "W");
templateValues.clear();
diff --git a/solr/solrj/src/test/org/apache/solr/common/util/TestValidatingJsonMap.java b/solr/solrj/src/test/org/apache/solr/common/util/TestValidatingJsonMap.java
index 759e5638bdd..b70d28f73af 100644
--- a/solr/solrj/src/test/org/apache/solr/common/util/TestValidatingJsonMap.java
+++ b/solr/solrj/src/test/org/apache/solr/common/util/TestValidatingJsonMap.java
@@ -20,10 +20,10 @@ package org.apache.solr.common.util;
import static org.apache.solr.common.util.ValidatingJsonMap.ENUM_OF;
import static org.apache.solr.common.util.ValidatingJsonMap.NOT_NULL;
-import com.google.common.collect.ImmutableSet;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.solr.SolrTestCaseJ4;
public class TestValidatingJsonMap extends SolrTestCaseJ4 {
@@ -46,9 +46,9 @@ public class TestValidatingJsonMap extends SolrTestCaseJ4 {
assertEquals(Boolean.FALSE, m.getBool("b", Boolean.TRUE));
assertEquals(Integer.valueOf(10), m.getInt("i", 0));
- expectThrows(RuntimeException.class, () -> m.getList("l", ENUM_OF, ImmutableSet.of("X", "Z")));
+ expectThrows(RuntimeException.class, () -> m.getList("l", ENUM_OF, Set.of("X", "Z")));
- List<?> l = m.getList("l", ENUM_OF, ImmutableSet.of("X", "Y", "Z"));
+ List<?> l = m.getList("l", ENUM_OF, Set.of("X", "Y", "Z"));
assertEquals(2, l.size());
m.getList("l", NOT_NULL);
assertNotNull(m.getMap("c"));
diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractBackupRepositoryTest.java b/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractBackupRepositoryTest.java
index 9620fe9231c..3bfac1a08cf 100644
--- a/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractBackupRepositoryTest.java
+++ b/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractBackupRepositoryTest.java
@@ -17,7 +17,6 @@
package org.apache.solr.cloud.api.collections;
-import com.google.common.collect.Lists;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URI;
@@ -191,16 +190,16 @@ public abstract class AbstractBackupRepositoryTest extends SolrTestCaseJ4 {
// Ensure nonexistent files are handled differently based on boolean flag param
final URI nonexistentFileUri = repo.resolve(getBaseUri(), "file4.txt");
assertFalse(repo.exists(nonexistentFileUri));
- repo.delete(getBaseUri(), Lists.newArrayList("file4.txt"), IGNORE_NONEXISTENT);
+ repo.delete(getBaseUri(), List.of("file4.txt"), IGNORE_NONEXISTENT);
expectThrows(
IOException.class,
() -> {
- repo.delete(getBaseUri(), Lists.newArrayList("file4.txt"), REPORT_NONEXISTENT);
+ repo.delete(getBaseUri(), List.of("file4.txt"), REPORT_NONEXISTENT);
});
// Delete existing files individually and in 'bulk'
- repo.delete(getBaseUri(), Lists.newArrayList("file1.txt"), REPORT_NONEXISTENT);
- repo.delete(getBaseUri(), Lists.newArrayList("file2.txt", "file3.txt"), REPORT_NONEXISTENT);
+ repo.delete(getBaseUri(), List.of("file1.txt"), REPORT_NONEXISTENT);
+ repo.delete(getBaseUri(), List.of("file2.txt", "file3.txt"), REPORT_NONEXISTENT);
assertFalse(repo.exists(file1Uri));
assertFalse(repo.exists(file2Uri));
assertFalse(repo.exists(file3Uri));
@@ -223,7 +222,7 @@ public abstract class AbstractBackupRepositoryTest extends SolrTestCaseJ4 {
addFile(repo, file1Uri);
addFile(repo, file2Uri);
- final List<String> rootChildren = Lists.newArrayList(repo.listAll(rootUri));
+ final List<String> rootChildren = List.of(repo.listAll(rootUri));
assertEquals(3, rootChildren.size());
assertTrue(rootChildren.contains("otherDir1"));
assertTrue(rootChildren.contains("otherDir2"));
@@ -232,7 +231,7 @@ public abstract class AbstractBackupRepositoryTest extends SolrTestCaseJ4 {
final String[] otherDir2Children = repo.listAll(otherDir2Uri);
assertEquals(0, otherDir2Children.length);
- final List<String> otherDir3Children = Lists.newArrayList(repo.listAll(otherDir3Uri));
+ final List<String> otherDir3Children = List.of(repo.listAll(otherDir3Uri));
assertEquals(2, otherDir3Children.size());
assertTrue(otherDir3Children.contains("file1.txt"));
assertTrue(otherDir3Children.contains("file2.txt"));
diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractCollectionsAPIDistributedZkTestBase.java b/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractCollectionsAPIDistributedZkTestBase.java
index 1ba39b0651c..a414eb5fdbe 100644
--- a/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractCollectionsAPIDistributedZkTestBase.java
+++ b/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractCollectionsAPIDistributedZkTestBase.java
@@ -19,7 +19,6 @@ package org.apache.solr.cloud.api.collections;
import static org.apache.solr.common.cloud.ZkStateReader.CORE_NAME_PROP;
import static org.apache.solr.common.cloud.ZkStateReader.REPLICATION_FACTOR;
-import com.google.common.collect.ImmutableList;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.lang.management.ManagementFactory;
@@ -371,8 +370,7 @@ public abstract class AbstractCollectionsAPIDistributedZkTestBase extends SolrCl
JettySolrRunner jetty1 = cluster.getRandomJetty(random());
JettySolrRunner jetty2 = cluster.getRandomJetty(random());
- List<String> baseUrls =
- ImmutableList.of(jetty1.getBaseUrl().toString(), jetty2.getBaseUrl().toString());
+ List<String> baseUrls = List.of(jetty1.getBaseUrl().toString(), jetty2.getBaseUrl().toString());
CollectionAdminRequest.createCollection("nodeset_collection", "conf", 2, 1)
.setCreateNodeSet(baseUrls.get(0) + "," + baseUrls.get(1))
diff --git a/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java b/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java
index 6a9eeca24eb..662b23f08ea 100644
--- a/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java
+++ b/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java
@@ -16,7 +16,6 @@
*/
package org.apache.solr.util;
-import com.google.common.collect.ImmutableList;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.StringWriter;
@@ -231,7 +230,7 @@ public class TestHarness extends BaseTestHarness {
@Override
public List<CoreDescriptor> discover(CoreContainer cc) {
- return ImmutableList.of(
+ return List.of(
new CoreDescriptor(
coreName,
cc.getCoreRootDirectory().resolve(coreName),