Apache Solr open-source search software
SOLR-18164: Remove use of .singleton (#4222)
Eric Pugh1af33ac6997a
diff --git a/gradle/validation/forbidden-apis/defaults.all.txt b/gradle/validation/forbidden-apis/defaults.all.txtindex eeab02a0dca..72ab6c8ded9 100644--- a/gradle/validation/forbidden-apis/defaults.all.txt+++ b/gradle/validation/forbidden-apis/defaults.all.txt@@ -63,6 +63,15 @@ java.util.Collections#emptySet()@defaultMessage Use Map.of()java.util.Collections#emptyMap()+@defaultMessage Use Set.of()+java.util.Collections#singleton(**)++@defaultMessage Use List.of()+java.util.Collections#singletonList(**)++@defaultMessage Use Map.of()+java.util.Collections#singletonMap(**)+java.util.Locale#forLanguageTag(java.lang.String) @ use new Locale.Builder().setLanguageTag(...).build() which has error handlingjava.util.Locale#toString() @ use Locale#toLanguageTag() for a standardized BCP47 locale namediff --git a/solr/benchmark/src/java/org/apache/solr/bench/generators/Maps.java b/solr/benchmark/src/java/org/apache/solr/bench/generators/Maps.javaindex 9ab4327b2c8..d6b4e9f90d0 100644--- a/solr/benchmark/src/java/org/apache/solr/bench/generators/Maps.java+++ b/solr/benchmark/src/java/org/apache/solr/bench/generators/Maps.java@@ -16,7 +16,6 @@*/package org.apache.solr.bench.generators;-import java.util.Collections;import java.util.Map;import java.util.function.Function;import java.util.stream.Collector;@@ -105,6 +104,6 @@ public class Maps {* @return the map . entry*/static <K, V> Map.Entry<K, V> mapEntry(K k, V v) {- return Collections.singletonMap(k, v).entrySet().iterator().next();+ return Map.of(k, v).entrySet().iterator().next();}}diff --git a/solr/benchmark/src/test/org/apache/solr/bench/SolrBenchStateTest.java b/solr/benchmark/src/test/org/apache/solr/bench/SolrBenchStateTest.javaindex 6aabc965720..8c5e302012d 100644--- a/solr/benchmark/src/test/org/apache/solr/bench/SolrBenchStateTest.java+++ b/solr/benchmark/src/test/org/apache/solr/bench/SolrBenchStateTest.java@@ -26,7 +26,7 @@ import static org.apache.solr.bench.generators.SourceDSL.longs;import static org.apache.solr.bench.generators.SourceDSL.strings;import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering;-import java.util.Collections;+import java.util.List;import java.util.concurrent.TimeUnit;import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.client.solrj.request.QueryRequest;@@ -61,7 +61,7 @@ public class SolrBenchStateTest extends SolrTestCaseJ4 {true,1,new int[] {1},- Collections.singletonList("label"),+ List.of("label"),0,0,new IterationParams(IterationType.WARMUP, 1, TimeValue.milliseconds(10), 1),@@ -71,7 +71,7 @@ public class SolrBenchStateTest extends SolrTestCaseJ4 {TimeUnit.SECONDS,1,"jvm",- Collections.singletonList("jvmArg"),+ List.of("jvmArg"),"jdkVersion","vmName","vmVersion",diff --git a/solr/core/src/java/org/apache/solr/api/AnnotatedApi.java b/solr/core/src/java/org/apache/solr/api/AnnotatedApi.javaindex 76df23de362..68cd3cc4660 100644--- a/solr/core/src/java/org/apache/solr/api/AnnotatedApi.java+++ b/solr/core/src/java/org/apache/solr/api/AnnotatedApi.java@@ -29,7 +29,6 @@ import java.lang.reflect.ParameterizedType;import java.lang.reflect.Type;import java.util.ArrayList;import java.util.Arrays;-import java.util.Collections;import java.util.HashMap;import java.util.LinkedHashMap;import java.util.List;@@ -130,15 +129,15 @@ public class AnnotatedApi extends Api implements PermissionNameProvider, Closeabthrow new RuntimeException("No method with @Command in class: " + klas.getName());}SpecProvider specProvider = readSpec(endPoint, methods);- return Collections.singletonList(new AnnotatedApi(specProvider, endPoint, commands, null));+ return List.of(new AnnotatedApi(specProvider, endPoint, commands, null));} else {List<Api> apis = new ArrayList<>();for (Method m : klas.getMethods()) {EndPoint endPoint = m.getAnnotation(EndPoint.class);if (endPoint == null) continue;Cmd cmd = new Cmd("", obj, m);- SpecProvider specProvider = readSpec(endPoint, Collections.singletonList(m));- apis.add(new AnnotatedApi(specProvider, endPoint, Collections.singletonMap("", cmd), null));+ SpecProvider specProvider = readSpec(endPoint, List.of(m));+ apis.add(new AnnotatedApi(specProvider, endPoint, Map.of("", cmd), null));}if (!allowEmpty && apis.isEmpty()) {throw new RuntimeException("Invalid Class : " + klas.getName() + " No @EndPoints");@@ -170,9 +169,7 @@ public class AnnotatedApi extends Api implements PermissionNameProvider, Closeabmethods.add(method.name());}map.put("methods", methods);- map.put(- "url",- new ValidatingJsonMap(Collections.singletonMap("paths", Arrays.asList(endPoint.path()))));+ map.put("url", new ValidatingJsonMap(Map.of("paths", Arrays.asList(endPoint.path()))));Map<String, Object> cmds = new HashMap<>();for (Method method : m) {@@ -359,7 +356,7 @@ public class AnnotatedApi extends Api implements PermissionNameProvider, Closeabthrow new SolrErrorWrappingException(SolrException.ErrorCode.BAD_REQUEST,"Error executing command",- CommandOperation.captureErrors(Collections.singletonList(cmd)));+ CommandOperation.captureErrors(List.of(cmd)));}}}diff --git a/solr/core/src/java/org/apache/solr/api/ApiBag.java b/solr/core/src/java/org/apache/solr/api/ApiBag.javaindex 89cf2796084..935881369d2 100644--- a/solr/core/src/java/org/apache/solr/api/ApiBag.java+++ b/solr/core/src/java/org/apache/solr/api/ApiBag.java@@ -28,7 +28,6 @@ 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;import java.util.HashSet;import java.util.List;@@ -276,9 +275,9 @@ public class ApiBag {if (commands != null) {ValidatingJsonMap m = commands.getMap(cmd, null);if (m == null) {- specCopy.put("commands", Collections.singletonMap(cmd, "Command not found!"));+ specCopy.put("commands", Map.of(cmd, "Command not found!"));} else {- specCopy.put("commands", Collections.singletonMap(cmd, m));+ specCopy.put("commands", Map.of(cmd, m));}}result = specCopy;@@ -386,7 +385,7 @@ public class ApiBag {final ValidatingJsonMap spec = new ValidatingJsonMap();spec.put("methods", List.of("GET", "POST"));final ValidatingJsonMap urlMap = new ValidatingJsonMap();- urlMap.put("paths", Collections.singletonList("$" + HANDLER_NAME));+ urlMap.put("paths", List.of("$" + HANDLER_NAME));spec.put("url", urlMap);return spec;};@@ -398,7 +397,7 @@ public class ApiBag {public void registerLazy(PluginBag.PluginHolder<SolrRequestHandler> holder, PluginInfo info) {register(new LazyLoadedApi(HANDLER_NAME_SPEC_PROVIDER, holder),- Collections.singletonMap(HANDLER_NAME, info.attributes.get(NAME)));+ Map.of(HANDLER_NAME, info.attributes.get(NAME)));}public static SpecProvider constructSpec(PluginInfo info) {@@ -417,8 +416,7 @@ public class ApiBag {ContentStream stream, Map<String, JsonSchemaValidator> validators, boolean validate) {List<CommandOperation> parsedCommands = null;try {- parsedCommands =- CommandOperation.readCommands(Collections.singleton(stream), new NamedList<>());+ parsedCommands = CommandOperation.readCommands(Set.of(stream), new NamedList<>());} catch (IOException e) {throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unable to parse commands", e);}diff --git a/solr/core/src/java/org/apache/solr/cli/CLIUtils.java b/solr/core/src/java/org/apache/solr/cli/CLIUtils.javaindex 5653bffa897..162e20e274e 100644--- a/solr/core/src/java/org/apache/solr/cli/CLIUtils.java+++ b/solr/core/src/java/org/apache/solr/cli/CLIUtils.java@@ -26,7 +26,7 @@ import java.net.URI;import java.net.URISyntaxException;import java.nio.file.Path;import java.util.Arrays;-import java.util.Collections;+import java.util.List;import java.util.Locale;import java.util.Map;import java.util.Optional;@@ -278,7 +278,7 @@ public final class CLIUtils {public static CloudSolrClient getCloudSolrClient(String zkHost, HttpJettySolrClient.Builder builder) {- return new CloudSolrClient.Builder(Collections.singletonList(zkHost), Optional.empty())+ return new CloudSolrClient.Builder(List.of(zkHost), Optional.empty()).withHttpClientBuilder(builder).build();}diff --git a/solr/core/src/java/org/apache/solr/cli/ExportTool.java b/solr/core/src/java/org/apache/solr/cli/ExportTool.javaindex 6fd43b52a1c..20314c6ee1c 100644--- a/solr/core/src/java/org/apache/solr/cli/ExportTool.java+++ b/solr/core/src/java/org/apache/solr/cli/ExportTool.java@@ -36,7 +36,6 @@ import java.nio.file.Path;import java.time.Instant;import java.time.format.DateTimeFormatter;import java.util.ArrayList;-import java.util.Collections;import java.util.Date;import java.util.HashMap;import java.util.List;@@ -247,9 +246,7 @@ public class ExportTool extends ToolBase {var builder = new HttpJettySolrClient.Builder().withOptionalBasicAuthCredentials(credentials);solrClient =- new CloudSolrClient.Builder(Collections.singletonList(baseurl))- .withHttpClientBuilder(builder)- .build();+ new CloudSolrClient.Builder(List.of(baseurl)).withHttpClientBuilder(builder).build();NamedList<Object> response =solrClient.request(new GenericSolrRequest(diff --git a/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java b/solr/core/src/java/org/apache/solr/cli/RunExampleTool.javaindex e1d002cf21e..8db32fc0b66 100644--- a/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java+++ b/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java@@ -28,8 +28,8 @@ import java.nio.file.Path;import java.nio.file.StandardCopyOption;import java.time.Duration;import java.util.Arrays;-import java.util.Collections;import java.util.HashMap;+import java.util.List;import java.util.Locale;import java.util.Map;import java.util.Optional;@@ -674,7 +674,7 @@ public class RunExampleTool extends ToolBase {/** wait until the number of live nodes == numNodes. */protected void waitToSeeLiveNodes(String zkHost, int numNodes) {try (CloudSolrClient cloudClient =- new CloudSolrClient.Builder(Collections.singletonList(zkHost), Optional.empty()).build()) {+ new CloudSolrClient.Builder(List.of(zkHost), Optional.empty()).build()) {Set<String> liveNodes = cloudClient.getClusterState().getLiveNodes();int numLiveNodes = (liveNodes != null) ? liveNodes.size() : 0;long timeoutNanos = System.nanoTime() + TimeUnit.NANOSECONDS.convert(10, TimeUnit.SECONDS);diff --git a/solr/core/src/java/org/apache/solr/cloud/DistributedClusterStateUpdater.java b/solr/core/src/java/org/apache/solr/cloud/DistributedClusterStateUpdater.javaindex 018d396a80d..cac60d45ce1 100644--- a/solr/core/src/java/org/apache/solr/cloud/DistributedClusterStateUpdater.java+++ b/solr/core/src/java/org/apache/solr/cloud/DistributedClusterStateUpdater.java@@ -17,14 +17,12 @@package org.apache.solr.cloud;-import static java.util.Collections.singletonMap;import static org.apache.solr.cloud.overseer.ZkStateWriter.NO_OP;import static org.apache.solr.common.cloud.ZkStateReader.COLLECTIONS_ZKNODE;import java.lang.invoke.MethodHandles;import java.time.Instant;import java.util.ArrayList;-import java.util.Collections;import java.util.List;import java.util.Map;import java.util.Optional;@@ -547,7 +545,7 @@ public class DistributedClusterStateUpdater {} else {// Collection update or creationDocCollection collection = updatedState.getCollection(updater.getCollectionName());- byte[] stateJson = Utils.toJSON(singletonMap(updater.getCollectionName(), collection));+ byte[] stateJson = Utils.toJSON(Map.of(updater.getCollectionName(), collection));if (updater.isCollectionCreation()) {// The state.json file does not exist yet (more precisely it is assumed not to exist)@@ -939,10 +937,7 @@ public class DistributedClusterStateUpdater {(zkcmd != ZkStateWriter.NO_OP)? clusterState.copyWith(zkcmd.name, zkcmd.collection): null;- replicaOpsList =- (zkcmd.ops != null && zkcmd.ops.get() != null)- ? Collections.singletonList(zkcmd.ops)- : null;+ replicaOpsList = (zkcmd.ops != null && zkcmd.ops.get() != null) ? List.of(zkcmd.ops) : null;} else {computedState = null;replicaOpsList = null;diff --git a/solr/core/src/java/org/apache/solr/cloud/Overseer.java b/solr/core/src/java/org/apache/solr/cloud/Overseer.javaindex 4b29aba7f1b..c1f3eefcdb2 100644--- a/solr/core/src/java/org/apache/solr/cloud/Overseer.java+++ b/solr/core/src/java/org/apache/solr/cloud/Overseer.java@@ -24,7 +24,6 @@ import java.io.Closeable;import java.io.IOException;import java.lang.invoke.MethodHandles;import java.util.ArrayDeque;-import java.util.Collections;import java.util.HashSet;import java.util.List;import java.util.Map;@@ -508,40 +507,39 @@ public class Overseer implements SolrCloseable {if (collectionAction != null) {switch (collectionAction) {case CREATE:- return Collections.singletonList(+ return List.of(new ClusterStateMutator(getSolrCloudManager()).createCollection(clusterState, message));case DELETE:- return Collections.singletonList(+ return List.of(new ClusterStateMutator(getSolrCloudManager()).deleteCollection(clusterState, message));case CREATESHARD:- return Collections.singletonList(+ return List.of(new CollectionMutator(getSolrCloudManager()).createShard(clusterState, message));case DELETESHARD:- return Collections.singletonList(+ return List.of(new CollectionMutator(getSolrCloudManager()).deleteShard(clusterState, message));case ADDREPLICA:- return Collections.singletonList(+ return List.of(new SliceMutator(getSolrCloudManager()).addReplica(clusterState, message));case ADDREPLICAPROP:- return Collections.singletonList(+ return List.of(new ReplicaMutator(getSolrCloudManager()).addReplicaProperty(clusterState, message));case DELETEREPLICAPROP:- return Collections.singletonList(+ return List.of(new ReplicaMutator(getSolrCloudManager()).deleteReplicaProperty(clusterState, message));case BALANCESHARDUNIQUE:ExclusiveSliceProperty dProp = new ExclusiveSliceProperty(clusterState, message);if (dProp.balanceProperty()) {String collName = message.getStr(ZkStateReader.COLLECTION_PROP);- return Collections.singletonList(- new ZkWriteCommand(collName, dProp.getDocCollection()));+ return List.of(new ZkWriteCommand(collName, dProp.getDocCollection()));}break;case MODIFYCOLLECTION:- return Collections.singletonList(+ return List.of(new CollectionMutator(getSolrCloudManager()).modifyCollection(clusterState, message));default:@@ -556,22 +554,22 @@ public class Overseer implements SolrCloseable {}switch (overseerAction) {case STATE:- return Collections.singletonList(+ return List.of(new ReplicaMutator(getSolrCloudManager()).setState(clusterState, message));case LEADER:- return Collections.singletonList(+ return List.of(new SliceMutator(getSolrCloudManager()).setShardLeader(clusterState, message));case DELETECORE:- return Collections.singletonList(+ return List.of(new SliceMutator(getSolrCloudManager()).removeReplica(clusterState, message));case ADDROUTINGRULE:- return Collections.singletonList(+ return List.of(new SliceMutator(getSolrCloudManager()).addRoutingRule(clusterState, message));case REMOVEROUTINGRULE:- return Collections.singletonList(+ return List.of(new SliceMutator(getSolrCloudManager()).removeRoutingRule(clusterState, message));case UPDATESHARDSTATE:- return Collections.singletonList(+ return List.of(new SliceMutator(getSolrCloudManager()).updateShardState(clusterState, message));case QUIT:if (myId.equals(message.get(ID))) {@@ -592,7 +590,7 @@ public class Overseer implements SolrCloseable {}}- return Collections.singletonList(ZkStateWriter.NO_OP);+ return List.of(ZkStateWriter.NO_OP);}private LeaderStatus amILeader() {diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/AddReplicaCmd.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/AddReplicaCmd.javaindex 91392c11146..162dc555a8a 100644--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/AddReplicaCmd.java+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/AddReplicaCmd.java@@ -32,9 +32,9 @@ import java.io.IOException;import java.lang.invoke.MethodHandles;import java.util.ArrayList;import java.util.Collection;-import java.util.Collections;import java.util.List;import java.util.Map;+import java.util.Set;import java.util.concurrent.TimeUnit;import java.util.stream.Collectors;import org.apache.solr.client.solrj.cloud.SolrCloudManager;@@ -287,7 +287,7 @@ public class AddReplicaCmd implements CollApiCmds.CollectionApiCommand {ccc.getZkStateReader(),ccc.getSolrCloudManager().getTimeSource(),collectionName,- Collections.singleton(createReplica.coreName))+ Set.of(createReplica.coreName)).get(createReplica.coreName).getName());diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/Assign.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/Assign.javaindex 4c260c9ab9e..b7f46c078a7 100644--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/Assign.java+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/Assign.java@@ -297,7 +297,7 @@ public class Assign {AssignRequest assignRequest =new AssignRequestBuilder().forCollection(collectionName)- .forShard(Collections.singletonList(shard))+ .forShard(List.of(shard)).assignReplicas(numReplicas).onNodes(createNodeList).build();diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/CollectionHandlingUtils.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/CollectionHandlingUtils.javaindex 6ba0bc39a6f..02320e1e854 100644--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/CollectionHandlingUtils.java+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/CollectionHandlingUtils.java@@ -377,7 +377,7 @@ public class CollectionHandlingUtils {BackupRepository repository, URI backupUri, BackupId backupId, CollectionCommandContext ccc)throws Exception {new DeleteBackupCmd(ccc)- .deleteBackupIds(backupUri, repository, Collections.singleton(backupId), new NamedList<>());+ .deleteBackupIds(backupUri, repository, Set.of(backupId), new NamedList<>());}static void deleteBackup(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.javaindex 53de754285f..5bba5e4affc 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 java.util.Collections;import java.util.HashSet;import java.util.LinkedHashMap;import java.util.List;@@ -179,8 +178,7 @@ public class CreateAliasCmd extends AliasCmd {// Create the collectioncreateCollectionAndWait(adminCmdContext, aliasName, aliasProperties, initialCollectionName, ccc);- validateAllCollectionsExistAndNoDuplicates(- Collections.singletonList(initialCollectionName), zkStateReader);+ validateAllCollectionsExistAndNoDuplicates(List.of(initialCollectionName), zkStateReader);}private void validateAllCollectionsExistAndNoDuplicates(diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.javaindex bc70f3bc955..dd6fdf2da63 100644--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java@@ -32,7 +32,6 @@ import static org.apache.solr.handler.admin.ConfigSetsHandler.getSuffixedNameForimport java.io.IOException;import java.lang.invoke.MethodHandles;import java.util.ArrayList;-import java.util.Collections;import java.util.HashMap;import java.util.LinkedHashMap;import java.util.List;@@ -200,7 +199,7 @@ public class CreateCollectionCmd implements CollApiCmds.CollectionApiCommand {// TODO: Consider doing this for all collections, not just the PRS collections.ZkWriteCommand command =new ClusterStateMutator(ccc.getSolrCloudManager()).createCollection(clusterState, m);- byte[] data = Utils.toJSON(Collections.singletonMap(collectionName, command.collection));+ byte[] data = Utils.toJSON(Map.of(collectionName, command.collection));ccc.getZkStateReader().getZkClient().create(collectionPath, data, CreateMode.PERSISTENT);clusterState = clusterState.copyWith(collectionName, command.collection);newColl = command.collection;@@ -374,9 +373,7 @@ public class CreateCollectionCmd implements CollApiCmds.CollectionApiCommand {// Update the state.json for PRS collection in a single operationif (isPRS) {byte[] data =- Utils.toJSON(- Collections.singletonMap(- collectionName, clusterState.getCollection(collectionName)));+ Utils.toJSON(Map.of(collectionName, clusterState.getCollection(collectionName)));zkStateReader.getZkClient().setData(collectionPath, data);}diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/DeleteBackupCmd.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/DeleteBackupCmd.javaindex dfec0e3bb0e..6b81d28cf0c 100644--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/DeleteBackupCmd.java+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/DeleteBackupCmd.java@@ -270,7 +270,7 @@ public class DeleteBackupCmd implements CollApiCmds.CollectionApiCommand {"Backup ID [" + bid + "] not found; cannot be deleted");}- deleteBackupIds(backupPath, repository, Collections.singleton(backupId), results);+ deleteBackupIds(backupPath, repository, Set.of(backupId), results);}static final class PurgeGraph {diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/DeleteCollectionCmd.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/DeleteCollectionCmd.javaindex 9c292863ece..7e6d9ff3f1f 100644--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/DeleteCollectionCmd.java+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/DeleteCollectionCmd.java@@ -23,7 +23,6 @@ import static org.apache.solr.common.params.CommonParams.NAME;import java.lang.invoke.MethodHandles;import java.util.ArrayList;-import java.util.Collections;import java.util.List;import java.util.Map;import java.util.Objects;@@ -53,7 +52,7 @@ public class DeleteCollectionCmd implements CollApiCmds.CollectionApiCommand {private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());private static final Set<String> okayExceptions =- Collections.singleton(NonExistentCoreException.class.getName());+ Set.of(NonExistentCoreException.class.getName());private final CollectionCommandContext ccc;diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/MigrateReplicasCmd.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/MigrateReplicasCmd.javaindex a45a64f4697..779ab999197 100644--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/MigrateReplicasCmd.java+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/MigrateReplicasCmd.java@@ -19,7 +19,6 @@ package org.apache.solr.cloud.api.collections;import java.util.ArrayList;import java.util.Collection;-import java.util.Collections;import java.util.HashSet;import java.util.List;import java.util.Map;@@ -96,7 +95,7 @@ public class MigrateReplicasCmd implements CollApiCmds.CollectionApiCommand {Assign.AssignRequest assignRequest =new Assign.AssignRequestBuilder().forCollection(sourceReplica.getCollection())- .forShard(Collections.singletonList(sourceReplica.getShard()))+ .forShard(List.of(sourceReplica.getShard())).assignReplicas(ReplicaCount.of(sourceReplica.getType(), 1)).onNodes(targetNodeList).build();diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/MoveReplicaCmd.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/MoveReplicaCmd.javaindex 89a5f32c930..634b2374633 100644--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/MoveReplicaCmd.java+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/MoveReplicaCmd.java@@ -389,8 +389,7 @@ public class MoveReplicaCmd implements CollApiCmds.CollectionApiCommand {log.debug("props {}", props);if (replica.equals(slice.getLeader()) || waitForFinalState) {watcher =- new ActiveReplicaWatcher(- coll.getName(), null, Collections.singletonList(newCoreName), countDownLatch);+ new ActiveReplicaWatcher(coll.getName(), null, List.of(newCoreName), countDownLatch);log.debug("-- registered watcher {}", watcher);ccc.getZkStateReader().registerCollectionStateWatcher(coll.getName(), watcher);}diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/ReplaceNodeCmd.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/ReplaceNodeCmd.javaindex 382f7dd9e2e..26a3730ca10 100644--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/ReplaceNodeCmd.java+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/ReplaceNodeCmd.java@@ -18,7 +18,6 @@package org.apache.solr.cloud.api.collections;import java.util.ArrayList;-import java.util.Collections;import java.util.List;import java.util.Map;import java.util.stream.Collectors;@@ -80,7 +79,7 @@ public class ReplaceNodeCmd implements CollApiCmds.CollectionApiCommand {Assign.AssignRequest assignRequest =new Assign.AssignRequestBuilder().forCollection(sourceReplica.getCollection())- .forShard(Collections.singletonList(sourceReplica.getShard()))+ .forShard(List.of(sourceReplica.getShard())).assignReplicas(ReplicaCount.of(sourceReplica.getType(), 1)).onNodes(ccc.getSolrCloudManager().getClusterStateProvider().getLiveNodes().stream()diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/ReplicaMigrationUtils.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/ReplicaMigrationUtils.javaindex 498695f4f9f..be08e6fc573 100644--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/ReplicaMigrationUtils.java+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/ReplicaMigrationUtils.java@@ -21,7 +21,6 @@ import java.io.IOException;import java.lang.invoke.MethodHandles;import java.util.ArrayList;import java.util.Collection;-import java.util.Collections;import java.util.HashMap;import java.util.List;import java.util.Locale;@@ -159,7 +158,7 @@ public class ReplicaMigrationUtils {new ActiveReplicaWatcher(sourceCollection,null,- Collections.singletonList(addedReplica.getStr(ZkStateReader.CORE_NAME_PROP)),+ List.of(addedReplica.getStr(ZkStateReader.CORE_NAME_PROP)),replicasToRecover);} else {watcher =diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/TimeRoutedAlias.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/TimeRoutedAlias.javaindex fd8b1cab552..8139956116e 100644--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/TimeRoutedAlias.java+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/TimeRoutedAlias.java@@ -36,7 +36,6 @@ import java.time.temporal.ChronoField;import java.time.temporal.ChronoUnit;import java.util.AbstractMap;import java.util.ArrayList;-import java.util.Collections;import java.util.Date;import java.util.HashMap;import java.util.List;@@ -673,7 +672,7 @@ public class TimeRoutedAlias extends RoutedAlias {String mostRecentTime = mostRecentCol.substring(getAliasName().length() + sepLen);Instant parsed = DATE_TIME_FORMATTER.parse(mostRecentTime, Instant::from);String nextCol = calcNextCollection(parsed);- return Collections.singletonList(new Action(this, ActionType.ENSURE_EXISTS, nextCol));+ return List.of(new Action(this, ActionType.ENSURE_EXISTS, nextCol));} else {return List.of();}diff --git a/solr/core/src/java/org/apache/solr/cloud/overseer/ZkStateWriter.java b/solr/core/src/java/org/apache/solr/cloud/overseer/ZkStateWriter.javaindex 9660887b659..5ee0fd03fa3 100644--- a/solr/core/src/java/org/apache/solr/cloud/overseer/ZkStateWriter.java+++ b/solr/core/src/java/org/apache/solr/cloud/overseer/ZkStateWriter.java@@ -16,8 +16,6 @@*/package org.apache.solr.cloud.overseer;-import static java.util.Collections.singletonMap;-import com.codahale.metrics.Timer;import java.lang.invoke.MethodHandles;import java.time.Instant;@@ -287,7 +285,7 @@ public class ZkStateWriter {log.debug("going to delete state.json {}", path);reader.getZkClient().clean(path);} else {- byte[] data = Utils.toJSON(singletonMap(c.getName(), c));+ byte[] data = Utils.toJSON(Map.of(c.getName(), c));if (minStateByteLenForCompression > -1 && data.length > minStateByteLenForCompression) {// When compressing state.json, we expect at least a 10:1 compression ratio.data = compressor.compressBytes(data, data.length / 10);diff --git a/solr/core/src/java/org/apache/solr/cluster/events/impl/CollectionsRepairEventListener.java b/solr/core/src/java/org/apache/solr/cluster/events/impl/CollectionsRepairEventListener.javaindex e52e33d5ff9..0d8c26d6c06 100644--- a/solr/core/src/java/org/apache/solr/cluster/events/impl/CollectionsRepairEventListener.java+++ b/solr/core/src/java/org/apache/solr/cluster/events/impl/CollectionsRepairEventListener.java@@ -21,7 +21,6 @@ import java.io.Closeable;import java.io.IOException;import java.lang.invoke.MethodHandles;import java.util.ArrayList;-import java.util.Collections;import java.util.HashMap;import java.util.HashSet;import java.util.List;@@ -187,7 +186,7 @@ public class CollectionsRepairEventListenerAssign.AssignRequest assignRequest =new Assign.AssignRequestBuilder().forCollection(coll.getName())- .forShard(Collections.singletonList(shard))+ .forShard(List.of(shard)).assignReplicas(types).build();try {diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/PlacementPlugin.java b/solr/core/src/java/org/apache/solr/cluster/placement/PlacementPlugin.javaindex 0739996e118..d2924d344b8 100644--- a/solr/core/src/java/org/apache/solr/cluster/placement/PlacementPlugin.java+++ b/solr/core/src/java/org/apache/solr/cluster/placement/PlacementPlugin.java@@ -18,7 +18,6 @@package org.apache.solr.cluster.placement;import java.util.Collection;-import java.util.Collections;import java.util.List;/**@@ -47,7 +46,7 @@ public interface PlacementPlugin {PlacementRequest placementRequest, PlacementContext placementContext)throws PlacementException, InterruptedException {List<PlacementPlan> placementPlans =- computePlacements(Collections.singletonList(placementRequest), placementContext);+ computePlacements(List.of(placementRequest), placementContext);if (placementPlans == null || placementPlans.isEmpty()) {return null;} else {diff --git a/solr/core/src/java/org/apache/solr/core/MetricsConfig.java b/solr/core/src/java/org/apache/solr/core/MetricsConfig.javaindex 75c98707f77..3320713eb47 100644--- a/solr/core/src/java/org/apache/solr/core/MetricsConfig.java+++ b/solr/core/src/java/org/apache/solr/core/MetricsConfig.java@@ -16,7 +16,7 @@*/package org.apache.solr.core;-import java.util.Collections;+import java.util.Map;/** */public class MetricsConfig {@@ -96,7 +96,7 @@ public class MetricsConfig {public static final String NOOP_IMPL_CLASS = "__noop__";private static final PluginInfo NO_OP_PLUGIN =- new PluginInfo("typeUnused", Collections.singletonMap("class", NOOP_IMPL_CLASS), null, null);+ new PluginInfo("typeUnused", Map.of("class", NOOP_IMPL_CLASS), null, null);public PluginInfo getCounterSupplier() {if (enabled) {diff --git a/solr/core/src/java/org/apache/solr/core/PluginBag.java b/solr/core/src/java/org/apache/solr/core/PluginBag.javaindex 600b9a0b351..30bb8435214 100644--- a/solr/core/src/java/org/apache/solr/core/PluginBag.java+++ b/solr/core/src/java/org/apache/solr/core/PluginBag.java@@ -16,7 +16,6 @@*/package org.apache.solr.core;-import static java.util.Collections.singletonMap;import static org.apache.solr.api.ApiBag.HANDLER_NAME;import java.io.IOException;@@ -253,7 +252,7 @@ public class PluginBag<T> implements AutoCloseable {if (registerApi) {Collection<Api> apis = apiSupport.getApis();if (apis != null) {- Map<String, String> nameSubstitutes = singletonMap(HANDLER_NAME, name);+ Map<String, String> nameSubstitutes = Map.of(HANDLER_NAME, name);for (Api api : apis) {apiBag.register(api, nameSubstitutes);}@@ -414,8 +413,7 @@ public class PluginBag<T> implements AutoCloseable {public PluginHolder(T inst, SolrConfig.SolrPluginInfo info) {this.inst = inst;- pluginInfo =- new PluginInfo(info.tag, Collections.singletonMap("class", inst.getClass().getName()));+ pluginInfo = new PluginInfo(info.tag, Map.of("class", inst.getClass().getName()));}public PluginHolder(PluginInfo info) {diff --git a/solr/core/src/java/org/apache/solr/core/RequestParams.java b/solr/core/src/java/org/apache/solr/core/RequestParams.javaindex f0b491c84a0..469b107e9af 100644--- a/solr/core/src/java/org/apache/solr/core/RequestParams.java+++ b/solr/core/src/java/org/apache/solr/core/RequestParams.java@@ -19,7 +19,6 @@ package org.apache.solr.core;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;@@ -66,7 +65,7 @@ public class RequestParams implements MapSerializable {@SuppressWarnings("unchecked")Map<String, Long> meta = (Map<String, Long>) copy.remove("");if (meta == null && version != null) {- meta = Collections.singletonMap("v", version);+ meta = Map.of("v", version);}Map invariants = (Map) copy.remove(INVARIANTS);Map appends = (Map) copy.remove(APPENDS);@@ -250,7 +249,7 @@ public class RequestParams implements MapSerializable {mergeMaps(Utils.getDeepCopy(defaults, 2), p.defaults),mergeMaps(Utils.getDeepCopy(invariants, 2), p.invariants),mergeMaps(Utils.getDeepCopy(appends, 2), p.appends),- mergeMaps(Utils.getDeepCopy(meta, 2), Collections.singletonMap("v", getVersion() + 1)));+ mergeMaps(Utils.getDeepCopy(meta, 2), Map.of("v", getVersion() + 1)));}private static <K, V> Map<K, V> mergeMaps(Map<K, V> m1, Map<K, V> m2) {diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.javaindex 656df17043a..7e9eaeb01b2 100644--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java@@ -1562,7 +1562,7 @@ public class SolrCore implements SolrInfoBean, Closeable {IndexOutput out = dir.createOutput(tmpFileName, DirectoryFactory.IOCONTEXT_NO_CACHE);os = new OutputStreamWriter(new IndexOutputOutputStream(out), StandardCharsets.UTF_8);p.store(os, IndexFetcher.INDEX_PROPERTIES);- dir.sync(Collections.singleton(tmpFileName));+ dir.sync(Set.of(tmpFileName));} catch (Exception e) {throw new SolrException(ErrorCode.SERVER_ERROR, "Unable to write " + IndexFetcher.INDEX_PROPERTIES, e);@@ -1686,9 +1686,7 @@ public class SolrCore implements SolrInfoBean, Closeable {map.computeIfAbsent(RunUpdateProcessorFactory.PRE_RUN_CHAIN_NAME,- k ->- new UpdateRequestProcessorChain(- Collections.singletonList(new NestedUpdateProcessorFactory()), this));+ k -> new UpdateRequestProcessorChain(List.of(new NestedUpdateProcessorFactory()), this));return map;}diff --git a/solr/core/src/java/org/apache/solr/core/SolrPaths.java b/solr/core/src/java/org/apache/solr/core/SolrPaths.javaindex 8918a321d06..dc2c245eada 100644--- a/solr/core/src/java/org/apache/solr/core/SolrPaths.java+++ b/solr/core/src/java/org/apache/solr/core/SolrPaths.java@@ -20,7 +20,6 @@ package org.apache.solr.core;import java.lang.invoke.MethodHandles;import java.nio.file.FileSystems;import java.nio.file.Path;-import java.util.Collections;import java.util.HashSet;import java.util.Set;import org.apache.commons.exec.OS;@@ -36,7 +35,7 @@ public final class SolrPaths {public static final Path ALL_PATH = Path.of("_ALL_");/** Special singleton path set containing only {@link #ALL_PATH}. */- private static final Set<Path> ALL_PATHS = Collections.singleton(ALL_PATH);+ private static final Set<Path> ALL_PATHS = Set.of(ALL_PATH);private SolrPaths() {} // don't create thisdiff --git a/solr/core/src/java/org/apache/solr/core/backup/BackupManager.java b/solr/core/src/java/org/apache/solr/core/backup/BackupManager.javaindex f47df829f74..3d4ae4d2f0e 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@@ -25,8 +25,8 @@ import java.net.URI;import java.nio.charset.StandardCharsets;import java.nio.file.FileSystems;import java.time.Instant;-import java.util.Collections;import java.util.List;+import java.util.Map;import java.util.Objects;import java.util.Optional;import java.util.Set;@@ -240,8 +240,7 @@ public class BackupManager {throws IOException {URI dest = repository.resolve(getZkStateDir(), COLLECTION_PROPS_FILE);try (OutputStream collectionStateOs = repository.createOutput(dest)) {- collectionStateOs.write(- Utils.toJSON(Collections.singletonMap(collectionName, collectionState)));+ collectionStateOs.write(Utils.toJSON(Map.of(collectionName, collectionState)));}}diff --git a/solr/core/src/java/org/apache/solr/core/backup/ShardBackupMetadata.java b/solr/core/src/java/org/apache/solr/core/backup/ShardBackupMetadata.javaindex 7561e167fda..73e1a13637a 100644--- a/solr/core/src/java/org/apache/solr/core/backup/ShardBackupMetadata.java+++ b/solr/core/src/java/org/apache/solr/core/backup/ShardBackupMetadata.java@@ -28,6 +28,7 @@ import java.util.HashMap;import java.util.List;import java.util.Map;import java.util.Optional;+import java.util.Set;import org.apache.lucene.store.IOContext;import org.apache.lucene.store.IndexInput;import org.apache.solr.common.util.Utils;@@ -111,7 +112,7 @@ public class ShardBackupMetadata {final String filename = shardBackupId.getBackupMetadataFilename();URI fileURI = repository.resolve(folderURI, filename);if (repository.exists(fileURI)) {- repository.delete(folderURI, Collections.singleton(filename));+ repository.delete(folderURI, Set.of(filename));}try (OutputStream os = repository.createOutput(repository.resolve(folderURI, filename))) {diff --git a/solr/core/src/java/org/apache/solr/core/snapshots/SolrSnapshotMetaDataManager.java b/solr/core/src/java/org/apache/solr/core/snapshots/SolrSnapshotMetaDataManager.javaindex 0608be5b41e..d74cbabfc2f 100644--- a/solr/core/src/java/org/apache/solr/core/snapshots/SolrSnapshotMetaDataManager.java+++ b/solr/core/src/java/org/apache/solr/core/snapshots/SolrSnapshotMetaDataManager.java@@ -20,7 +20,6 @@ import java.io.IOException;import java.lang.invoke.MethodHandles;import java.util.ArrayList;import java.util.Collection;-import java.util.Collections;import java.util.HashMap;import java.util.LinkedHashMap;import java.util.List;@@ -347,7 +346,7 @@ public class SolrSnapshotMetaDataManager {}}- dir.sync(Collections.singletonList(fileName));+ dir.sync(List.of(fileName));if (nextWriteGen > 0) {String lastSaveFile = SNAPSHOTS_PREFIX + (nextWriteGen - 1);diff --git a/solr/core/src/java/org/apache/solr/filestore/ClusterFileStore.java b/solr/core/src/java/org/apache/solr/filestore/ClusterFileStore.javaindex c3b76dca4bb..c405fcbcfe9 100644--- a/solr/core/src/java/org/apache/solr/filestore/ClusterFileStore.java+++ b/solr/core/src/java/org/apache/solr/filestore/ClusterFileStore.java@@ -44,6 +44,7 @@ import org.apache.solr.common.params.CommonParams;import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.common.params.SolrParams;import org.apache.solr.common.util.StrUtils;+import org.apache.solr.common.util.SuppressForbidden;import org.apache.solr.core.CoreContainer;import org.apache.solr.core.SolrCore;import org.apache.solr.jersey.PermissionName;@@ -208,6 +209,7 @@ public class ClusterFileStore extends JerseyResource implements ClusterFileStore}@SuppressWarnings("fallthrough")+ @SuppressForbidden(reason = "singletonMap with null value is intentional")public static FileStoreDirectoryListingResponse getMetadata(FileStore.FileType type, String path, FileStore fileStore) {final var dirListingResponse = new FileStoreDirectoryListingResponse();@@ -234,7 +236,7 @@ public class ClusterFileStore extends JerseyResource implements ClusterFileStorefileStore.list(path, null).stream().map(details -> convertToResponse(details)).collect(Collectors.toList());- dirListingResponse.files = Collections.singletonMap(path, directoryContents);+ dirListingResponse.files = Map.of(path, directoryContents);break;}diff --git a/solr/core/src/java/org/apache/solr/handler/ClusterAPI.java b/solr/core/src/java/org/apache/solr/handler/ClusterAPI.javaindex dd7a3a6e383..7bc49e85f2a 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.security.PermissionNameProvider.Name.COLL_EDIT_PERimport static org.apache.solr.security.PermissionNameProvider.Name.COLL_READ_PERM;import java.io.IOException;-import java.util.Collections;import java.util.HashMap;import java.util.List;import java.util.Map;@@ -181,7 +180,7 @@ public class ClusterAPI {.getSolrCloudManager().getDistribStateManager().listData(ZkStateReader.NODE_ROLES + "/" + roleStr + "/" + modeStr);- rsp.add("node-roles", Map.of(roleStr, Collections.singletonMap(modeStr, nodes)));+ rsp.add("node-roles", Map.of(roleStr, Map.of(modeStr, nodes)));}public static List<String> getNodesByRole(diff --git a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.javaindex 27d7f018748..5fffe0099e1 100644--- a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java+++ b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java@@ -301,7 +301,7 @@ public class IndexFetcher {solrCore.getCoreContainer().getAllowListUrlChecker()- .checkAllowList(Collections.singletonList(leaderCoreUrl), clusterState);+ .checkAllowList(List.of(leaderCoreUrl), clusterState);} catch (MalformedURLException e) {throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Malformed 'leaderUrl' " + leaderCoreUrl, e);@@ -944,7 +944,7 @@ public class IndexFetcher {try (Writer outFile =new OutputStreamWriter(new IndexOutputOutputStream(out), StandardCharsets.UTF_8)) {props.store(outFile, "Replication details");- dir.sync(Collections.singleton(tmpFileName));+ dir.sync(Set.of(tmpFileName));}solrCore.getDirectoryFactory().renameWithOverwrite(dir, tmpFileName, REPLICATION_PROPERTIES);@@ -1843,7 +1843,7 @@ public class IndexFetcher {@Overridepublic void sync() throws IOException {- copy2Dir.sync(Collections.singleton(saveAs));+ copy2Dir.sync(Set.of(saveAs));}@Overridediff --git a/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java b/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.javaindex 684250e35d5..f1a87df3e0b 100644--- a/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java+++ b/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java@@ -21,10 +21,10 @@ import java.io.Reader;import java.lang.invoke.MethodHandles;import java.util.ArrayList;import java.util.Collection;-import java.util.Collections;import java.util.Iterator;import java.util.List;import java.util.Map;+import java.util.Set;import java.util.regex.Pattern;import net.jcip.annotations.NotThreadSafe;import org.apache.lucene.document.Document;@@ -447,7 +447,7 @@ public class MoreLikeThisHandler extends RequestHandlerBase {buffered.append(chunk, 0, len);}- Collection<Object> streamValue = Collections.singleton(buffered.get().toString());+ Collection<Object> streamValue = Set.of(buffered.get().toString());Map<String, Collection<Object>> multifieldDoc = CollectionUtil.newHashMap(fields.length);for (String field : fields) {multifieldDoc.put(field, streamValue);diff --git a/solr/core/src/java/org/apache/solr/handler/RequestHandlerBase.java b/solr/core/src/java/org/apache/solr/handler/RequestHandlerBase.javaindex 4946bbcaa35..e7322360ea5 100644--- a/solr/core/src/java/org/apache/solr/handler/RequestHandlerBase.java+++ b/solr/core/src/java/org/apache/solr/handler/RequestHandlerBase.java@@ -24,8 +24,8 @@ import io.opentelemetry.api.common.Attributes;import java.io.IOException;import java.lang.invoke.MethodHandles;import java.util.Collection;-import java.util.Collections;import java.util.Optional;+import java.util.Set;import org.apache.solr.api.Api;import org.apache.solr.api.ApiBag;import org.apache.solr.api.ApiSupport;@@ -412,8 +412,7 @@ public abstract class RequestHandlerBase@Overridepublic Collection<Api> getApis() {- return Collections.singleton(- new ApiBag.ReqHandlerToApi(this, ApiBag.constructSpec(pluginInfo)));+ return Set.of(new ApiBag.ReqHandlerToApi(this, ApiBag.constructSpec(pluginInfo)));}/**diff --git a/solr/core/src/java/org/apache/solr/handler/SchemaHandler.java b/solr/core/src/java/org/apache/solr/handler/SchemaHandler.javaindex 38060104bc9..bf2ef121c31 100644--- a/solr/core/src/java/org/apache/solr/handler/SchemaHandler.java+++ b/solr/core/src/java/org/apache/solr/handler/SchemaHandler.java@@ -16,7 +16,6 @@*/package org.apache.solr.handler;-import static java.util.Collections.singletonMap;import static org.apache.solr.common.params.CommonParams.JSON;import static org.apache.solr.schema.IndexSchema.SchemaProps.Handler.COPY_FIELDS;import static org.apache.solr.schema.IndexSchema.SchemaProps.Handler.DYNAMIC_FIELDS;@@ -198,10 +197,10 @@ public class SchemaHandler extends RequestHandlerBaseString realName = parts.get(1);String pathParam = level2.get(realName); // Might be null- if (parts.size() > 2) {+ if (parts.size() > 2 && pathParam != null) {req.setParams(SolrParams.wrapDefaults(- new MapSolrParams(singletonMap(pathParam, parts.get(2))), req.getParams()));+ new MapSolrParams(Map.of(pathParam, parts.get(2))), req.getParams()));}switch (realName) {case "fields":diff --git a/solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java b/solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.javaindex cba47bad98d..e27bfc0e317 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 java.util.Collections.singletonList;import static org.apache.solr.common.params.CoreAdminParams.NAME;import static org.apache.solr.common.util.StrUtils.formatString;import static org.apache.solr.core.ConfigOverlay.NOT_EDITABLE;@@ -423,7 +422,7 @@ public class SolrConfigHandler extends RequestHandlerBase}} catch (Exception e) {resp.setException(e);- resp.add(CommandOperation.ERR_MSGS, singletonList(SchemaManager.getErrorStr(e)));+ resp.add(CommandOperation.ERR_MSGS, List.of(SchemaManager.getErrorStr(e)));}}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.javaindex ed1fdbebfeb..0244726235b 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@@ -38,6 +38,7 @@ import org.apache.solr.client.solrj.request.ApiMapping.V2EndPoint;import org.apache.solr.common.SolrException;import org.apache.solr.common.params.SolrParams;import org.apache.solr.common.util.CommandOperation;+import org.apache.solr.common.util.SuppressForbidden;import org.apache.solr.common.util.Utils;import org.apache.solr.request.SolrQueryRequest;import org.apache.solr.response.SolrQueryResponse;@@ -103,7 +104,7 @@ public abstract class BaseHandlerApiSupport implements ApiSupport {if (commands.size() > 1) {for (ApiCommand command : commands) {if (command.meta().getName().equals(req.getPath())) {- commands = Collections.singletonList(command);+ commands = List.of(command);break;}}@@ -126,6 +127,8 @@ public abstract class BaseHandlerApiSupport implements ApiSupport {}/** Wrapper for SolrParams that wraps V2 params and exposes them as V1 params. */+ @SuppressForbidden(+ reason = "CommandOperation.getCommandData can return null when there is no payload")private static void wrapParams(final SolrQueryRequest req,final CommandOperation co,diff --git a/solr/core/src/java/org/apache/solr/handler/admin/ColStatus.java b/solr/core/src/java/org/apache/solr/handler/admin/ColStatus.javaindex ece36d05ad7..d0bfbe94ae2 100644--- a/solr/core/src/java/org/apache/solr/handler/admin/ColStatus.java+++ b/solr/core/src/java/org/apache/solr/handler/admin/ColStatus.java@@ -20,7 +20,6 @@ package org.apache.solr.handler.admin;import java.io.IOException;import java.lang.invoke.MethodHandles;import java.util.Collection;-import java.util.Collections;import java.util.Map;import java.util.Set;import java.util.TreeMap;@@ -78,7 +77,7 @@ public class ColStatus {if (col == null) {collections = clusterState.getCollectionNames();} else {- collections = Collections.singleton(col);+ collections = Set.of(col);}boolean withFieldInfo = props.getBool(FIELD_INFO_PROP, false);boolean withCoreInfo = props.getBool(CORE_INFO_PROP, false);diff --git a/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandlerLocal.java b/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandlerLocal.javaindex 724c2c16da3..79d86c936f9 100644--- a/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandlerLocal.java+++ b/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandlerLocal.java@@ -23,7 +23,7 @@ import java.io.OutputStream;import java.lang.invoke.MethodHandles;import java.nio.file.Files;import java.nio.file.Path;-import java.util.Collections;+import java.util.List;import org.apache.solr.common.SolrException;import org.apache.solr.common.util.CommandOperation;import org.apache.solr.common.util.Utils;@@ -69,7 +69,7 @@ public class SecurityConfHandlerLocal extends SecurityConfHandler {SecurityConfig props = getSecurityConfig(false);Object o = props.getData().get(key);if (o == null) {- rsp.add(CommandOperation.ERR_MSGS, Collections.singletonList("No " + key + " configured"));+ rsp.add(CommandOperation.ERR_MSGS, List.of("No " + key + " configured"));} else {rsp.add(key + ".enabled", getPlugin(key) != null);rsp.add(key, o);diff --git a/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandlerZk.java b/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandlerZk.javaindex 09d8cbcddf6..b9cd18ae3a3 100644--- a/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandlerZk.java+++ b/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandlerZk.java@@ -22,7 +22,7 @@ import static org.apache.solr.common.cloud.ZkStateReader.SOLR_SECURITY_CONF_PATHimport java.io.IOException;import java.lang.invoke.MethodHandles;-import java.util.Collections;+import java.util.List;import org.apache.solr.common.SolrException;import org.apache.solr.common.cloud.ZkStateReader;import org.apache.solr.common.util.CommandOperation;@@ -63,7 +63,7 @@ public class SecurityConfHandlerZk extends SecurityConfHandler {cores.getZkController().getZkStateReader().getSecurityProps(false);Object o = map == null ? null : map.data.get(key);if (o == null) {- rsp.add(CommandOperation.ERR_MSGS, Collections.singletonList("No " + key + " configured"));+ rsp.add(CommandOperation.ERR_MSGS, List.of("No " + key + " configured"));} else {rsp.add(key + ".enabled", getPlugin(key) != null);rsp.add(key, o);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.javaindex c23b3891639..2bc9ae3d0bb 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@@ -444,11 +444,11 @@ public class QueryElevationComponent extends SearchComponent implements SolrCoreString e = DOMUtil.getAttr(child, EXCLUDE, null);if (e != null) {if (Boolean.valueOf(e)) {- elevationBuilder.addExcludedIds(Collections.singleton(id));+ elevationBuilder.addExcludedIds(Set.of(id));continue;}}- elevationBuilder.addElevatedIds(Collections.singletonList(id));+ elevationBuilder.addElevatedIds(List.of(id));}// It is allowed to define multiple times different elevations for the same query. In thisdiff --git a/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java b/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.javaindex d1dc15d9a49..e08fe5d3ee4 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@@ -584,10 +584,7 @@ public class RealTimeGetComponent extends SearchComponent {searcher.getDocFetcher().decorateDocValueFields(- doc,- docid,- Collections.singleton(VERSION_FIELD),- new DocValuesIteratorCache(searcher, false));+ doc, docid, Set.of(VERSION_FIELD), new DocValuesIteratorCache(searcher, false));}long docVersion = (long) doc.getFirstValue(VERSION_FIELD);diff --git a/solr/core/src/java/org/apache/solr/handler/component/ResponseLogComponent.java b/solr/core/src/java/org/apache/solr/handler/component/ResponseLogComponent.javaindex 6d8ee1957fb..fa7377ed6f1 100644--- a/solr/core/src/java/org/apache/solr/handler/component/ResponseLogComponent.java+++ b/solr/core/src/java/org/apache/solr/handler/component/ResponseLogComponent.java@@ -17,7 +17,6 @@package org.apache.solr.handler.component;import java.io.IOException;-import java.util.Collections;import java.util.Set;import org.apache.solr.common.params.SolrParams;import org.apache.solr.response.ResultContext;@@ -90,7 +89,7 @@ public class ResponseLogComponent extends SearchComponent {StringBuilder sb = new StringBuilder();- Set<String> fields = Collections.singleton(schema.getUniqueKeyField().getName());+ Set<String> fields = Set.of(schema.getUniqueKeyField().getName());SolrDocumentFetcher docFetcher = searcher.getDocFetcher();for (DocIterator iter = dl.iterator(); iter.hasNext(); ) {@@ -106,7 +105,7 @@ public class ResponseLogComponent extends SearchComponent {throws IOException {StringBuilder sb = new StringBuilder();- Set<String> fields = Collections.singleton(schema.getUniqueKeyField().getName());+ Set<String> fields = Set.of(schema.getUniqueKeyField().getName());SolrDocumentFetcher docFetcher = searcher.getDocFetcher();for (DocIterator iter = dl.iterator(); iter.hasNext(); ) {sb.append(schema.printableUniqueKey(docFetcher.doc(iter.nextDoc(), fields)))diff --git a/solr/core/src/java/org/apache/solr/handler/designer/DefaultSampleDocumentsLoader.java b/solr/core/src/java/org/apache/solr/handler/designer/DefaultSampleDocumentsLoader.javaindex 4dff58a7ba2..785be168ca9 100644--- a/solr/core/src/java/org/apache/solr/handler/designer/DefaultSampleDocumentsLoader.java+++ b/solr/core/src/java/org/apache/solr/handler/designer/DefaultSampleDocumentsLoader.java@@ -28,7 +28,6 @@ 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.List;import java.util.Map;import java.util.NoSuchElementException;@@ -213,7 +212,7 @@ public class DefaultSampleDocumentsLoader implements SampleDocumentsLoader {if (isJsonLines) {docs = loadJsonLines(lines);} else {- docs = Collections.singletonList((Map<String, Object>) json);+ docs = List.of((Map<String, Object>) json);}} else {throw new SolrException(diff --git a/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerAPI.java b/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerAPI.javaindex 91f8e7e57d2..bced3660ef7 100644--- a/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerAPI.java+++ b/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerAPI.java@@ -222,7 +222,7 @@ public class SchemaDesignerAPI implements SchemaDesignerConstants {}String stringData =data != null && data.length > 0 ? new String(data, StandardCharsets.UTF_8) : "";- rsp.getValues().addAll(Collections.singletonMap(file, stringData));+ rsp.getValues().addAll(Map.of(file, stringData));}@EndPoint(method = POST, path = "/schema-designer/file", permission = CONFIG_EDIT_PERM)@@ -358,16 +358,14 @@ public class SchemaDesignerAPI implements SchemaDesignerConstants {public void listCollectionsForConfig(SolrQueryRequest req, SolrQueryResponse rsp) {final String configSet = getRequiredParam(CONFIG_SET_PARAM, req);rsp.getValues()- .addAll(- Collections.singletonMap(- "collections", configSetHelper.listCollectionsForConfig(configSet)));+ .addAll(Map.of("collections", configSetHelper.listCollectionsForConfig(configSet)));}// CONFIG_EDIT_PERM is required here since this endpoint is used by the UI to determine if the// user has access to the Schema Designer UI@EndPoint(method = GET, path = "/schema-designer/configs", permission = CONFIG_EDIT_PERM)public void listConfigs(SolrQueryRequest req, SolrQueryResponse rsp) throws IOException {- rsp.getValues().addAll(Collections.singletonMap("configSets", listEnabledConfigs()));+ rsp.getValues().addAll(Map.of("configSets", listEnabledConfigs()));}protected Map<String, Integer> listEnabledConfigs() throws IOException {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.javaindex 23729eb21a1..907e0933acf 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@@ -41,7 +41,6 @@ import java.nio.file.attribute.BasicFileAttributes;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;@@ -179,7 +178,7 @@ class SchemaDesignerConfigSetHelper implements SchemaDesignerConstants {Object dest = map.get("dest");List<String> destFields = null;if (dest instanceof String) {- destFields = Collections.singletonList((String) dest);+ destFields = List.of((String) dest);} else if (dest instanceof List) {destFields = (List<String>) dest;} else if (dest instanceof Collection) {diff --git a/solr/core/src/java/org/apache/solr/handler/export/ExportWriter.java b/solr/core/src/java/org/apache/solr/handler/export/ExportWriter.javaindex 142c6617632..2b9731152fe 100644--- a/solr/core/src/java/org/apache/solr/handler/export/ExportWriter.java+++ b/solr/core/src/java/org/apache/solr/handler/export/ExportWriter.java@@ -17,9 +17,6 @@package org.apache.solr.handler.export;-import static java.util.Collections.singletonList;-import static java.util.Collections.singletonMap;-import java.io.Closeable;import java.io.EOFException;import java.io.IOException;@@ -180,14 +177,14 @@ public class ExportWriter implements SolrCore.RawWriter, Closeable {throws IOException {w.writeMap(mw -> {- mw.put("responseHeader", singletonMap("status", 400))+ mw.put("responseHeader", Map.of("status", 400)).put("response",Map.of("numFound",0,"docs",- singletonList(singletonMap("EXCEPTION", e.getMessage()))));+ List.of(Map.of("EXCEPTION", String.valueOf(e.getMessage())))));});if (logException) {log.error("Exception", e);@@ -339,7 +336,7 @@ public class ExportWriter implements SolrCore.RawWriter, Closeable {try {writer.writeMap(m -> {- m.put("responseHeader", singletonMap("status", 0));+ m.put("responseHeader", Map.of("status", 0));m.put("response",(MapWriter)diff --git a/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.java b/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.javaindex 0d16ec02b0d..3f061375d66 100644--- a/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.java+++ b/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.java@@ -30,7 +30,6 @@ 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.List;@@ -160,7 +159,7 @@ public class PackageManager implements Closeable {new V2Request.Builder(PackageUtils.PACKAGE_PATH).forceV2(true).withMethod(SolrRequest.METHOD.POST)- .withPayload(Collections.singletonMap("delete", del))+ .withPayload(Map.of("delete", del)).build();try {@@ -438,12 +437,11 @@ public class PackageManager implements Closeable {PackageUtils.getCollectionParamsPath(collection),getMapper().writeValueAsString(- Collections.singletonMap(+ Map.of(packageParamsExist ? "update" : "set",- Collections.singletonMap(+ Map.of("packages",- Collections.singletonMap(- packageInstance.name, collectionParameterOverrides)))));+ Map.of(packageInstance.name, collectionParameterOverrides)))));} catch (Exception e) {throw new SolrException(ErrorCode.SERVER_ERROR, e);}diff --git a/solr/core/src/java/org/apache/solr/parser/SolrQueryParserBase.java b/solr/core/src/java/org/apache/solr/parser/SolrQueryParserBase.javaindex 044f56211d0..42cedf82979 100644--- a/solr/core/src/java/org/apache/solr/parser/SolrQueryParserBase.java+++ b/solr/core/src/java/org/apache/solr/parser/SolrQueryParserBase.java@@ -20,7 +20,6 @@ import static org.apache.solr.parser.SolrQueryParserBase.SynonymQueryStyle.AS_SAimport java.io.StringReader;import java.util.ArrayList;-import java.util.Collections;import java.util.EnumSet;import java.util.HashMap;import java.util.Iterator;@@ -187,7 +186,7 @@ public abstract class SolrQueryParserBase extends QueryBuilder {private final List<String> externalVals;public RawQuery(SchemaField sfield, String externalVal) {- this(sfield, Collections.singletonList(externalVal));+ this(sfield, List.of(externalVal));}public RawQuery(SchemaField sfield, List<String> externalVals) {diff --git a/solr/core/src/java/org/apache/solr/pkg/PackageAPI.java b/solr/core/src/java/org/apache/solr/pkg/PackageAPI.javaindex 24ea22cd387..c2d6e0cbeea 100644--- a/solr/core/src/java/org/apache/solr/pkg/PackageAPI.java+++ b/solr/core/src/java/org/apache/solr/pkg/PackageAPI.java@@ -402,7 +402,7 @@ public class PackageAPI {if (name == null) {rsp.add("result", pkgs);} else {- rsp.add("result", Collections.singletonMap(name, pkgs.packages.get(name)));+ rsp.add("result", Map.of(name, pkgs.packages.get(name)));}}diff --git a/solr/core/src/java/org/apache/solr/pkg/PackagePluginHolder.java b/solr/core/src/java/org/apache/solr/pkg/PackagePluginHolder.javaindex b0731d05095..419cb033835 100644--- a/solr/core/src/java/org/apache/solr/pkg/PackagePluginHolder.java+++ b/solr/core/src/java/org/apache/solr/pkg/PackagePluginHolder.java@@ -19,7 +19,6 @@ package org.apache.solr.pkg;import java.io.IOException;import java.lang.invoke.MethodHandles;-import java.util.Collections;import java.util.Map;import org.apache.lucene.util.ResourceLoaderAware;import org.apache.solr.common.MapWriter;@@ -60,7 +59,7 @@ public class PackagePluginHolder<T> extends PluginBag.PluginHolder<T> {@Overridepublic Map<String, PackageAPI.PkgVersion> packageDetails() {- return Collections.singletonMap(info.cName.original, pkgVersion.getPkgVersion());+ return Map.of(info.cName.original, pkgVersion.getPkgVersion());}@Override@@ -77,8 +76,7 @@ public class PackagePluginHolder<T> extends PluginBag.PluginHolder<T> {public static <T> PluginBag.PluginHolder<T> createHolder(T inst, Class<T> type) {SolrConfig.SolrPluginInfo plugin = SolrConfig.classVsSolrPluginInfo.get(type.getName());- PluginInfo info =- new PluginInfo(plugin.tag, Collections.singletonMap("class", inst.getClass().getName()));+ PluginInfo info = new PluginInfo(plugin.tag, Map.of("class", inst.getClass().getName()));return new PluginBag.PluginHolder<>(info, inst);}diff --git a/solr/core/src/java/org/apache/solr/pkg/SolrPackageLoader.java b/solr/core/src/java/org/apache/solr/pkg/SolrPackageLoader.javaindex fdfb9881964..364bbb919bc 100644--- a/solr/core/src/java/org/apache/solr/pkg/SolrPackageLoader.java+++ b/solr/core/src/java/org/apache/solr/pkg/SolrPackageLoader.java@@ -145,7 +145,7 @@ public class SolrPackageLoader implements Closeable {public void notifyListeners(String pkg) {SolrPackage p = packageClassLoaders.get(pkg);if (p != null) {- List<SolrPackage> l = Collections.singletonList(p);+ List<SolrPackage> l = List.of(p);for (SolrCore core : coreContainer.getCores()) {core.getPackageListeners().packagesUpdated(l);}diff --git a/solr/core/src/java/org/apache/solr/response/TextResponseWriter.java b/solr/core/src/java/org/apache/solr/response/TextResponseWriter.javaindex a7017f5d4fb..6809e99e936 100644--- a/solr/core/src/java/org/apache/solr/response/TextResponseWriter.java+++ b/solr/core/src/java/org/apache/solr/response/TextResponseWriter.java@@ -20,7 +20,6 @@ import java.io.IOException;import java.io.Writer;import java.util.Calendar;import java.util.Collection;-import java.util.Collections;import java.util.HashSet;import java.util.Iterator;import java.util.Set;@@ -87,9 +86,7 @@ public abstract class TextResponseWriter implements TextWriter {this.rawReturnFields = NO_RAW_FIELDS;} else {this.rawFields =- rawFields.size() == 1- ? Collections.singleton(rawFields.iterator().next())- : new HashSet<>(rawFields);+ rawFields.size() == 1 ? Set.of(rawFields.iterator().next()) : new HashSet<>(rawFields);this.rawShim = new RawShimTextResponseWriter(this);this.rawReturnFields = returnFields;}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.javaindex 7f671ad3102..b165b81e923 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@@ -17,7 +17,6 @@package org.apache.solr.response.transform;import java.util.Collection;-import java.util.Collections;import java.util.Map;import java.util.Set;import org.apache.solr.common.SolrDocument;@@ -123,7 +122,7 @@ public class RawValueTransformerFactory extends TransformerFactory@Overridepublic Collection<String> getRawFields() {- return Collections.singleton(display);+ return Set.of(display);}@Overridediff --git a/solr/core/src/java/org/apache/solr/schema/BinaryField.java b/solr/core/src/java/org/apache/solr/schema/BinaryField.javaindex 6738f448086..d752d20916a 100644--- a/solr/core/src/java/org/apache/solr/schema/BinaryField.java+++ b/solr/core/src/java/org/apache/solr/schema/BinaryField.java@@ -22,7 +22,6 @@ import java.nio.ByteBuffer;import java.nio.charset.StandardCharsets;import java.util.ArrayList;import java.util.Base64;-import java.util.Collections;import java.util.List;import org.apache.lucene.document.BinaryDocValuesField;import org.apache.lucene.document.StoredField;@@ -150,7 +149,7 @@ public class BinaryField extends FieldType {fval = docval;}- return Collections.singletonList(fval);+ return List.of(fval);}@Overridediff --git a/solr/core/src/java/org/apache/solr/schema/BoolField.java b/solr/core/src/java/org/apache/solr/schema/BoolField.javaindex 65c86f919d6..cefd4a0bdbe 100644--- a/solr/core/src/java/org/apache/solr/schema/BoolField.java+++ b/solr/core/src/java/org/apache/solr/schema/BoolField.java@@ -18,7 +18,6 @@ package org.apache.solr.schema;import java.io.IOException;import java.util.ArrayList;-import java.util.Collections;import java.util.List;import java.util.Map;import org.apache.lucene.analysis.Analyzer;@@ -205,7 +204,7 @@ public class BoolField extends PrimitiveFieldType {fval = docval;}- return Collections.singletonList(fval);+ return List.of(fval);}@Overridediff --git a/solr/core/src/java/org/apache/solr/schema/CollationField.java b/solr/core/src/java/org/apache/solr/schema/CollationField.javaindex e55474f8953..ce4a1828dc7 100644--- a/solr/core/src/java/org/apache/solr/schema/CollationField.java+++ b/solr/core/src/java/org/apache/solr/schema/CollationField.java@@ -23,7 +23,6 @@ import java.text.Collator;import java.text.ParseException;import java.text.RuleBasedCollator;import java.util.ArrayList;-import java.util.Collections;import java.util.List;import java.util.Locale;import java.util.Map;@@ -260,7 +259,7 @@ public class CollationField extends FieldType {}return fields;} else {- return Collections.singletonList(createField(field, value));+ return List.of(createField(field, value));}}diff --git a/solr/core/src/java/org/apache/solr/schema/FieldType.java b/solr/core/src/java/org/apache/solr/schema/FieldType.javaindex 0f72e49747a..1452233beee 100644--- a/solr/core/src/java/org/apache/solr/schema/FieldType.java+++ b/solr/core/src/java/org/apache/solr/schema/FieldType.java@@ -348,7 +348,7 @@ public abstract class FieldType extends FieldProperties {throw new UnsupportedOperationException("This field type does not support doc values: " + this);}- return f == null ? List.of() : Collections.singletonList(f);+ return f == null ? List.of() : List.of(f);}/**diff --git a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java b/solr/core/src/java/org/apache/solr/schema/IndexSchema.javaindex 3571dd2a07d..ff81ecc84b3 100644--- a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java+++ b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java@@ -17,8 +17,6 @@package org.apache.solr.schema;import static java.util.Arrays.asList;-import static java.util.Collections.singletonList;-import static java.util.Collections.singletonMap;import java.io.IOException;import java.io.Writer;@@ -1801,7 +1799,7 @@ public class IndexSchema {* @see #newField(String, String, Map)*/public IndexSchema addField(SchemaField newField, boolean persist) {- return addFields(Collections.singletonList(newField), Map.of(), persist);+ return addFields(List.of(newField), Map.of(), persist);}public IndexSchema addField(SchemaField newField) {@@ -1819,8 +1817,7 @@ public class IndexSchema {* @see #newField(String, String, Map)*/public IndexSchema addField(SchemaField newField, Collection<String> copyFieldNames) {- return addFields(- singletonList(newField), singletonMap(newField.getName(), copyFieldNames), true);+ return addFields(List.of(newField), Map.of(newField.getName(), copyFieldNames), true);}/**diff --git a/solr/core/src/java/org/apache/solr/schema/SchemaManager.java b/solr/core/src/java/org/apache/solr/schema/SchemaManager.javaindex fc2d4bcb49e..a65eb18df6a 100644--- a/solr/core/src/java/org/apache/solr/schema/SchemaManager.java+++ b/solr/core/src/java/org/apache/solr/schema/SchemaManager.java@@ -16,9 +16,6 @@*/package org.apache.solr.schema;-import static java.util.Collections.singleton;-import static java.util.Collections.singletonList;-import static java.util.Collections.singletonMap;import static org.apache.solr.client.api.model.SchemaChange.OPERATION_TYPE_PROP;import static org.apache.solr.common.util.CommandOperation.ERR_MSGS;import static org.apache.solr.schema.IndexSchema.MAX_CHARS;@@ -37,6 +34,7 @@ import java.util.Arrays;import java.util.HashMap;import java.util.List;import java.util.Map;+import java.util.Set;import java.util.concurrent.TimeUnit;import org.apache.solr.client.api.model.AddCopyFieldOperation;import org.apache.solr.client.api.model.DeleteCopyFieldOperation;@@ -102,7 +100,7 @@ public class SchemaManager {if (schema instanceof ManagedIndexSchema && schema.isMutable()) {return doOperations(ops);} else {- return singletonList(singletonMap(ERR_MSGS, "schema is not editable"));+ return List.of(Map.of(ERR_MSGS, "schema is not editable"));}}@@ -127,7 +125,7 @@ public class SchemaManager {op.operationType,SchemaManagerUtils.convertToMap(op),ERR_MSGS,- singletonList(soe.getMessage())));+ List.of(soe.getMessage())));}}if (!errors.isEmpty()) break;@@ -175,8 +173,7 @@ public class SchemaManager {core.getCoreContainer().reload(core.getName(), core.uniqueId);} catch (SolrException e) {log.warn(errorMsg);- errors =- singletonList(singletonMap(CommandOperation.ERR_MSGS, errorMsg + e.getMessage()));+ errors = List.of(Map.of(CommandOperation.ERR_MSGS, errorMsg + e.getMessage()));}break;}@@ -190,7 +187,7 @@ public class SchemaManager {}if (errors.isEmpty() && timeOut.hasTimedOut()) {log.warn("{} Timed out", errorMsg);- errors = singletonList(singletonMap(CommandOperation.ERR_MSGS, errorMsg + "Timed out."));+ errors = List.of(Map.of(CommandOperation.ERR_MSGS, errorMsg + "Timed out."));}return errors;}@@ -247,8 +244,7 @@ public class SchemaManager {try {FieldType fieldType =mgr.managedIndexSchema.newFieldType(name, className, convertToMap(addFieldTypeOp));- mgr.managedIndexSchema =- mgr.managedIndexSchema.addFieldTypes(singletonList(fieldType), false);+ mgr.managedIndexSchema = mgr.managedIndexSchema.addFieldTypes(List.of(fieldType), false);return true;} catch (Exception e) {log.error("Could not add field type.", e);@@ -305,7 +301,7 @@ public class SchemaManager {mgr.managedIndexSchema.newField(name, type, convertToMapExcluding(addFieldOp, propsToOmit));mgr.managedIndexSchema =- mgr.managedIndexSchema.addFields(singletonList(field), Map.of(), false);+ mgr.managedIndexSchema.addFields(List.of(field), Map.of(), false);return true;} catch (Exception e) {log.error("Could not add field", e);@@ -341,7 +337,7 @@ public class SchemaManager {mgr.managedIndexSchema.newDynamicField(name, type, convertToMapExcluding(addDynFieldOp, propsToOmit));mgr.managedIndexSchema =- mgr.managedIndexSchema.addDynamicFields(singletonList(field), Map.of(), false);+ mgr.managedIndexSchema.addDynamicFields(List.of(field), Map.of(), false);return true;} catch (Exception e) {log.error("Could not add dynamic field", e);@@ -355,7 +351,7 @@ public class SchemaManager {final var deleteFieldTypeOp = (DeleteFieldTypeOperation) op;String name = ensureNotNull("name", deleteFieldTypeOp.name);try {- mgr.managedIndexSchema = mgr.managedIndexSchema.deleteFieldTypes(singleton(name));+ mgr.managedIndexSchema = mgr.managedIndexSchema.deleteFieldTypes(Set.of(name));return true;} catch (Exception e) {log.error("Could not delete field type", e);@@ -370,8 +366,7 @@ public class SchemaManager {String source = ensureNotNull("source", deleteCopyField.source);List<String> dests = ensureNotNull("dest", deleteCopyField.destinations);try {- mgr.managedIndexSchema =- mgr.managedIndexSchema.deleteCopyFields(singletonMap(source, dests));+ mgr.managedIndexSchema = mgr.managedIndexSchema.deleteCopyFields(Map.of(source, dests));return true;} catch (Exception e) {log.error("Could not delete copy field", e);@@ -385,7 +380,7 @@ public class SchemaManager {final var deleteFieldOp = (DeleteFieldOperation) op;String name = ensureNotNull("name", deleteFieldOp.name);try {- mgr.managedIndexSchema = mgr.managedIndexSchema.deleteFields(singleton(name));+ mgr.managedIndexSchema = mgr.managedIndexSchema.deleteFields(Set.of(name));return true;} catch (Exception e) {log.error("Could not delete field", e);@@ -399,7 +394,7 @@ public class SchemaManager {final var deleteDynFieldOp = (DeleteDynamicFieldOperation) op;String name = ensureNotNull("name", deleteDynFieldOp.name);try {- mgr.managedIndexSchema = mgr.managedIndexSchema.deleteDynamicFields(singleton(name));+ mgr.managedIndexSchema = mgr.managedIndexSchema.deleteDynamicFields(Set.of(name));return true;} catch (Exception e) {log.error("Could not delete dynamic field", e);diff --git a/solr/core/src/java/org/apache/solr/schema/SortableTextField.java b/solr/core/src/java/org/apache/solr/schema/SortableTextField.javaindex 6e120dddb5c..02d74724f88 100644--- a/solr/core/src/java/org/apache/solr/schema/SortableTextField.java+++ b/solr/core/src/java/org/apache/solr/schema/SortableTextField.java@@ -17,7 +17,6 @@package org.apache.solr.schema;import java.util.Arrays;-import java.util.Collections;import java.util.List;import java.util.Map;import org.apache.lucene.document.SortedDocValuesField;@@ -99,7 +98,7 @@ public class SortableTextField extends TextField {public List<IndexableField> createFields(SchemaField field, Object value) {IndexableField f = createField(field, value);if (!field.hasDocValues()) {- return Collections.singletonList(f);+ return List.of(f);}if (value instanceof ByteArrayUtf8CharSequence utf8) {if (utf8.size() < maxCharsForDocValues) {@@ -138,7 +137,7 @@ public class SortableTextField extends TextField {: new SortedDocValuesField(field.getName(), bytes);if (null == f) {- return Collections.singletonList(docval);+ return List.of(docval);}return Arrays.asList(f, docval);}diff --git a/solr/core/src/java/org/apache/solr/schema/StrField.java b/solr/core/src/java/org/apache/solr/schema/StrField.javaindex a5f7b4643f9..bc437553fe4 100644--- a/solr/core/src/java/org/apache/solr/schema/StrField.java+++ b/solr/core/src/java/org/apache/solr/schema/StrField.java@@ -18,7 +18,6 @@ package org.apache.solr.schema;import java.io.IOException;import java.util.ArrayList;-import java.util.Collections;import java.util.List;import java.util.Map;import org.apache.lucene.document.SortedDocValuesField;@@ -65,7 +64,7 @@ public class StrField extends PrimitiveFieldType {fval = docval;}- return Collections.singletonList(fval);+ return List.of(fval);}public static BytesRef getBytesRef(Object value) {diff --git a/solr/core/src/java/org/apache/solr/schema/TrieField.java b/solr/core/src/java/org/apache/solr/schema/TrieField.javaindex 5b8980d0a12..9512176d33d 100644--- a/solr/core/src/java/org/apache/solr/schema/TrieField.java+++ b/solr/core/src/java/org/apache/solr/schema/TrieField.java@@ -20,7 +20,6 @@ import java.io.IOException;import java.lang.invoke.MethodHandles;import java.time.Instant;import java.util.ArrayList;-import java.util.Collections;import java.util.Date;import java.util.List;import java.util.Locale;@@ -690,7 +689,7 @@ public class TrieField extends NumericFieldType {return fields;} else {- return Collections.singletonList(createField(sf, value));+ return List.of(createField(sf, value));}}diff --git a/solr/core/src/java/org/apache/solr/search/CacheConfig.java b/solr/core/src/java/org/apache/solr/search/CacheConfig.javaindex da05152a86d..c253f48fa41 100644--- a/solr/core/src/java/org/apache/solr/search/CacheConfig.java+++ b/solr/core/src/java/org/apache/solr/search/CacheConfig.java@@ -19,7 +19,6 @@ package org.apache.solr.search;import static org.apache.solr.common.params.CommonParams.NAME;import java.lang.invoke.MethodHandles;-import java.util.Collections;import java.util.HashMap;import java.util.LinkedHashMap;import java.util.List;@@ -148,7 +147,7 @@ public class CacheConfig implements MapSerializable {if (loadedClass != null) return loadedClass;return loadedClass =loader.findClass(- new PluginInfo("cache", Collections.singletonMap("class", config.cacheImpl)),+ new PluginInfo("cache", Map.of("class", config.cacheImpl)),SolrCache.class,true);}diff --git a/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.javaindex 9f127f7d460..ae3102e41ce 100644--- a/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java+++ b/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java@@ -29,7 +29,6 @@ import java.io.IOException;import java.lang.invoke.MethodHandles;import java.util.ArrayList;import java.util.Arrays;-import java.util.Collections;import java.util.EnumSet;import java.util.Iterator;import java.util.List;@@ -504,7 +503,7 @@ public class CollapsingQParserPlugin extends QParserPlugin {return UninvertingReader.wrap(new ReaderWrapper(searcher.getSlowAtomicReader(), collapseField),- Collections.singletonMap(collapseField, type)::get);+ Map.of(collapseField, type)::get);}private static class ReaderWrapper extends FilterLeafReader {diff --git a/solr/core/src/java/org/apache/solr/search/NumericHidingLeafReader.java b/solr/core/src/java/org/apache/solr/search/NumericHidingLeafReader.javaindex 36a7e6177f4..8b80b87053d 100644--- a/solr/core/src/java/org/apache/solr/search/NumericHidingLeafReader.java+++ b/solr/core/src/java/org/apache/solr/search/NumericHidingLeafReader.java@@ -18,7 +18,6 @@ package org.apache.solr.search;import java.io.IOException;import java.util.ArrayList;-import java.util.Collections;import java.util.Map;import org.apache.lucene.index.BinaryDocValues;import org.apache.lucene.index.DocValuesSkipIndexType;@@ -49,7 +48,7 @@ public class NumericHidingLeafReader extends FilterLeafReader {public static LeafReader wrap(LeafReader leafReader, String field) {return UninvertingReader.wrap(new NumericHidingLeafReader(leafReader, field),- Collections.singletonMap(field, UninvertingReader.Type.SORTED)::get);+ Map.of(field, UninvertingReader.Type.SORTED)::get);}private final String field;diff --git a/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java b/solr/core/src/java/org/apache/solr/search/ValueSourceParser.javaindex 04e17b78d8e..943a1239b21 100644--- a/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java+++ b/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java@@ -1452,8 +1452,8 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin {SolrException.ErrorCode.BAD_REQUEST,"Illegal number of sources. There must be an even number of sources");} else {- mvr.mv1 = new VectorValueSource(Collections.singletonList(sources.get(0)));- mvr.mv2 = new VectorValueSource(Collections.singletonList(sources.get(1)));+ mvr.mv1 = new VectorValueSource(List.of(sources.get(0)));+ mvr.mv2 = new VectorValueSource(List.of(sources.get(1)));}} else {int dim = sources.size() / 2;diff --git a/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/TopGroupsResultTransformer.java b/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/TopGroupsResultTransformer.javaindex 060fc78ab8a..2da4835b18a 100644--- a/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/TopGroupsResultTransformer.java+++ b/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/TopGroupsResultTransformer.java@@ -22,11 +22,11 @@ import java.io.IOException;import java.lang.invoke.MethodHandles;import java.lang.reflect.Array;import java.util.ArrayList;-import java.util.Collections;import java.util.HashMap;import java.util.List;import java.util.Map;import java.util.Map.Entry;+import java.util.Set;import org.apache.lucene.document.Document;import org.apache.lucene.search.FieldDoc;import org.apache.lucene.search.ScoreDoc;@@ -331,6 +331,6 @@ public class TopGroupsResultTransformerprivate Document retrieveDocument(final SchemaField uniqueField, int doc, SolrDocumentFetcher docFetcher) throws IOException {- return docFetcher.doc(doc, Collections.singleton(uniqueField.getName()));+ return docFetcher.doc(doc, Set.of(uniqueField.getName()));}}diff --git a/solr/core/src/java/org/apache/solr/search/mlt/MLTContentQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/mlt/MLTContentQParserPlugin.javaindex 246497b1303..4864b1cfb2d 100644--- a/solr/core/src/java/org/apache/solr/search/mlt/MLTContentQParserPlugin.java+++ b/solr/core/src/java/org/apache/solr/search/mlt/MLTContentQParserPlugin.java@@ -19,8 +19,8 @@ package org.apache.solr.search.mlt;import java.io.IOException;import java.io.StringReader;import java.util.Collection;-import java.util.Collections;import java.util.Map;+import java.util.Set;import org.apache.lucene.queries.mlt.MoreLikeThis;import org.apache.lucene.search.Query;import org.apache.solr.common.SolrException;@@ -57,7 +57,7 @@ public class MLTContentQParserPlugin extends QParserPlugin {if (fieldNames.length == 1) {return moreLikeThis.like(fieldNames[0], new StringReader(content));} else {- Collection<Object> streamValue = Collections.singleton(content);+ Collection<Object> streamValue = Set.of(content);Map<String, Collection<Object>> multifieldDoc = CollectionUtil.newHashMap(fieldNames.length);for (String field : fieldNames) {multifieldDoc.put(field, streamValue);diff --git a/solr/core/src/java/org/apache/solr/security/AuditEvent.java b/solr/core/src/java/org/apache/solr/security/AuditEvent.javaindex e3367e8d8ea..7294926c724 100644--- a/solr/core/src/java/org/apache/solr/security/AuditEvent.java+++ b/solr/core/src/java/org/apache/solr/security/AuditEvent.java@@ -23,7 +23,6 @@ import jakarta.servlet.http.HttpServletRequest;import java.lang.invoke.MethodHandles;import java.security.Principal;import java.util.Arrays;-import java.util.Collections;import java.util.Date;import java.util.Enumeration;import java.util.HashMap;@@ -558,10 +557,8 @@ public class AuditEvent {"^/api/node.*$","^/api/cluster.*$");- private static final List<String> STREAMING_PATH_REGEXES =- Collections.singletonList(".*/stream.*");- private static final List<String> INDEXING_PATH_REGEXES =- Collections.singletonList(".*/update.*");+ private static final List<String> STREAMING_PATH_REGEXES = List.of(".*/stream.*");+ private static final List<String> INDEXING_PATH_REGEXES = List.of(".*/update.*");private static final List<String> SEARCH_PATH_REGEXES =Arrays.asList(".*/select.*", ".*/query.*");diff --git a/solr/core/src/java/org/apache/solr/security/AuditLoggerPlugin.java b/solr/core/src/java/org/apache/solr/security/AuditLoggerPlugin.javaindex fce04423f94..ec0ee1acd0d 100644--- a/solr/core/src/java/org/apache/solr/security/AuditLoggerPlugin.java+++ b/solr/core/src/java/org/apache/solr/security/AuditLoggerPlugin.java@@ -26,7 +26,6 @@ import java.io.StringWriter;import java.lang.invoke.MethodHandles;import java.util.ArrayList;import java.util.Arrays;-import java.util.Collections;import java.util.Date;import java.util.List;import java.util.Map;@@ -429,7 +428,7 @@ public abstract class AuditLoggerPlugin implements Closeable, Runnable, SolrInfo.forEach(l -> {if (l instanceof String) {- rules.add(Collections.singletonList(parseRule(l)));+ rules.add(List.of(parseRule(l)));} else if (l instanceof List) {List<MuteRule> rl = new ArrayList<>();((List<?>) l).forEach(r -> rl.add(parseRule(r)));diff --git a/solr/core/src/java/org/apache/solr/security/MultiAuthPlugin.java b/solr/core/src/java/org/apache/solr/security/MultiAuthPlugin.javaindex 30cc75f44ee..1e1d33ee6d1 100644--- a/solr/core/src/java/org/apache/solr/security/MultiAuthPlugin.java+++ b/solr/core/src/java/org/apache/solr/security/MultiAuthPlugin.java@@ -22,7 +22,6 @@ import jakarta.servlet.http.HttpServletRequest;import jakarta.servlet.http.HttpServletResponse;import java.io.IOException;import java.util.ArrayList;-import java.util.Collections;import java.util.HashMap;import java.util.LinkedHashMap;import java.util.List;@@ -99,7 +98,7 @@ public class MultiAuthPlugin extends AuthenticationPluginErrorCode.BAD_REQUEST, "Config for scheme '" + scheme + "' not found!");}- Map<String, Object> updated = plugin.edit(latestPluginConf, Collections.singletonList(c));+ Map<String, Object> updated = plugin.edit(latestPluginConf, List.of(c));if (updated != null) {madeChanges = true;schemes.set(updateAt, withScheme(scheme, updated));diff --git a/solr/core/src/java/org/apache/solr/security/MultiAuthRuleBasedAuthorizationPlugin.java b/solr/core/src/java/org/apache/solr/security/MultiAuthRuleBasedAuthorizationPlugin.javaindex 2506605e935..3711c6b96b8 100644--- a/solr/core/src/java/org/apache/solr/security/MultiAuthRuleBasedAuthorizationPlugin.java+++ b/solr/core/src/java/org/apache/solr/security/MultiAuthRuleBasedAuthorizationPlugin.java@@ -19,7 +19,6 @@ package org.apache.solr.security;import static org.apache.solr.security.MultiAuthPlugin.applyEditCommandToSchemePlugin;import java.security.Principal;-import java.util.Collections;import java.util.HashMap;import java.util.HashSet;import java.util.LinkedHashMap;@@ -123,7 +122,7 @@ public class MultiAuthRuleBasedAuthorizationPlugin extends RuleBasedAuthorizatio// just let the base class handle permission commandsif (c.name.endsWith("-permission")) {- Map<String, Object> updated = super.edit(latestConf, Collections.singletonList(c));+ Map<String, Object> updated = super.edit(latestConf, List.of(c));if (updated != null) {madeChanges = true;latestConf = updated;diff --git a/solr/core/src/java/org/apache/solr/security/Permission.java b/solr/core/src/java/org/apache/solr/security/Permission.javaindex a344b3f2ce1..290b7912afb 100644--- a/solr/core/src/java/org/apache/solr/security/Permission.java+++ b/solr/core/src/java/org/apache/solr/security/Permission.java@@ -18,7 +18,6 @@package org.apache.solr.security;import static java.util.Collections.singleton;-import static java.util.Collections.singletonList;import static org.apache.solr.common.params.CommonParams.NAME;import java.util.Collection;@@ -34,6 +33,7 @@ import java.util.stream.Collectors;import java.util.stream.Stream;import org.apache.solr.common.SolrException;import org.apache.solr.common.params.CommonParams;+import org.apache.solr.common.util.SuppressForbidden;import org.apache.solr.common.util.Utils;class Permission {@@ -82,9 +82,7 @@ class Permission {} else {@SuppressWarnings("unchecked")List<String> patternStrs =- e.getValue() instanceof List- ? (List) e.getValue()- : singletonList(e.getValue().toString());+ e.getValue() instanceof List ? (List) e.getValue() : List.of(e.getValue().toString());List<?> patterns =patternStrs.stream().map(@@ -92,7 +90,7 @@ class Permission {it.startsWith("REGEX:")? Pattern.compile(it.substring("REGEX:".length())): it)- .collect(Collectors.toList());+ .toList();p.params.put(e.getKey(),val -> {@@ -115,6 +113,9 @@ class Permission {}/** This checks for the defaults available other rules for the keys */+ @SuppressForbidden(+ reason =+ "Collections.singleton(null) is intentional — null is a sentinel value meaning 'core admin / collection admin request' (no collection)")private static Set<String> readSetSmart(String permissionName, Map<?, ?> m, String key) {if (PermissionNameProvider.values.containsKey(permissionName)&& !m.containsKey(key)@@ -128,7 +129,7 @@ class Permission {}return set;}- return set == null ? singleton(null) : set;+ return set == null ? Collections.singleton(null) : set;}/**@@ -137,6 +138,9 @@ class Permission {* @param m the map from which to lookup* @param key the key with which to do lookup*/+ @SuppressForbidden(+ reason =+ "Collections.singleton(null) is intentional — null is a sentinel value meaning 'core admin / collection admin request' (no collection)")static Set<String> readValueAsSet(Map<?, ?> m, String key) {Set<String> result = new HashSet<>();Object val = m.get(key);@@ -144,7 +148,7 @@ class Permission {if ("collection".equals(key)) {// for collection collection: null means a core admin/ collection admin request// otherwise it means a request where collection name is ignored- return m.containsKey(key) ? singleton(null) : singleton("*");+ return m.containsKey(key) ? singleton(null) : Set.of("*");}return null;}diff --git a/solr/core/src/java/org/apache/solr/security/PermissionNameProvider.java b/solr/core/src/java/org/apache/solr/security/PermissionNameProvider.javaindex 3321c6ac248..fdd313069a6 100644--- a/solr/core/src/java/org/apache/solr/security/PermissionNameProvider.java+++ b/solr/core/src/java/org/apache/solr/security/PermissionNameProvider.java@@ -24,9 +24,11 @@ import static java.util.Collections.unmodifiableSet;import static java.util.function.Function.identity;import static java.util.stream.Collectors.toMap;+import java.util.Arrays;import java.util.HashSet;import java.util.Map;import java.util.Set;+import org.apache.solr.common.util.SuppressForbidden;/*** A requestHandler should implement this interface to provide the well known permission at request@@ -61,6 +63,7 @@ public interface PermissionNameProvider {final Set<String> collName;@SuppressWarnings({"unchecked"})+ @SuppressForbidden(reason = "Set.of fails here")Name(String s, Object collName) {name = s;this.collName =@@ -76,12 +79,9 @@ public interface PermissionNameProvider {}}- Set<String> NULL = singleton(null);- Set<String> ANY = singleton("*");-Map<String, Name> values =unmodifiableMap(- asList(Name.values()).stream().collect(toMap(Name::getPermissionName, identity())));+ Arrays.stream(Name.values()).collect(toMap(Name::getPermissionName, identity())));Name getPermissionName(AuthorizationContext request);}diff --git a/solr/core/src/java/org/apache/solr/security/RuleBasedAuthorizationPluginBase.java b/solr/core/src/java/org/apache/solr/security/RuleBasedAuthorizationPluginBase.javaindex 0b959100420..d481047f058 100644--- a/solr/core/src/java/org/apache/solr/security/RuleBasedAuthorizationPluginBase.java+++ b/solr/core/src/java/org/apache/solr/security/RuleBasedAuthorizationPluginBase.java@@ -40,6 +40,7 @@ import org.apache.solr.api.Api;import org.apache.solr.common.SolrException;import org.apache.solr.common.SpecProvider;import org.apache.solr.common.util.CommandOperation;+import org.apache.solr.common.util.SuppressForbidden;import org.apache.solr.common.util.ValidatingJsonMap;import org.apache.solr.handler.admin.api.ModifyRuleBasedAuthConfigAPI;import org.slf4j.Logger;@@ -358,6 +359,7 @@ public abstract class RuleBasedAuthorizationPluginBase}// this is to do optimized lookup of permissions for a given collection/path+ @SuppressForbidden(reason = "singletonList(null) is intentional")private void add2Mapping(Permission permission) {for (String c : permission.collections) {WildCardSupportMap m = mapping.computeIfAbsent(c, k -> new WildCardSupportMap());diff --git a/solr/core/src/java/org/apache/solr/security/Sha256AuthenticationProvider.java b/solr/core/src/java/org/apache/solr/security/Sha256AuthenticationProvider.javaindex 17c56aea0a3..31c38537f69 100644--- a/solr/core/src/java/org/apache/solr/security/Sha256AuthenticationProvider.java+++ b/solr/core/src/java/org/apache/solr/security/Sha256AuthenticationProvider.java@@ -73,8 +73,7 @@ public class Sha256AuthenticationProvider}promptHeader =- Collections.unmodifiableMap(- Collections.singletonMap("WWW-Authenticate", "Basic realm=\"" + realm + "\""));+ Collections.unmodifiableMap(Map.of("WWW-Authenticate", "Basic realm=\"" + realm + "\""));credentials = new LinkedHashMap<>();@SuppressWarnings({"unchecked"})Map<String, String> users = (Map<String, String>) pluginConfig.get("credentials");diff --git a/solr/core/src/java/org/apache/solr/security/cert/PathBasedCertPrincipalResolver.java b/solr/core/src/java/org/apache/solr/security/cert/PathBasedCertPrincipalResolver.javaindex bc681685981..f2e823f9bb6 100644--- a/solr/core/src/java/org/apache/solr/security/cert/PathBasedCertPrincipalResolver.java+++ b/solr/core/src/java/org/apache/solr/security/cert/PathBasedCertPrincipalResolver.java@@ -20,7 +20,7 @@ import java.lang.invoke.MethodHandles;import java.security.Principal;import java.security.cert.CertificateParsingException;import java.security.cert.X509Certificate;-import java.util.Collections;+import java.util.List;import java.util.Map;import java.util.Set;import javax.net.ssl.SSLPeerUnverifiedException;@@ -120,8 +120,7 @@ public class PathBasedCertPrincipalResolver extends PathBasedCertResolverBase@Overridepublic Principal resolvePrincipal(X509Certificate certificate)throws SSLPeerUnverifiedException, CertificateParsingException {- Map<String, Set<String>> matches =- getValuesFromPaths(certificate, Collections.singletonList(pattern));+ Map<String, Set<String>> matches = getValuesFromPaths(certificate, List.of(pattern));String basePrincipal = null;if (matches != null && !matches.isEmpty()) {Set<String> fieldValues = matches.getOrDefault(pattern.getName(), Set.of());diff --git a/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java b/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.javaindex 3e638f56de9..f8c7725c429 100644--- a/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java+++ b/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java@@ -38,7 +38,6 @@ import java.lang.invoke.MethodHandles;import java.nio.charset.StandardCharsets;import java.util.ArrayList;import java.util.Collection;-import java.util.Collections;import java.util.HashMap;import java.util.Iterator;import java.util.LinkedHashSet;@@ -765,8 +764,7 @@ public class HttpSolrCall {if (collectionParam == null&& // if collection param already exists, we may need to over-write itcore != null- && collections.equals(- Collections.singletonList(core.getCoreDescriptor().getCollectionName()))) {+ && collections.equals(List.of(core.getCoreDescriptor().getCollectionName()))) {return;}String newCollectionParam = StrUtils.join(collections, ',');diff --git a/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java b/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.javaindex 5ca176ea66a..167a3d5a0bd 100644--- a/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java+++ b/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java@@ -19,8 +19,8 @@ package org.apache.solr.update;import com.google.common.annotations.VisibleForTesting;import java.util.ArrayList;import java.util.Collection;-import java.util.Collections;import java.util.List;+import java.util.Set;import org.apache.lucene.document.Document;import org.apache.lucene.index.Term;import org.apache.lucene.util.BytesRef;@@ -211,7 +211,7 @@ public class AddUpdateCommand extends UpdateCommand {final boolean ignoreNestedDocs = false; // throw an exception if foundDocument doc =DocumentBuilder.toDocument(solrDoc, req.getSchema(), forInPlaceUpdate, ignoreNestedDocs);- return Collections.singleton(doc);+ return Set.of(doc);}List<SolrInputDocument> all = flatten(solrDoc);diff --git a/solr/core/src/java/org/apache/solr/update/UpdateLog.java b/solr/core/src/java/org/apache/solr/update/UpdateLog.javaindex 5284e94e0e5..ef35d3c9b0c 100644--- a/solr/core/src/java/org/apache/solr/update/UpdateLog.java+++ b/solr/core/src/java/org/apache/solr/update/UpdateLog.java@@ -1460,7 +1460,7 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {tlog.incref();ExecutorCompletionService<RecoveryInfo> cs = new ExecutorCompletionService<>(recoveryExecutor);- LogReplayer replayer = new LogReplayer(Collections.singletonList(tlog), false, true);+ LogReplayer replayer = new LogReplayer(List.of(tlog), false, true);updateLocks.blockUpdates();try {@@ -2059,7 +2059,7 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {throw new RuntimeException("executor is not running...");}ExecutorCompletionService<RecoveryInfo> cs = new ExecutorCompletionService<>(recoveryExecutor);- LogReplayer replayer = new LogReplayer(Collections.singletonList(bufferTlog), true);+ LogReplayer replayer = new LogReplayer(List.of(bufferTlog), true);return cs.submit(() -> {replayer.run();diff --git a/solr/core/src/java/org/apache/solr/update/processor/AtomicUpdateDocumentMerger.java b/solr/core/src/java/org/apache/solr/update/processor/AtomicUpdateDocumentMerger.javaindex f93c729695d..3cdb0706980 100644--- a/solr/core/src/java/org/apache/solr/update/processor/AtomicUpdateDocumentMerger.java+++ b/solr/core/src/java/org/apache/solr/update/processor/AtomicUpdateDocumentMerger.java@@ -22,7 +22,6 @@ import java.io.IOException;import java.lang.invoke.MethodHandles;import java.util.ArrayList;import java.util.Collection;-import java.util.Collections;import java.util.Date;import java.util.HashSet;import java.util.LinkedHashMap;@@ -483,7 +482,7 @@ public class AtomicUpdateDocumentMerger {return ((Collection<?>) fieldVal).stream().map(SolrInputDocument.class::cast).collect(Collectors.toList());} else {- return Collections.singletonList((SolrInputDocument) fieldVal);+ return List.of((SolrInputDocument) fieldVal);}}diff --git a/solr/core/src/java/org/apache/solr/update/processor/AtomicUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/AtomicUpdateProcessorFactory.javaindex 8416e0eca9f..c8b7add9086 100644--- a/solr/core/src/java/org/apache/solr/update/processor/AtomicUpdateProcessorFactory.java+++ b/solr/core/src/java/org/apache/solr/update/processor/AtomicUpdateProcessorFactory.java@@ -16,7 +16,6 @@*/package org.apache.solr.update.processor;-import static java.util.Collections.singletonMap;import static org.apache.solr.common.SolrException.ErrorCode.SERVER_ERROR;import java.io.IOException;@@ -135,7 +134,7 @@ public class AtomicUpdateProcessorFactory extends UpdateRequestProcessorFactorycontinue;}- orgdoc.setField(field, singletonMap(operation, orgdoc.get(field).getValue()));+ orgdoc.setField(field, Map.of(operation, orgdoc.get(field).getValue()));isAtomicUpdateAddedByMe = true;}diff --git a/solr/core/src/java/org/apache/solr/update/processor/CloneFieldUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/CloneFieldUpdateProcessorFactory.javaindex f9978a3ed22..8f4b7410338 100644--- a/solr/core/src/java/org/apache/solr/update/processor/CloneFieldUpdateProcessorFactory.java+++ b/solr/core/src/java/org/apache/solr/update/processor/CloneFieldUpdateProcessorFactory.java@@ -22,7 +22,6 @@ import java.io.IOException;import java.lang.invoke.MethodHandles;import java.util.ArrayList;import java.util.Collection;-import java.util.Collections;import java.util.HashMap;import java.util.HashSet;import java.util.List;@@ -299,7 +298,7 @@ public class CloneFieldUpdateProcessorFactory extends UpdateRequestProcessorFactpe);}srcInclusions = new SelectorParams();- srcInclusions.fieldRegex = Collections.singletonList(this.pattern);+ srcInclusions.fieldRegex = List.of(this.pattern);}/**diff --git a/solr/core/src/java/org/apache/solr/update/processor/DistributedZkUpdateProcessor.java b/solr/core/src/java/org/apache/solr/update/processor/DistributedZkUpdateProcessor.javaindex e381ae5f827..49c9fc717a7 100644--- a/solr/core/src/java/org/apache/solr/update/processor/DistributedZkUpdateProcessor.java+++ b/solr/core/src/java/org/apache/solr/update/processor/DistributedZkUpdateProcessor.java@@ -24,7 +24,6 @@ import java.lang.invoke.MethodHandles;import java.util.ArrayList;import java.util.Arrays;import java.util.Collection;-import java.util.Collections;import java.util.EnumSet;import java.util.HashSet;import java.util.List;@@ -791,7 +790,7 @@ public class DistributedZkUpdateProcessor extends DistributedUpdateProcessor {} else {// I need to forward on to the leader...forwardToLeader = true;- return Collections.singletonList(+ return List.of(new SolrCmdDistributor.ForwardNode(new ZkCoreNodeProps(leaderReplica),zkController.getZkStateReader(),diff --git a/solr/core/src/java/org/apache/solr/update/processor/FirstFieldValueUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/FirstFieldValueUpdateProcessorFactory.javaindex 44cff759554..3a399e2fbfb 100644--- a/solr/core/src/java/org/apache/solr/update/processor/FirstFieldValueUpdateProcessorFactory.java+++ b/solr/core/src/java/org/apache/solr/update/processor/FirstFieldValueUpdateProcessorFactory.java@@ -20,6 +20,7 @@ import static org.apache.solr.update.processor.FieldMutatingUpdateProcessor.SELEimport java.util.Collection;import java.util.Collections;+import org.apache.solr.common.util.SuppressForbidden;import org.apache.solr.core.SolrCore;import org.apache.solr.update.processor.FieldMutatingUpdateProcessor.FieldNameSelector;@@ -46,6 +47,7 @@ import org.apache.solr.update.processor.FieldMutatingUpdateProcessor.FieldNameSepublic final class FirstFieldValueUpdateProcessorFactoryextends FieldValueSubsetUpdateProcessorFactory {+ @SuppressForbidden(reason = "singletonList allows null field values")@Overridepublic <T> Collection<T> pickSubset(Collection<T> values) {// trust the iteratordiff --git a/solr/core/src/java/org/apache/solr/update/processor/LastFieldValueUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/LastFieldValueUpdateProcessorFactory.javaindex 8be53308a3a..3f12f053ea6 100644--- a/solr/core/src/java/org/apache/solr/update/processor/LastFieldValueUpdateProcessorFactory.java+++ b/solr/core/src/java/org/apache/solr/update/processor/LastFieldValueUpdateProcessorFactory.java@@ -22,6 +22,7 @@ import java.util.Collection;import java.util.Collections;import java.util.List;import java.util.SortedSet;+import org.apache.solr.common.util.SuppressForbidden;import org.apache.solr.core.SolrCore;import org.apache.solr.update.processor.FieldMutatingUpdateProcessor.FieldNameSelector;@@ -48,6 +49,7 @@ import org.apache.solr.update.processor.FieldMutatingUpdateProcessor.FieldNameSepublic final class LastFieldValueUpdateProcessorFactoryextends FieldValueSubsetUpdateProcessorFactory {+ @SuppressForbidden(reason = "singletonList allows null field values")@Overridepublic <T> Collection<T> pickSubset(Collection<T> values) {diff --git a/solr/core/src/java/org/apache/solr/update/processor/MaxFieldValueUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/MaxFieldValueUpdateProcessorFactory.javaindex 8f985762e0f..42e412ebec5 100644--- a/solr/core/src/java/org/apache/solr/update/processor/MaxFieldValueUpdateProcessorFactory.java+++ b/solr/core/src/java/org/apache/solr/update/processor/MaxFieldValueUpdateProcessorFactory.java@@ -22,6 +22,7 @@ import static org.apache.solr.update.processor.FieldMutatingUpdateProcessor.SELEimport java.util.Collection;import java.util.Collections;import org.apache.solr.common.SolrException;+import org.apache.solr.common.util.SuppressForbidden;import org.apache.solr.core.SolrCore;import org.apache.solr.update.processor.FieldMutatingUpdateProcessor.FieldNameSelector;@@ -49,6 +50,7 @@ import org.apache.solr.update.processor.FieldMutatingUpdateProcessor.FieldNameSepublic final class MaxFieldValueUpdateProcessorFactoryextends FieldValueSubsetUpdateProcessorFactory {+ @SuppressForbidden(reason = "singletonList allows null field values from Collections.max")@Overridepublic <T> Collection<T> pickSubset(Collection<T> values) {try {diff --git a/solr/core/src/java/org/apache/solr/update/processor/MinFieldValueUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/MinFieldValueUpdateProcessorFactory.javaindex 8fef2e2e55b..4a5bd0a1e13 100644--- a/solr/core/src/java/org/apache/solr/update/processor/MinFieldValueUpdateProcessorFactory.java+++ b/solr/core/src/java/org/apache/solr/update/processor/MinFieldValueUpdateProcessorFactory.java@@ -22,6 +22,7 @@ import static org.apache.solr.update.processor.FieldMutatingUpdateProcessor.SELEimport java.util.Collection;import java.util.Collections;import org.apache.solr.common.SolrException;+import org.apache.solr.common.util.SuppressForbidden;import org.apache.solr.core.SolrCore;import org.apache.solr.update.processor.FieldMutatingUpdateProcessor.FieldNameSelector;@@ -49,6 +50,7 @@ import org.apache.solr.update.processor.FieldMutatingUpdateProcessor.FieldNameSepublic final class MinFieldValueUpdateProcessorFactoryextends FieldValueSubsetUpdateProcessorFactory {+ @SuppressForbidden(reason = "singletonList allows null field values from Collections.min")@Overridepublic <T> Collection<T> pickSubset(Collection<T> values) {try {diff --git a/solr/core/src/java/org/apache/solr/update/processor/ParseBooleanFieldUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/ParseBooleanFieldUpdateProcessorFactory.javaindex 710e98a337f..89a99da3d6a 100644--- a/solr/core/src/java/org/apache/solr/update/processor/ParseBooleanFieldUpdateProcessorFactory.java+++ b/solr/core/src/java/org/apache/solr/update/processor/ParseBooleanFieldUpdateProcessorFactory.java@@ -17,7 +17,6 @@package org.apache.solr.update.processor;import java.util.Collection;-import java.util.Collections;import java.util.HashSet;import java.util.Locale;import java.util.Set;@@ -66,8 +65,8 @@ public class ParseBooleanFieldUpdateProcessorFactory extends FieldMutatingUpdateprivate static final String FALSE_VALUES_PARAM = "falseValue";private static final String CASE_SENSITIVE_PARAM = "caseSensitive";- private Set<String> trueValues = new HashSet<>(Collections.singleton("true"));- private Set<String> falseValues = new HashSet<>(Collections.singleton("false"));+ private Set<String> trueValues = new HashSet<>(Set.of("true"));+ private Set<String> falseValues = new HashSet<>(Set.of("false"));private boolean caseSensitive = false;@Overridediff --git a/solr/core/src/java/org/apache/solr/update/processor/RoutedAliasUpdateProcessor.java b/solr/core/src/java/org/apache/solr/update/processor/RoutedAliasUpdateProcessor.javaindex da5e771e2e8..b38cc5d1e6b 100644--- a/solr/core/src/java/org/apache/solr/update/processor/RoutedAliasUpdateProcessor.java+++ b/solr/core/src/java/org/apache/solr/update/processor/RoutedAliasUpdateProcessor.java@@ -23,7 +23,6 @@ import static org.apache.solr.update.processor.DistributingUpdateProcessorFactorimport java.io.IOException;import java.lang.invoke.MethodHandles;import java.util.Collection;-import java.util.Collections;import java.util.List;import java.util.Map;import java.util.stream.Collectors;@@ -199,9 +198,7 @@ public class RoutedAliasUpdateProcessor extends UpdateRequestProcessor {SolrCmdDistributor.Node targetLeaderNode =routeDocToSlice(targetCollection, cmd.getSolrInputDocument());cmdDistrib.distribAdd(- cmd,- Collections.singletonList(targetLeaderNode),- new ModifiableSolrParams(outParamsToLeader));+ cmd, List.of(targetLeaderNode), new ModifiableSolrParams(outParamsToLeader));}}diff --git a/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java b/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.javaindex aa19b6d25f4..b32b77846d2 100644--- a/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java+++ b/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java@@ -16,7 +16,6 @@*/package org.apache.solr.util;-import static java.util.Collections.singletonList;import static org.apache.solr.core.PluginInfo.APPENDS;import static org.apache.solr.core.PluginInfo.DEFAULTS;import static org.apache.solr.core.PluginInfo.INVARIANTS;@@ -171,9 +170,7 @@ public class SolrPluginUtils {RequestParams requestParams, SolrParams defaults, String paramSets, String type) {if (paramSets == null) return defaults;List<String> paramSetList =- paramSets.indexOf(',') == -1- ? singletonList(paramSets)- : StrUtils.splitSmart(paramSets, ',');+ paramSets.indexOf(',') == -1 ? List.of(paramSets) : StrUtils.splitSmart(paramSets, ',');for (String name : paramSetList) {RequestParams.VersionedParams params = requestParams.getParams(name, type);if (params == null) return defaults;diff --git a/solr/core/src/test/org/apache/solr/TestSimpleTrackingShardHandler.java b/solr/core/src/test/org/apache/solr/TestSimpleTrackingShardHandler.javaindex 15bf978d4a5..6516164af93 100644--- a/solr/core/src/test/org/apache/solr/TestSimpleTrackingShardHandler.java+++ b/solr/core/src/test/org/apache/solr/TestSimpleTrackingShardHandler.java@@ -16,7 +16,6 @@*/package org.apache.solr;-import java.util.Collections;import java.util.List;import org.apache.solr.handler.component.TrackingShardHandlerFactory;import org.apache.solr.handler.component.TrackingShardHandlerFactory.RequestTrackingQueue;@@ -38,8 +37,7 @@ public class TestSimpleTrackingShardHandler extends BaseDistributedSearchTestCasTrackingShardHandlerFactory.setTrackingQueue(jettys, trackingQueue);// sanity check that our control jetty has the correct configs as well- TrackingShardHandlerFactory.setTrackingQueue(- Collections.singletonList(controlJetty), trackingQueue);+ TrackingShardHandlerFactory.setTrackingQueue(List.of(controlJetty), trackingQueue);query("q", "*:*", "fl", "id", "sort", "id asc");@@ -50,6 +48,6 @@ public class TestSimpleTrackingShardHandler extends BaseDistributedSearchTestCas}}TrackingShardHandlerFactory.setTrackingQueue(jettys, null);- TrackingShardHandlerFactory.setTrackingQueue(Collections.singletonList(controlJetty), null);+ TrackingShardHandlerFactory.setTrackingQueue(List.of(controlJetty), null);}}diff --git a/solr/core/src/test/org/apache/solr/api/NodeConfigClusterPluginsSourceTest.java b/solr/core/src/test/org/apache/solr/api/NodeConfigClusterPluginsSourceTest.javaindex a50979b3418..0ad8666c527 100644--- a/solr/core/src/test/org/apache/solr/api/NodeConfigClusterPluginsSourceTest.java+++ b/solr/core/src/test/org/apache/solr/api/NodeConfigClusterPluginsSourceTest.java@@ -17,7 +17,6 @@package org.apache.solr.api;-import java.util.Collections;import java.util.HashMap;import java.util.Map;import org.apache.solr.client.solrj.RemoteSolrException;@@ -118,10 +117,7 @@ public class NodeConfigClusterPluginsSourceTest extends SolrCloudTestCase {public void testClusterPluginsEditApi() throws Exception {PluginMeta meta = SingletonNoConfig.pluginMeta();V2Request req =- new V2Request.Builder("/cluster/plugin")- .POST()- .withPayload(Collections.singletonMap("add", meta))- .build();+ new V2Request.Builder("/cluster/plugin").POST().withPayload(Map.of("add", meta)).build();try {req.process(cluster.getSolrClient());fail("Expected a 404 response code because the Edit Apis are not registered");diff --git a/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java b/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.javaindex 59bde025506..ad9660080ca 100644--- a/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java+++ b/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java@@ -28,7 +28,6 @@ import java.nio.file.Files;import java.nio.file.Path;import java.util.ArrayList;import java.util.Arrays;-import java.util.Collections;import java.util.List;import java.util.Map;import java.util.Optional;@@ -477,8 +476,7 @@ public class TestSolrCLIRunExample extends SolrTestCaseJ4 {// index some docs - to verify all is good for both shardstry (CloudSolrClient cloudClient =new RandomizingCloudHttp2SolrClientBuilder(- Collections.singletonList(executor.solrCloudCluster.getZkServer().getZkAddress()),- Optional.empty())+ List.of(executor.solrCloudCluster.getZkServer().getZkAddress()), Optional.empty()).withDefaultCollection(collectionName).build()) {@@ -591,8 +589,7 @@ public class TestSolrCLIRunExample extends SolrTestCaseJ4 {// verify the collection was created with the specified parameterstry (CloudSolrClient cloudClient =new RandomizingCloudSolrClientBuilder(- Collections.singletonList(executor.solrCloudCluster.getZkServer().getZkAddress()),- Optional.empty())+ List.of(executor.solrCloudCluster.getZkServer().getZkAddress()), Optional.empty()).withDefaultCollection(collectionName).build()) {diff --git a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.javaindex 60636d30c92..c9598a8a19e 100644--- a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java@@ -912,8 +912,7 @@ public class CollectionsAPISolrJTest extends SolrCloudTestCase {new AtomicReference<>(getCoreStatus(leader).startTime.getTime());// Check for value change- CollectionAdminRequest.modifyCollection(- collectionName, Collections.singletonMap(ZkStateReader.READ_ONLY, "true"))+ CollectionAdminRequest.modifyCollection(collectionName, Map.of(ZkStateReader.READ_ONLY, "true")).process(solrClient);DocCollection coll = solrClient.getClusterState().getCollection(collectionName);@@ -986,8 +985,7 @@ public class CollectionsAPISolrJTest extends SolrCloudTestCase {// Check for removing value// setting to empty string is equivalent to removing the property, see SOLR-12507- CollectionAdminRequest.modifyCollection(- collectionName, Collections.singletonMap(ZkStateReader.READ_ONLY, ""))+ CollectionAdminRequest.modifyCollection(collectionName, Map.of(ZkStateReader.READ_ONLY, "")).process(cluster.getSolrClient());coll = solrClient.getClusterState().getCollection(collectionName);assertNull(coll.toString(), coll.getProperties().get(ZkStateReader.READ_ONLY));diff --git a/solr/core/src/test/org/apache/solr/cloud/DistributedVersionInfoTest.java b/solr/core/src/test/org/apache/solr/cloud/DistributedVersionInfoTest.javaindex 409adfdc26a..6df1bea6cfc 100644--- a/solr/core/src/test/org/apache/solr/cloud/DistributedVersionInfoTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/DistributedVersionInfoTest.java@@ -22,7 +22,6 @@ import static org.apache.solr.update.processor.DistributingUpdateProcessorFactorimport java.io.IOException;import java.lang.invoke.MethodHandles;import java.util.ArrayList;-import java.util.Collections;import java.util.HashSet;import java.util.List;import java.util.Random;@@ -351,7 +350,7 @@ public class DistributedVersionInfoTest extends SolrCloudTestCase {doc.addField("id", String.valueOf(docId));doc.addField("a_t", "hello" + docId);AbstractFullDistribZkTestBase.sendDocsWithRetry(- cluster.getSolrClient(), COLLECTION, Collections.singletonList(doc), 2, 3, 100);+ cluster.getSolrClient(), COLLECTION, List.of(doc), 2, 3, 100);}/**diff --git a/solr/core/src/test/org/apache/solr/cloud/ForceLeaderTest.java b/solr/core/src/test/org/apache/solr/cloud/ForceLeaderTest.javaindex 5364c1f32a0..e5c32a3a257 100644--- a/solr/core/src/test/org/apache/solr/cloud/ForceLeaderTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/ForceLeaderTest.java@@ -19,7 +19,6 @@ package org.apache.solr.cloud;import com.carrotsearch.randomizedtesting.annotations.Nightly;import java.io.IOException;import java.lang.invoke.MethodHandles;-import java.util.Collections;import java.util.List;import java.util.Optional;import java.util.concurrent.TimeUnit;@@ -204,8 +203,7 @@ public class ForceLeaderTest extends HttpPartitionTest {@Overrideprotected CloudSolrClient createCloudClient(String defaultCollection) {CloudLegacySolrClient.Builder builder =- new CloudLegacySolrClient.Builder(- Collections.singletonList(zkServer.getZkAddress()), Optional.empty());+ new CloudLegacySolrClient.Builder(List.of(zkServer.getZkAddress()), Optional.empty());builder.withDefaultCollection(TEST_COLLECTION);return builder.withConnectionTimeout(30000).withSocketTimeout(120000).build();}@@ -306,7 +304,7 @@ public class ForceLeaderTest extends HttpPartitionTest {cloudClient.commit(collection);log.info("Doc {} sent and commit issued", docid);assertDocsExistInAllReplicas(notLeaders, collection, docid, docid);- assertDocsExistInAllReplicas(Collections.singletonList(leader), collection, docid, docid);+ assertDocsExistInAllReplicas(List.of(leader), collection, docid, docid);}@Override@@ -315,7 +313,7 @@ public class ForceLeaderTest extends HttpPartitionTest {doc.addField(id, String.valueOf(docId));doc.addField("a_t", "hello" + docId);- return sendDocsWithRetry(collectionName, Collections.singletonList(doc), 1, 5, 1);+ return sendDocsWithRetry(collectionName, List.of(doc), 1, 5, 1);}private void doForceLeader(String collectionName, String shard)@@ -324,8 +322,7 @@ public class ForceLeaderTest extends HttpPartitionTest {CollectionAdminRequest.forceLeaderElection(collectionName, shard);try (CloudSolrClient cloudClient =- new CloudLegacySolrClient.Builder(- Collections.singletonList(zkServer.getZkAddress()), Optional.empty())+ new CloudLegacySolrClient.Builder(List.of(zkServer.getZkAddress()), Optional.empty()).withConnectionTimeout(3000).withSocketTimeout(60000).build()) {diff --git a/solr/core/src/test/org/apache/solr/cloud/LeaderFailoverAfterPartitionTest.java b/solr/core/src/test/org/apache/solr/cloud/LeaderFailoverAfterPartitionTest.javaindex 14408681acb..18e3d792cbe 100644--- a/solr/core/src/test/org/apache/solr/cloud/LeaderFailoverAfterPartitionTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/LeaderFailoverAfterPartitionTest.java@@ -17,7 +17,6 @@package org.apache.solr.cloud;import java.lang.invoke.MethodHandles;-import java.util.Collections;import java.util.HashSet;import java.util.List;import java.util.Set;@@ -190,7 +189,7 @@ public class LeaderFailoverAfterPartitionTest extends HttpPartitionTest {SolrInputDocument doc = new SolrInputDocument();doc.addField(id, String.valueOf(6));doc.addField("a_t", "hello" + 6);- sendDocsWithRetry(testCollectionName, Collections.singletonList(doc), 1, 3, 1);+ sendDocsWithRetry(testCollectionName, List.of(doc), 1, 3, 1);Set<String> replicasToCheck = new HashSet<>();for (Replica stillUp : participatingReplicas) replicasToCheck.add(stillUp.getName());diff --git a/solr/core/src/test/org/apache/solr/cloud/LeaderFailureAfterFreshStartTest.java b/solr/core/src/test/org/apache/solr/cloud/LeaderFailureAfterFreshStartTest.javaindex db978da4b36..f061661f113 100644--- a/solr/core/src/test/org/apache/solr/cloud/LeaderFailureAfterFreshStartTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/LeaderFailureAfterFreshStartTest.java@@ -17,8 +17,6 @@package org.apache.solr.cloud;-import static java.util.Collections.singletonList;-import com.carrotsearch.randomizedtesting.generators.RandomStrings;import java.io.IOException;import java.lang.invoke.MethodHandles;@@ -107,7 +105,7 @@ public class LeaderFailureAfterFreshStartTest extends AbstractFullDistribZkTestB// shutdown a node to simulate fresh startotherJetties.remove(freshNode);- forceNodeFailures(singletonList(freshNode));+ forceNodeFailures(List.of(freshNode));del("*:*");waitForThingsToLevelOut(30, TimeUnit.SECONDS);@@ -125,7 +123,7 @@ public class LeaderFailureAfterFreshStartTest extends AbstractFullDistribZkTestB// bring down the other node and index a few docs; so the leader and other node segments// diverge- forceNodeFailures(singletonList(secondNode));+ forceNodeFailures(List.of(secondNode));for (int i = 0; i < 10; i++) {indexDoc(id, docId, i1, 50, tlong, 50, t1, "document number " + docId++);if (i % 2 == 0) {@@ -133,10 +131,10 @@ public class LeaderFailureAfterFreshStartTest extends AbstractFullDistribZkTestB}}commit();- restartNodes(singletonList(secondNode));+ restartNodes(List.of(secondNode));// start the freshNode- restartNodes(singletonList(freshNode));+ restartNodes(List.of(freshNode));String coreName = freshNode.jetty.getCoreContainer().getCores().iterator().next().getName();Path replicationProperties =Path.of(freshNode.jetty.getSolrHome(), "cores", coreName, "data", "replication.properties");@@ -144,7 +142,7 @@ public class LeaderFailureAfterFreshStartTest extends AbstractFullDistribZkTestB// shutdown the original leaderlog.info("Now shutting down initial leader");- forceNodeFailures(singletonList(initialLeaderJetty));+ forceNodeFailures(List.of(initialLeaderJetty));waitForNewLeader(cloudClient, "shard1", initialLeaderJetty.info);waitTillNodesActive();log.info("Updating mappings from zk");diff --git a/solr/core/src/test/org/apache/solr/cloud/MoveReplicaTest.java b/solr/core/src/test/org/apache/solr/cloud/MoveReplicaTest.javaindex d6e00a202ee..76092a2c936 100644--- a/solr/core/src/test/org/apache/solr/cloud/MoveReplicaTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/MoveReplicaTest.java@@ -182,7 +182,7 @@ public class MoveReplicaTest extends SolrCloudTestCase {if (!r.getNodeName().equals(targetNode)) {continue;}- if (!r.isActive(Collections.singleton(targetNode))) {+ if (!r.isActive(Set.of(targetNode))) {log.info("Not active: {}", r);allActive = false;}@@ -227,7 +227,7 @@ public class MoveReplicaTest extends SolrCloudTestCase {if (!r.getNodeName().equals(replica.getNodeName())) {continue;}- if (!r.isActive(Collections.singleton(replica.getNodeName()))) {+ if (!r.isActive(Set.of(replica.getNodeName()))) {log.info("Not active yet: {}", r);allActive = false;}diff --git a/solr/core/src/test/org/apache/solr/cloud/OverseerModifyCollectionTest.java b/solr/core/src/test/org/apache/solr/cloud/OverseerModifyCollectionTest.javaindex bae0a0cafb2..536fbce44a9 100644--- a/solr/core/src/test/org/apache/solr/cloud/OverseerModifyCollectionTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/OverseerModifyCollectionTest.java@@ -17,7 +17,7 @@package org.apache.solr.cloud;-import java.util.Collections;+import java.util.Map;import org.apache.solr.client.solrj.request.CollectionAdminRequest;import org.apache.solr.client.solrj.response.RequestStatusState;import org.junit.BeforeClass;@@ -43,8 +43,7 @@ public class OverseerModifyCollectionTest extends SolrCloudTestCase {// Modify configSetRequestStatusState requestStatusState =- CollectionAdminRequest.modifyCollection(- collName, Collections.singletonMap("collection.configName", "conf2"))+ CollectionAdminRequest.modifyCollection(collName, Map.of("collection.configName", "conf2")).processAndWait(cluster.getSolrClient(), DEFAULT_TIMEOUT);assertEquals(RequestStatusState.COMPLETED, requestStatusState);@@ -58,8 +57,7 @@ public class OverseerModifyCollectionTest extends SolrCloudTestCase {Exception.class,() -> {CollectionAdminRequest.modifyCollection(- collName,- Collections.singletonMap("collection.configName", "notARealConfigName"))+ collName, Map.of("collection.configName", "notARealConfigName")).process(cluster.getSolrClient());});diff --git a/solr/core/src/test/org/apache/solr/cloud/PeerSyncReplicationTest.java b/solr/core/src/test/org/apache/solr/cloud/PeerSyncReplicationTest.javaindex e89b9890bd2..c217ebb2487 100644--- a/solr/core/src/test/org/apache/solr/cloud/PeerSyncReplicationTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/PeerSyncReplicationTest.java@@ -17,8 +17,6 @@package org.apache.solr.cloud;-import static java.util.Collections.singletonList;-import com.carrotsearch.randomizedtesting.generators.RandomStrings;import io.opentelemetry.api.metrics.MeterProvider;import java.io.IOException;@@ -121,7 +119,7 @@ public class PeerSyncReplicationTest extends AbstractFullDistribZkTestBase {otherJetties.remove(neverLeader);// first shutdown a node that will never be a leader- forceNodeFailures(singletonList(neverLeader));+ forceNodeFailures(List.of(neverLeader));// node failure and recovery via PeerSynclog.info("Forcing PeerSync");@@ -143,7 +141,7 @@ public class PeerSyncReplicationTest extends AbstractFullDistribZkTestBase {// now shutdown the original leaderlog.info("Now shutting down initial leader");- forceNodeFailures(singletonList(initialLeaderJetty));+ forceNodeFailures(List.of(initialLeaderJetty));log.info("Updating mappings from zk");waitForNewLeader(cloudClient, "shard1", initialLeaderJetty.info);updateMappingsFromZk(jettys, clients, true);diff --git a/solr/core/src/test/org/apache/solr/cloud/ReindexCollectionTest.java b/solr/core/src/test/org/apache/solr/cloud/ReindexCollectionTest.javaindex 31e4d4bbf82..aff39f246e7 100644--- a/solr/core/src/test/org/apache/solr/cloud/ReindexCollectionTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/ReindexCollectionTest.java@@ -18,7 +18,6 @@package org.apache.solr.cloud;import java.util.ArrayList;-import java.util.Collections;import java.util.List;import java.util.Locale;import java.util.Map;@@ -78,7 +77,7 @@ public class ReindexCollectionTest extends SolrCloudTestCase {stateManager = cloudManager.getDistribStateManager();solrClient =new RandomizingCloudSolrClientBuilder(- Collections.singletonList(zkController.getZkServerAddress()), Optional.empty())+ List.of(zkController.getZkServerAddress()), Optional.empty()).build();}diff --git a/solr/core/src/test/org/apache/solr/cloud/ShardTermsTest.java b/solr/core/src/test/org/apache/solr/cloud/ShardTermsTest.javaindex 579285d7207..939a91bad62 100644--- a/solr/core/src/test/org/apache/solr/cloud/ShardTermsTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/ShardTermsTest.java@@ -17,7 +17,6 @@package org.apache.solr.cloud;-import java.util.Collections;import java.util.HashMap;import java.util.Map;import java.util.Set;@@ -30,16 +29,16 @@ public class ShardTermsTest extends SolrTestCase {Map<String, Long> map = new HashMap<>();map.put("leader", 0L);ShardTerms terms = new ShardTerms(map, 0);- terms = terms.increaseTerms("leader", Collections.singleton("replica"));+ terms = terms.increaseTerms("leader", Set.of("replica"));assertEquals(1L, terms.getTerm("leader").longValue());map.put("leader", 2L);map.put("live-replica", 2L);map.put("dead-replica", 1L);terms = new ShardTerms(map, 0);- assertNull(terms.increaseTerms("leader", Collections.singleton("dead-replica")));+ assertNull(terms.increaseTerms("leader", Set.of("dead-replica")));- terms = terms.increaseTerms("leader", Collections.singleton("leader"));+ terms = terms.increaseTerms("leader", Set.of("leader"));assertEquals(3L, terms.getTerm("live-replica").longValue());assertEquals(2L, terms.getTerm("leader").longValue());assertEquals(1L, terms.getTerm("dead-replica").longValue());diff --git a/solr/core/src/test/org/apache/solr/cloud/TestHashPartitioner.java b/solr/core/src/test/org/apache/solr/cloud/TestHashPartitioner.javaindex 9b9dd28c7aa..21eda93cb37 100644--- a/solr/core/src/test/org/apache/solr/cloud/TestHashPartitioner.java+++ b/solr/core/src/test/org/apache/solr/cloud/TestHashPartitioner.java@@ -18,7 +18,6 @@ package org.apache.solr.cloud;import java.time.Instant;import java.util.Collection;-import java.util.Collections;import java.util.HashMap;import java.util.HashSet;import java.util.List;@@ -299,8 +298,7 @@ public class TestHashPartitioner extends SolrTestCaseJ4 {return DocCollection.create("collection1",slices,- Collections.singletonMap(- ZkStateReader.CONFIGNAME_PROP, ConfigSetsHandler.DEFAULT_CONFIGSET_NAME),+ Map.of(ZkStateReader.CONFIGNAME_PROP, ConfigSetsHandler.DEFAULT_CONFIGSET_NAME),router,Integer.MAX_VALUE,Instant.EPOCH,diff --git a/solr/core/src/test/org/apache/solr/cloud/TestRandomFlRTGCloud.java b/solr/core/src/test/org/apache/solr/cloud/TestRandomFlRTGCloud.javaindex 615c925b1cc..0423498ba6a 100644--- a/solr/core/src/test/org/apache/solr/cloud/TestRandomFlRTGCloud.java+++ b/solr/core/src/test/org/apache/solr/cloud/TestRandomFlRTGCloud.java@@ -739,7 +739,7 @@ public class TestRandomFlRTGCloud extends SolrCloudTestCase {expectedFieldName + " vs " + actualFieldName,expected.getFieldValue(expectedFieldName),normalize(wt, actual.getFirstValue(actualFieldName)));- return Collections.<String>singleton(actualFieldName);+ return Set.of(actualFieldName);}}@@ -785,7 +785,7 @@ public class TestRandomFlRTGCloud extends SolrCloudTestCase {@Overridepublic Set<String> getSuppressedFields() {- return Collections.singleton(expectedFieldName);+ return Set.of(expectedFieldName);}}@@ -834,14 +834,14 @@ public class TestRandomFlRTGCloud extends SolrCloudTestCase {// validates based on `actual.getFirstValue(...)`, it causes issues. Here we know that our// raw values are only on single-valued fields, so we wrap it to work around// `getFirstValue` in parent class. The same logic applies to `expected` (below)- actual.setField(actualFieldName, Collections.singleton(v));+ actual.setField(actualFieldName, Set.of(v));}try {Object parsedExpected =ObjectBuilder.fromJSON((String) expected.getFieldValue(expectedFieldName));if (parsedExpected instanceof Collection) {// see note above- parsedExpected = Collections.singleton(parsedExpected);+ parsedExpected = Set.of(parsedExpected);}expected = expected.deepCopy(); // need to copy before modifying expected!expected.setField(expectedFieldName, parsedExpected);@@ -972,7 +972,7 @@ public class TestRandomFlRTGCloud extends SolrCloudTestCase {}assertTrue(USAGE + " must be >= " + minValidDocId + ": " + value, minValidDocId <= (Integer) value);- return Collections.<String>singleton(resultKey);+ return Set.of(resultKey);}}@@ -1012,7 +1012,7 @@ public class TestRandomFlRTGCloud extends SolrCloudTestCase {// trivial sanity checkassertFalse(USAGE + " => blank string", value.toString().trim().isEmpty());- return Collections.<String>singleton(resultKey);+ return Set.of(resultKey);}}@@ -1052,7 +1052,7 @@ public class TestRandomFlRTGCloud extends SolrCloudTestCase {// trivial sanity checkassertFalse(USAGE + " => blank string", value.toString().trim().isEmpty());- return Collections.singleton(resultKey);+ return Set.of(resultKey);}}@@ -1103,7 +1103,7 @@ public class TestRandomFlRTGCloud extends SolrCloudTestCase {Object actualVal = normalize(wt, actual.getFirstValue(resultKey));assertNotNull(getFlParam() + " => no value in actual doc", actualVal);assertEquals(getFlParam(), expectedVal, actualVal);- return Collections.<String>singleton(resultKey);+ return Set.of(resultKey);}}@@ -1153,7 +1153,7 @@ public class TestRandomFlRTGCloud extends SolrCloudTestCase {"this validator only works on numeric fields: " + origVal, origVal instanceof Number);assertEquals(fl, 1.3F, normalize(wt, actual.getFirstValue(resultKey)));- return Collections.<String>singleton(resultKey);+ return Set.of(resultKey);}}@@ -1218,7 +1218,7 @@ public class TestRandomFlRTGCloud extends SolrCloudTestCase {((subDocIdVal < compVal) && ((compVal - 2) <= subDocIdVal)));}- return Collections.<String>singleton(SUBQ_KEY);+ return Set.of(SUBQ_KEY);}@Override@@ -1319,12 +1319,12 @@ public class TestRandomFlRTGCloud extends SolrCloudTestCase {}}assertEquals(fl, orig, actual.getFirstValue(resultKey));- return Collections.<String>singleton(resultKey);+ return Set.of(resultKey);}@Overridepublic Set<String> getSuppressedFields() {- return Collections.singleton(fieldName);+ return Set.of(fieldName);}}diff --git a/solr/core/src/test/org/apache/solr/cloud/TestStressCloudBlindAtomicUpdates.java b/solr/core/src/test/org/apache/solr/cloud/TestStressCloudBlindAtomicUpdates.javaindex 8f692d3006f..8abccaf7fbd 100644--- a/solr/core/src/test/org/apache/solr/cloud/TestStressCloudBlindAtomicUpdates.java+++ b/solr/core/src/test/org/apache/solr/cloud/TestStressCloudBlindAtomicUpdates.java@@ -21,7 +21,6 @@ import java.net.URL;import java.nio.file.Path;import java.util.ArrayList;import java.util.Arrays;-import java.util.Collections;import java.util.List;import java.util.Map;import java.util.Random;@@ -428,8 +427,7 @@ public class TestStressCloudBlindAtomicUpdates extends SolrCloudTestCase {log.info("worker={}, docId={}, delta={}", workerId, docId, delta);SolrClient client = getRandClient(rand);- SolrInputDocument doc =- doc(f("id", "" + docId), f(updateField, Collections.singletonMap("inc", delta)));+ SolrInputDocument doc = doc(f("id", "" + docId), f(updateField, Map.of("inc", delta)));UpdateResponse rsp = update(doc).process(client);assertEquals(doc + " => " + rsp, 0, rsp.getStatus());diff --git a/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java b/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.javaindex 702c077a066..5c7cd7442d3 100644--- a/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java@@ -27,7 +27,6 @@ import java.nio.charset.StandardCharsets;import java.nio.file.Path;import java.time.Duration;import java.time.Instant;-import java.util.Collections;import java.util.List;import java.util.Map;import java.util.Optional;@@ -257,7 +256,7 @@ public class ZkControllerTest extends SolrCloudTestCase {// to wait indefinitely when using coreNodeName but usage of core name alone will// return immediatelydescriptor.getCloudDescriptor().setCoreNodeName("core_node0");- return Collections.singletonList(descriptor);+ return List.of(descriptor);}};ZkController zkController = null;diff --git a/solr/core/src/test/org/apache/solr/cloud/ZkShardTermsTest.java b/solr/core/src/test/org/apache/solr/cloud/ZkShardTermsTest.javaindex eb0f3e183b8..7aed2e27d3d 100644--- a/solr/core/src/test/org/apache/solr/cloud/ZkShardTermsTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/ZkShardTermsTest.java@@ -65,7 +65,7 @@ public class ZkShardTermsTest extends SolrCloudTestCase {new ZkShardTerms(collection, "shard2", cluster.getZkClient())) {zkShardTerms.registerTerm("replica1");zkShardTerms.registerTerm("replica2");- zkShardTerms.ensureTermsIsHigher("replica1", Collections.singleton("replica2"));+ zkShardTerms.ensureTermsIsHigher("replica1", Set.of("replica2"));}// When new collection is created, the old term nodes will be removed@@ -94,7 +94,7 @@ public class ZkShardTermsTest extends SolrCloudTestCase {zkShardTerms.registerTerm("replica2");// normal case when leader failed to send an update to replica- zkShardTerms.ensureTermsIsHigher("replica1", Collections.singleton("replica2"));+ zkShardTerms.ensureTermsIsHigher("replica1", Set.of("replica2"));zkShardTerms.startRecovering("replica2");assertEquals(zkShardTerms.getTerm("replica2"), 1);assertEquals(zkShardTerms.getTerm("replica2_recovering"), 0);@@ -104,7 +104,7 @@ public class ZkShardTermsTest extends SolrCloudTestCase {assertEquals(zkShardTerms.getTerm("replica2"), 1);assertEquals(zkShardTerms.getTerm("replica2_recovering"), -1);- zkShardTerms.ensureTermsIsHigher("replica1", Collections.singleton("replica2"));+ zkShardTerms.ensureTermsIsHigher("replica1", Set.of("replica2"));assertEquals(zkShardTerms.getTerm("replica1"), 2);assertEquals(zkShardTerms.getTerm("replica2"), 1);assertEquals(zkShardTerms.getTerm("replica2_recovering"), -1);@@ -113,7 +113,7 @@ public class ZkShardTermsTest extends SolrCloudTestCase {assertEquals(zkShardTerms.getTerm("replica2"), 2);assertEquals(zkShardTerms.getTerm("replica2_recovering"), 1);- zkShardTerms.ensureTermsIsHigher("replica1", Collections.singleton("replica2"));+ zkShardTerms.ensureTermsIsHigher("replica1", Set.of("replica2"));assertEquals(zkShardTerms.getTerm("replica1"), 3);assertEquals(zkShardTerms.getTerm("replica2"), 2);assertEquals(zkShardTerms.getTerm("replica2_recovering"), 1);@@ -125,9 +125,9 @@ public class ZkShardTermsTest extends SolrCloudTestCase {zkShardTerms.startRecovering("replica2");zkShardTerms.doneRecovering("replica2");- zkShardTerms.ensureTermsIsHigher("replica1", Collections.singleton("replica2"));+ zkShardTerms.ensureTermsIsHigher("replica1", Set.of("replica2"));zkShardTerms.startRecovering("replica2");- zkShardTerms.ensureTermsIsHigher("replica1", Collections.singleton("replica2"));+ zkShardTerms.ensureTermsIsHigher("replica1", Set.of("replica2"));zkShardTerms.startRecovering("replica2");assertEquals(zkShardTerms.getTerm("replica1"), 5);assertEquals(zkShardTerms.getTerm("replica2"), 5);@@ -147,7 +147,7 @@ public class ZkShardTermsTest extends SolrCloudTestCase {zkShardTerms.registerTerm("replica2_rem");// normal case when leader failed to send an update to replica- zkShardTerms.ensureTermsIsHigher("replica1_rem", Collections.singleton("replica2_rem"));+ zkShardTerms.ensureTermsIsHigher("replica1_rem", Set.of("replica2_rem"));zkShardTerms.startRecovering("replica2_rem");assertEquals(zkShardTerms.getTerm("replica2_rem"), 1);assertEquals(zkShardTerms.getTerm("replica2_rem_recovering"), 0);@@ -174,7 +174,7 @@ public class ZkShardTermsTest extends SolrCloudTestCase {assertEquals(0L, zkShardTerms.getTerm("rep2"));}waitFor(2, () -> rep1Terms.getTerms().size());- rep1Terms.ensureTermsIsHigher("rep1", Collections.singleton("rep2"));+ rep1Terms.ensureTermsIsHigher("rep1", Set.of("rep2"));assertEquals(1L, rep1Terms.getTerm("rep1"));assertEquals(0L, rep1Terms.getTerm("rep2"));@@ -272,7 +272,7 @@ public class ZkShardTermsTest extends SolrCloudTestCase {replicaTerms.addListener(watcher);replicaTerms.registerTerm("replica");waitFor(1, count::get);- leaderTerms.ensureTermsIsHigher("leader", Collections.singleton("replica"));+ leaderTerms.ensureTermsIsHigher("leader", Set.of("replica"));waitFor(2, count::get);replicaTerms.setTermEqualsToLeader("replica");waitFor(3, count::get);@@ -287,7 +287,7 @@ public class ZkShardTermsTest extends SolrCloudTestCase {ZkShardTerms terms = new ZkShardTerms(collection, "shard1", cluster.getZkClient());terms.registerTerm("leader");terms.registerTerm("replica");- terms.ensureTermsIsHigher("leader", Collections.singleton("replica"));+ terms.ensureTermsIsHigher("leader", Set.of("replica"));assertEquals(1L, terms.getTerm("leader"));terms.setTermToZero("leader");assertEquals(0L, terms.getTerm("leader"));@@ -301,7 +301,7 @@ public class ZkShardTermsTest extends SolrCloudTestCase {leaderTerms.registerTerm("leader");replicaTerms.registerTerm("replica");- leaderTerms.ensureTermsIsHigher("leader", Collections.singleton("replica"));+ leaderTerms.ensureTermsIsHigher("leader", Set.of("replica"));waitFor(false, () -> replicaTerms.canBecomeLeader("replica"));waitFor(true, () -> leaderTerms.skipSendingUpdatesTo("replica"));@@ -324,7 +324,7 @@ public class ZkShardTermsTest extends SolrCloudTestCase {leaderTerms.registerTerm("leader");replicaTerms.registerTerm("replica");- leaderTerms.ensureTermsIsHigher("leader", Collections.singleton("replica"));+ leaderTerms.ensureTermsIsHigher("leader", Set.of("replica"));waitFor(false, () -> replicaTerms.canBecomeLeader("replica"));waitFor(true, () -> leaderTerms.skipSendingUpdatesTo("replica"));diff --git a/solr/core/src/test/org/apache/solr/cloud/api/collections/ShardSplitTest.java b/solr/core/src/test/org/apache/solr/cloud/api/collections/ShardSplitTest.javaindex 90421919c80..7fdf13328d1 100644--- a/solr/core/src/test/org/apache/solr/cloud/api/collections/ShardSplitTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/api/collections/ShardSplitTest.java@@ -21,7 +21,6 @@ import static org.apache.solr.common.cloud.ZkStateReader.REPLICATION_FACTOR;import java.io.IOException;import java.lang.invoke.MethodHandles;import java.util.ArrayList;-import java.util.Collections;import java.util.HashMap;import java.util.HashSet;import java.util.List;@@ -153,8 +152,7 @@ public class ShardSplitTest extends BasicDistributedZkTest {collectionName, 30, TimeUnit.SECONDS, SolrCloudTestCase.activeClusterShape(1, 1));var builder =- new RandomizingCloudSolrClientBuilder(- Collections.singletonList(zkServer.getZkAddress()), Optional.empty());+ new RandomizingCloudSolrClientBuilder(List.of(zkServer.getZkAddress()), Optional.empty());try (CloudSolrClient client =builderdiff --git a/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionsAPIViaSolrCloudCluster.java b/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionsAPIViaSolrCloudCluster.javaindex 4f6d009cfe5..747d7a9a8cb 100644--- a/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionsAPIViaSolrCloudCluster.java+++ b/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionsAPIViaSolrCloudCluster.java@@ -54,7 +54,7 @@ public class TestCollectionsAPIViaSolrCloudCluster extends SolrCloudTestCase {private static final String configName = "solrCloudCollectionConfig";private static final Map<String, String>collectionProperties // ensure indexes survive core shutdown- = Collections.singletonMap("solr.directoryFactory", "solr.StandardDirectoryFactory");+ = Map.of("solr.directoryFactory", "solr.StandardDirectoryFactory");@Overridepublic void setUp() throws Exception {diff --git a/solr/core/src/test/org/apache/solr/cloud/overseer/TestClusterStateMutator.java b/solr/core/src/test/org/apache/solr/cloud/overseer/TestClusterStateMutator.javaindex 96dd45b58b5..577b4467127 100644--- a/solr/core/src/test/org/apache/solr/cloud/overseer/TestClusterStateMutator.java+++ b/solr/core/src/test/org/apache/solr/cloud/overseer/TestClusterStateMutator.java@@ -19,7 +19,6 @@ package org.apache.solr.cloud.overseer;import static org.mockito.Mockito.mock;import static org.mockito.Mockito.when;-import java.util.Collections;import java.util.Map;import java.util.Set;import org.apache.solr.SolrTestCaseJ4;@@ -56,7 +55,7 @@ public class TestClusterStateMutator extends SolrTestCaseJ4 {assertEquals("xyz", collection.getName());assertEquals(1, collection.getSlicesMap().size());- ClusterState state = new ClusterState(Set.of(), Collections.singletonMap("xyz", collection));+ ClusterState state = new ClusterState(Set.of(), Map.of("xyz", collection));message =new ZkNodeProps(Map.of(diff --git a/solr/core/src/test/org/apache/solr/cloud/overseer/ZkStateReaderTest.java b/solr/core/src/test/org/apache/solr/cloud/overseer/ZkStateReaderTest.javaindex 3e7e575ca44..eb3eadff0e6 100644--- a/solr/core/src/test/org/apache/solr/cloud/overseer/ZkStateReaderTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/overseer/ZkStateReaderTest.java@@ -25,7 +25,6 @@ import java.lang.invoke.MethodHandles;import java.nio.file.Path;import java.time.Instant;import java.util.Arrays;-import java.util.Collections;import java.util.HashMap;import java.util.List;import java.util.Map;@@ -163,7 +162,7 @@ public class ZkStateReaderTest extends SolrTestCaseJ4 {PerReplicaStatesOps.getZkClientPrsSupplier(fixture.zkClient, DocCollection.getCollectionPath("c1"))));- writer.enqueueUpdate(reader.getClusterState(), Collections.singletonList(c1), null);+ writer.enqueueUpdate(reader.getClusterState(), List.of(c1), null);writer.writePendingUpdates();reader.forceUpdateCollection("c1");@@ -191,7 +190,7 @@ public class ZkStateReaderTest extends SolrTestCaseJ4 {PerReplicaStatesOps.getZkClientPrsSupplier(fixture.zkClient, DocCollection.getCollectionPath("c1")));ZkWriteCommand wc = new ZkWriteCommand("c1", state);- writer.enqueueUpdate(reader.getClusterState(), Collections.singletonList(wc), null);+ writer.enqueueUpdate(reader.getClusterState(), List.of(wc), null);writer.writePendingUpdates();assertTrue(fixture.zkClient.exists(ZkStateReader.COLLECTIONS_ZKNODE + "/c1/state.json"));reader.waitForState(@@ -211,7 +210,7 @@ public class ZkStateReaderTest extends SolrTestCaseJ4 {PerReplicaStatesOps.getZkClientPrsSupplier(fixture.zkClient, DocCollection.getCollectionPath("c1")));wc = new ZkWriteCommand("c1", state);- writer.enqueueUpdate(reader.getClusterState(), Collections.singletonList(wc), null);+ writer.enqueueUpdate(reader.getClusterState(), List.of(wc), null);writer.writePendingUpdates();boolean found = false;@@ -253,7 +252,7 @@ public class ZkStateReaderTest extends SolrTestCaseJ4 {PerReplicaStatesOps.getZkClientPrsSupplier(fixture.zkClient, DocCollection.getCollectionPath("c1")));ZkWriteCommand wc = new ZkWriteCommand("c1", state);- writer.enqueueUpdate(reader.getClusterState(), Collections.singletonList(wc), null);+ writer.enqueueUpdate(reader.getClusterState(), List.of(wc), null);writer.writePendingUpdates();assertTrue(fixture.zkClient.exists(ZkStateReader.COLLECTIONS_ZKNODE + "/c1/state.json"));@@ -296,7 +295,7 @@ public class ZkStateReaderTest extends SolrTestCaseJ4 {PerReplicaStatesOps.getZkClientPrsSupplier(fixture.zkClient, DocCollection.getCollectionPath("c1")));ZkWriteCommand wc = new ZkWriteCommand("c1", state);- writer.enqueueUpdate(clusterState, Collections.singletonList(wc), null);+ writer.enqueueUpdate(clusterState, List.of(wc), null);clusterState = writer.writePendingUpdates();// have to register it here after the updates, otherwise the child node watch will not be@@ -349,7 +348,7 @@ public class ZkStateReaderTest extends SolrTestCaseJ4 {// now delete the collectionwc = new ZkWriteCommand("c1", null);- writer.enqueueUpdate(clusterState, Collections.singletonList(wc), null);+ writer.enqueueUpdate(clusterState, List.of(wc), null);clusterState = writer.writePendingUpdates();timeOut.waitFor("Timeout on waiting for c1 to be removed from cluster state",@@ -358,7 +357,7 @@ public class ZkStateReaderTest extends SolrTestCaseJ4 {reader.unregisterCore("c1");// re-add the same collectionwc = new ZkWriteCommand("c1", state);- writer.enqueueUpdate(clusterState, Collections.singletonList(wc), null);+ writer.enqueueUpdate(clusterState, List.of(wc), null);clusterState = writer.writePendingUpdates();// re-register, otherwise the child watch would be missing from collection deletionreader.registerCore("c1");@@ -417,7 +416,7 @@ public class ZkStateReaderTest extends SolrTestCaseJ4 {PerReplicaStatesOps.getZkClientPrsSupplier(fixture.zkClient, DocCollection.getCollectionPath("c1")));ZkWriteCommand wc = new ZkWriteCommand("c1", state);- writer.enqueueUpdate(reader.getClusterState(), Collections.singletonList(wc), null);+ writer.enqueueUpdate(reader.getClusterState(), List.of(wc), null);writer.writePendingUpdates();assertTrue(fixture.zkClient.exists(ZkStateReader.COLLECTIONS_ZKNODE + "/c1/state.json"));@@ -440,7 +439,7 @@ public class ZkStateReaderTest extends SolrTestCaseJ4 {PerReplicaStatesOps.getZkClientPrsSupplier(fixture.zkClient, DocCollection.getCollectionPath("c1")));wc = new ZkWriteCommand("c1", state);- writer.enqueueUpdate(reader.getClusterState(), Collections.singletonList(wc), null);+ writer.enqueueUpdate(reader.getClusterState(), List.of(wc), null);writer.writePendingUpdates();reader.forciblyRefreshAllClusterStateSlow();@@ -504,7 +503,7 @@ public class ZkStateReaderTest extends SolrTestCaseJ4 {Instant.now(),null);ZkWriteCommand wc = new ZkWriteCommand("c1", state);- writer.enqueueUpdate(reader.getClusterState(), Collections.singletonList(wc), null);+ writer.enqueueUpdate(reader.getClusterState(), List.of(wc), null);writer.writePendingUpdates();assertTrue(fixture.zkClient.exists(ZkStateReader.COLLECTIONS_ZKNODE + "/c1/state.json"));@@ -526,7 +525,7 @@ public class ZkStateReaderTest extends SolrTestCaseJ4 {Instant.now(),null);wc = new ZkWriteCommand("c1", state);- writer.enqueueUpdate(reader.getClusterState(), Collections.singletonList(wc), null);+ writer.enqueueUpdate(reader.getClusterState(), List.of(wc), null);writer.writePendingUpdates();reader.forciblyRefreshAllClusterStateSlow();@@ -654,7 +653,7 @@ public class ZkStateReaderTest extends SolrTestCaseJ4 {PerReplicaStatesOps.getZkClientPrsSupplier(fixture.zkClient, DocCollection.getCollectionPath("c1")));ZkWriteCommand wc = new ZkWriteCommand("c1", state);- writer.enqueueUpdate(clusterState, Collections.singletonList(wc), null);+ writer.enqueueUpdate(clusterState, List.of(wc), null);clusterState = writer.writePendingUpdates();TimeUnit.MILLISECONDS.sleep(100);}@@ -763,7 +762,7 @@ public class ZkStateReaderTest extends SolrTestCaseJ4 {PerReplicaStatesOps.getZkClientPrsSupplier(fixture.zkClient, DocCollection.getCollectionPath("c1")));ZkWriteCommand wc = new ZkWriteCommand("c1", state);- writer.enqueueUpdate(clusterState, Collections.singletonList(wc), null);+ writer.enqueueUpdate(clusterState, List.of(wc), null);clusterState = writer.writePendingUpdates();barrier.await(250, TimeUnit.MILLISECONDS); // wait for the watch callback to executefixture.zkClient.makePath(ZkStateReader.COLLECTIONS_ZKNODE + "/c1" + i, true);@@ -799,14 +798,14 @@ public class ZkStateReaderTest extends SolrTestCaseJ4 {DocCollection.create(collectionName,Map.of(sliceName, slice),- Collections.singletonMap(DocCollection.CollectionStateProps.PER_REPLICA_STATE, true),+ Map.of(DocCollection.CollectionStateProps.PER_REPLICA_STATE, true),DocRouter.DEFAULT,0,Instant.now(),PerReplicaStatesOps.getZkClientPrsSupplier(fixture.zkClient, DocCollection.getCollectionPath(collectionName)));ZkWriteCommand wc = new ZkWriteCommand(collectionName, state);- writer.enqueueUpdate(clusterState, Collections.singletonList(wc), null);+ writer.enqueueUpdate(clusterState, List.of(wc), null);clusterState = writer.writePendingUpdates();TimeOut timeOut = new TimeOut(5000, TimeUnit.MILLISECONDS, TimeSource.NANO_TIME);@@ -842,7 +841,7 @@ public class ZkStateReaderTest extends SolrTestCaseJ4 {wc =new ZkWriteCommand(collectionName, SliceMutator.updateReplica(state, slice, replica.getName(), replica));- writer.enqueueUpdate(clusterState, Collections.singletonList(wc), null);+ writer.enqueueUpdate(clusterState, List.of(wc), null);clusterState = writer.writePendingUpdates();timeOut.waitFor(diff --git a/solr/core/src/test/org/apache/solr/cloud/overseer/ZkStateWriterTest.java b/solr/core/src/test/org/apache/solr/cloud/overseer/ZkStateWriterTest.javaindex f464523d406..6eed23c8b4e 100644--- a/solr/core/src/test/org/apache/solr/cloud/overseer/ZkStateWriterTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/overseer/ZkStateWriterTest.java@@ -19,8 +19,8 @@ package org.apache.solr.cloud.overseer;import java.lang.invoke.MethodHandles;import java.nio.file.Path;import java.time.Instant;-import java.util.Collections;import java.util.HashMap;+import java.util.List;import java.util.Map;import java.util.concurrent.TimeUnit;import java.util.concurrent.atomic.AtomicBoolean;@@ -88,8 +88,7 @@ public class ZkStateWriterTest extends SolrTestCaseJ4 {zkClient.makePath(ZkStateReader.COLLECTIONS_ZKNODE + "/c3", true);Map<String, Object> props =- Collections.singletonMap(- ZkStateReader.CONFIGNAME_PROP, ConfigSetsHandler.DEFAULT_CONFIGSET_NAME);+ Map.of(ZkStateReader.CONFIGNAME_PROP, ConfigSetsHandler.DEFAULT_CONFIGSET_NAME);ZkWriteCommand c1 = new ZkWriteCommand("c1", createDocCollection("c1", props));ZkWriteCommand c2 = new ZkWriteCommand("c2", createDocCollection("c2", props));ZkWriteCommand c3 = new ZkWriteCommand("c3", createDocCollection("c3", props));@@ -98,23 +97,17 @@ public class ZkStateWriterTest extends SolrTestCaseJ4 {// First write is flushed immediatelyClusterState clusterState =- writer.enqueueUpdate(reader.getClusterState(), Collections.singletonList(c1), null);- clusterState =- writer.enqueueUpdate(clusterState, Collections.singletonList(c1), FAIL_ON_WRITE);- clusterState =- writer.enqueueUpdate(clusterState, Collections.singletonList(c2), FAIL_ON_WRITE);+ writer.enqueueUpdate(reader.getClusterState(), List.of(c1), null);+ clusterState = writer.enqueueUpdate(clusterState, List.of(c1), FAIL_ON_WRITE);+ clusterState = writer.enqueueUpdate(clusterState, List.of(c2), FAIL_ON_WRITE);Thread.sleep(Overseer.STATE_UPDATE_DELAY + 100);AtomicBoolean didWrite = new AtomicBoolean(false);- clusterState =- writer.enqueueUpdate(- clusterState, Collections.singletonList(c3), () -> didWrite.set(true));+ clusterState = writer.enqueueUpdate(clusterState, List.of(c3), () -> didWrite.set(true));assertTrue("Exceed the update delay, should be flushed", didWrite.get());for (int i = 0; i <= Overseer.STATE_UPDATE_BATCH_SIZE; i++) {- clusterState =- writer.enqueueUpdate(- clusterState, Collections.singletonList(c3), () -> didWrite.set(true));+ clusterState = writer.enqueueUpdate(clusterState, List.of(c3), () -> didWrite.set(true));}assertTrue("Exceed the update batch size, should be flushed", didWrite.get());}@@ -172,22 +165,16 @@ public class ZkStateWriterTest extends SolrTestCaseJ4 {// First write is flushed immediatelyClusterState clusterState =- writer.enqueueUpdate(reader.getClusterState(), Collections.singletonList(c1), null);- clusterState =- writer.enqueueUpdate(clusterState, Collections.singletonList(c1), FAIL_ON_WRITE);- clusterState =- writer.enqueueUpdate(clusterState, Collections.singletonList(c2), FAIL_ON_WRITE);+ writer.enqueueUpdate(reader.getClusterState(), List.of(c1), null);+ clusterState = writer.enqueueUpdate(clusterState, List.of(c1), FAIL_ON_WRITE);+ clusterState = writer.enqueueUpdate(clusterState, List.of(c2), FAIL_ON_WRITE);Thread.sleep(Overseer.STATE_UPDATE_DELAY + 100);AtomicBoolean didWrite = new AtomicBoolean(false);- clusterState =- writer.enqueueUpdate(- clusterState, Collections.singletonList(prs1), () -> didWrite.set(true));+ clusterState = writer.enqueueUpdate(clusterState, List.of(prs1), () -> didWrite.set(true));assertTrue("Exceed the update delay, should be flushed", didWrite.get());didWrite.set(false);- clusterState =- writer.enqueueUpdate(- clusterState, Collections.singletonList(c3), () -> didWrite.set(true));+ clusterState = writer.enqueueUpdate(clusterState, List.of(c3), () -> didWrite.set(true));assertTrue("Exceed the update delay, should be flushed", didWrite.get());assertTrue("The updates queue should be empty having been flushed", writer.updates.isEmpty());@@ -247,19 +234,16 @@ public class ZkStateWriterTest extends SolrTestCaseJ4 {// First write is flushed immediatelyClusterState clusterState =- writer.enqueueUpdate(reader.getClusterState(), Collections.singletonList(c1), null);+ writer.enqueueUpdate(reader.getClusterState(), List.of(c1), null);AtomicBoolean didWrite = new AtomicBoolean(false);AtomicBoolean didWritePrs = new AtomicBoolean(false);for (int i = 0; i <= Overseer.STATE_UPDATE_BATCH_SIZE; i++) {- clusterState =- writer.enqueueUpdate(- clusterState, Collections.singletonList(c3), () -> didWrite.set(true));+ clusterState = writer.enqueueUpdate(clusterState, List.of(c3), () -> didWrite.set(true));// Write a PRS update in the middle and make sure we still get the right resultsif (i == (Overseer.STATE_UPDATE_BATCH_SIZE / 2)) {clusterState =- writer.enqueueUpdate(- clusterState, Collections.singletonList(prs1), () -> didWritePrs.set(true));+ writer.enqueueUpdate(clusterState, List.of(prs1), () -> didWritePrs.set(true));}}assertTrue("Exceed the update batch size, should be flushed", didWrite.get());@@ -305,10 +289,10 @@ public class ZkStateWriterTest extends SolrTestCaseJ4 {"c1",createDocCollection("c1",- Collections.singletonMap(+ Map.of(ZkStateReader.CONFIGNAME_PROP, ConfigSetsHandler.DEFAULT_CONFIGSET_NAME)));- writer.enqueueUpdate(reader.getClusterState(), Collections.singletonList(c1), null);+ writer.enqueueUpdate(reader.getClusterState(), List.of(c1), null);ClusterState clusterState = writer.writePendingUpdates();Map<?, ?> map =@@ -364,9 +348,9 @@ public class ZkStateWriterTest extends SolrTestCaseJ4 {"c2",createDocCollection("c2",- Collections.singletonMap(+ Map.of(ZkStateReader.CONFIGNAME_PROP, ConfigSetsHandler.DEFAULT_CONFIGSET_NAME)));- state = writer.enqueueUpdate(state, Collections.singletonList(c2), null);+ state = writer.enqueueUpdate(state, List.of(c2), null);assertFalse(writer.hasPendingUpdates()); // first write is flushed immediatelyint c2Version = state.getCollection("c2").getZNodeVersion();@@ -388,7 +372,7 @@ public class ZkStateWriterTest extends SolrTestCaseJ4 {assertTrue(state.hasCollection("c2"));assertEquals(c2Version + 1, state.getCollection("c2").getZNodeVersion());- writer.enqueueUpdate(state, Collections.singletonList(c2), null);+ writer.enqueueUpdate(state, List.of(c2), null);assertTrue(writer.hasPendingUpdates());// get the most up-to-date state@@ -402,18 +386,18 @@ public class ZkStateWriterTest extends SolrTestCaseJ4 {"c1",createDocCollection("c1",- Collections.singletonMap(+ Map.of(ZkStateReader.CONFIGNAME_PROP, ConfigSetsHandler.DEFAULT_CONFIGSET_NAME)));try {- writer.enqueueUpdate(state, Collections.singletonList(c1), null);+ writer.enqueueUpdate(state, List.of(c1), null);fail("Enqueue should not have succeeded");} catch (KeeperException.BadVersionException bve) {// expected}try {- writer.enqueueUpdate(reader.getClusterState(), Collections.singletonList(c2), null);+ writer.enqueueUpdate(reader.getClusterState(), List.of(c2), null);fail("enqueueUpdate after BadVersionException should not have succeeded");} catch (IllegalStateException e) {// expected@@ -461,7 +445,7 @@ public class ZkStateWriterTest extends SolrTestCaseJ4 {// create new collection with stateFormat = 2ZkWriteCommand c1 = new ZkWriteCommand("c1", createDocCollection("c1", new HashMap<>()));- writer.enqueueUpdate(reader.getClusterState(), Collections.singletonList(c1), null);+ writer.enqueueUpdate(reader.getClusterState(), List.of(c1), null);writer.writePendingUpdates();byte[] data =@@ -497,7 +481,7 @@ public class ZkStateWriterTest extends SolrTestCaseJ4 {DocCollection.create("c2", slices, new HashMap<>(), DocRouter.DEFAULT, 0, Instant.now(), null));- writer.enqueueUpdate(reader.getClusterState(), Collections.singletonList(c1), null);+ writer.enqueueUpdate(reader.getClusterState(), List.of(c1), null);writer.writePendingUpdates();byte[] dataCompressed =diff --git a/solr/core/src/test/org/apache/solr/cluster/events/ClusterEventProducerTest.java b/solr/core/src/test/org/apache/solr/cluster/events/ClusterEventProducerTest.javaindex 6f217be9644..bdf6d51b49b 100644--- a/solr/core/src/test/org/apache/solr/cluster/events/ClusterEventProducerTest.java+++ b/solr/core/src/test/org/apache/solr/cluster/events/ClusterEventProducerTest.java@@ -17,14 +17,12 @@package org.apache.solr.cluster.events;-import static java.util.Collections.singletonMap;import static org.apache.solr.client.solrj.SolrRequest.METHOD.GET;import static org.apache.solr.client.solrj.SolrRequest.METHOD.POST;import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering;import java.lang.invoke.MethodHandles;import java.time.Instant;-import java.util.Collections;import java.util.List;import java.util.Map;import java.util.concurrent.CountDownLatch;@@ -103,7 +101,7 @@ public class ClusterEventProducerTest extends SolrCloudTestCase {V2Request req =new V2Request.Builder("/cluster/plugin").withMethod(POST)- .withPayload(Collections.singletonMap("remove", ClusterEventProducer.PLUGIN_NAME))+ .withPayload(Map.of("remove", ClusterEventProducer.PLUGIN_NAME)).build();req.process(cluster.getSolrClient());}@@ -119,7 +117,7 @@ public class ClusterEventProducerTest extends SolrCloudTestCase {V2Request req =new V2Request.Builder("/cluster/plugin").withMethod(POST)- .withPayload(Collections.singletonMap("add", plugin))+ .withPayload(Map.of("add", plugin)).build();V2Response rsp = req.process(cluster.getSolrClient());assertEquals(0, rsp.getStatus());@@ -341,7 +339,7 @@ public class ClusterEventProducerTest extends SolrCloudTestCase {V2Request req =new V2Request.Builder("/cluster/plugin").withMethod(POST)- .withPayload(Collections.singletonMap("add", plugin))+ .withPayload(Map.of("add", plugin)).build();V2Response rsp = req.process(cluster.getSolrClient());assertEquals(0, rsp.getStatus());@@ -354,7 +352,7 @@ public class ClusterEventProducerTest extends SolrCloudTestCase {new V2Request.Builder("/cluster/plugin").forceV2(true).withMethod(POST)- .withPayload(singletonMap("add", plugin))+ .withPayload(Map.of("add", plugin)).build();rsp = req.process(cluster.getSolrClient());// just check if the plugin is indeed registered@@ -419,7 +417,7 @@ public class ClusterEventProducerTest extends SolrCloudTestCase {req =new V2Request.Builder("/cluster/plugin").withMethod(POST)- .withPayload(Collections.singletonMap("remove", ClusterEventProducer.PLUGIN_NAME))+ .withPayload(Map.of("remove", ClusterEventProducer.PLUGIN_NAME)).build();req.process(cluster.getSolrClient());version = phaser.awaitAdvanceInterruptibly(version, 10, TimeUnit.SECONDS);@@ -440,7 +438,7 @@ public class ClusterEventProducerTest extends SolrCloudTestCase {req =new V2Request.Builder("/cluster/plugin").withMethod(POST)- .withPayload(Collections.singletonMap("add", plugin))+ .withPayload(Map.of("add", plugin)).build();rsp = req.process(cluster.getSolrClient());assertEquals(0, rsp.getStatus());diff --git a/solr/core/src/test/org/apache/solr/cluster/events/impl/CollectionsRepairEventListenerTest.java b/solr/core/src/test/org/apache/solr/cluster/events/impl/CollectionsRepairEventListenerTest.javaindex 2aec62eaa7c..3d621cc63c1 100644--- a/solr/core/src/test/org/apache/solr/cluster/events/impl/CollectionsRepairEventListenerTest.java+++ b/solr/core/src/test/org/apache/solr/cluster/events/impl/CollectionsRepairEventListenerTest.java@@ -20,7 +20,7 @@ package org.apache.solr.cluster.events.impl;import static org.apache.solr.client.solrj.SolrRequest.METHOD.POST;import java.io.IOException;-import java.util.Collections;+import java.util.Map;import java.util.concurrent.CountDownLatch;import java.util.concurrent.TimeUnit;import org.apache.commons.io.IOUtils;@@ -107,7 +107,7 @@ public class CollectionsRepairEventListenerTest extends SolrCloudTestCase {V2Request req =new V2Request.Builder("/cluster/plugin").withMethod(POST)- .withPayload(Collections.singletonMap("add", plugin))+ .withPayload(Map.of("add", plugin)).build();V2Response rsp = req.process(cluster.getSolrClient());assertNotNull(rsp);diff --git a/solr/core/src/test/org/apache/solr/cluster/maintenance/InactiveShardRemoverTest.java b/solr/core/src/test/org/apache/solr/cluster/maintenance/InactiveShardRemoverTest.javaindex b3a267bfdb7..f88815c7254 100644--- a/solr/core/src/test/org/apache/solr/cluster/maintenance/InactiveShardRemoverTest.java+++ b/solr/core/src/test/org/apache/solr/cluster/maintenance/InactiveShardRemoverTest.java@@ -21,7 +21,6 @@ import static org.apache.solr.client.solrj.SolrRequest.METHOD.POST;import java.io.IOException;import java.util.ArrayList;-import java.util.Collections;import java.util.Map;import java.util.concurrent.TimeUnit;import org.apache.solr.client.solrj.SolrServerException;@@ -168,11 +167,11 @@ public class InactiveShardRemoverTest extends SolrCloudTestCase {private static void addPlugin(final InactiveShardRemoverConfig config)throws SolrServerException, IOException {PluginMeta plugin = pluginMeta(config);- pluginRequest(Collections.singletonMap("add", plugin));+ pluginRequest(Map.of("add", plugin));}private static void removePlugin() throws SolrServerException, IOException {- pluginRequest(Collections.singletonMap("remove", InactiveShardRemover.PLUGIN_NAME));+ pluginRequest(Map.of("remove", InactiveShardRemover.PLUGIN_NAME));}private static void pluginRequest(Map<String, Object> payload)diff --git a/solr/core/src/test/org/apache/solr/cluster/placement/impl/PlacementPluginIntegrationTest.java b/solr/core/src/test/org/apache/solr/cluster/placement/impl/PlacementPluginIntegrationTest.javaindex 0c81722721c..3ffb39bf373 100644--- a/solr/core/src/test/org/apache/solr/cluster/placement/impl/PlacementPluginIntegrationTest.java+++ b/solr/core/src/test/org/apache/solr/cluster/placement/impl/PlacementPluginIntegrationTest.java@@ -17,7 +17,6 @@package org.apache.solr.cluster.placement.impl;-import static java.util.Collections.singletonMap;import static org.hamcrest.Matchers.instanceOf;import java.util.Arrays;@@ -145,7 +144,7 @@ public class PlacementPluginIntegrationTest extends SolrCloudTestCase {new V2Request.Builder("/cluster/plugin").forceV2(true).POST()- .withPayload(singletonMap("add", plugin))+ .withPayload(Map.of("add", plugin)).build();req.process(cluster.getSolrClient());@@ -203,7 +202,7 @@ public class PlacementPluginIntegrationTest extends SolrCloudTestCase {new V2Request.Builder("/cluster/plugin").forceV2(true).POST()- .withPayload(singletonMap("add", plugin))+ .withPayload(Map.of("add", plugin)).build();req.process(cluster.getSolrClient());@@ -221,7 +220,7 @@ public class PlacementPluginIntegrationTest extends SolrCloudTestCase {new V2Request.Builder("/cluster/plugin").forceV2(true).POST()- .withPayload(singletonMap("update", plugin))+ .withPayload(Map.of("update", plugin)).build();req.process(cluster.getSolrClient());@@ -241,7 +240,7 @@ public class PlacementPluginIntegrationTest extends SolrCloudTestCase {new V2Request.Builder("/cluster/plugin").forceV2(true).POST()- .withPayload(singletonMap("update", plugin))+ .withPayload(Map.of("update", plugin)).build();req.process(cluster.getSolrClient());@@ -260,7 +259,7 @@ public class PlacementPluginIntegrationTest extends SolrCloudTestCase {new V2Request.Builder("/cluster/plugin").forceV2(true).POST()- .withPayload(singletonMap("add", plugin))+ .withPayload(Map.of("add", plugin)).build();req.process(cluster.getSolrClient());final int oldVersion = version;@@ -312,7 +311,7 @@ public class PlacementPluginIntegrationTest extends SolrCloudTestCase {new V2Request.Builder("/cluster/plugin").forceV2(true).POST()- .withPayload(singletonMap("add", plugin))+ .withPayload(Map.of("add", plugin)).build();req.process(cluster.getSolrClient());@@ -413,7 +412,7 @@ public class PlacementPluginIntegrationTest extends SolrCloudTestCase {new V2Request.Builder("/cluster/plugin").forceV2(true).POST()- .withPayload(singletonMap("add", plugin))+ .withPayload(Map.of("add", plugin)).build();req.process(cluster.getSolrClient());diff --git a/solr/core/src/test/org/apache/solr/cluster/placement/plugins/SimplePlacementFactoryTest.java b/solr/core/src/test/org/apache/solr/cluster/placement/plugins/SimplePlacementFactoryTest.javaindex 2f4d81f8658..00d18cce762 100644--- a/solr/core/src/test/org/apache/solr/cluster/placement/plugins/SimplePlacementFactoryTest.java+++ b/solr/core/src/test/org/apache/solr/cluster/placement/plugins/SimplePlacementFactoryTest.java@@ -157,7 +157,7 @@ public class SimplePlacementFactoryTest extends AbstractPlacementFactoryTest {shard ->new PlacementRequestImpl(solrCollection,- Collections.singleton(shard),+ Set.of(shard),new HashSet<>(liveNodes),ReplicaCount.of(1, 0, 0))).collect(Collectors.toList());diff --git a/solr/core/src/test/org/apache/solr/core/CoreSorterTest.java b/solr/core/src/test/org/apache/solr/core/CoreSorterTest.javaindex 78e8cae727f..c753a800f1f 100644--- a/solr/core/src/test/org/apache/solr/core/CoreSorterTest.java+++ b/solr/core/src/test/org/apache/solr/core/CoreSorterTest.java@@ -124,7 +124,7 @@ public class CoreSorterTest extends SolrTestCaseJ4 {String slice = "s" + shardCounts.hashCode();List<Replica> replicas = new ArrayList<>();for (int myRepNum = 0; myRepNum < shardCounts.myReplicas; myRepNum++) {- addNewReplica(replicas, collection, slice, Collections.singletonList(thisNode));+ addNewReplica(replicas, collection, slice, List.of(thisNode));// save this mapping for latermyCountsToDescs.put(shardCounts,@@ -145,8 +145,7 @@ public class CoreSorterTest extends SolrTestCaseJ4 {DocCollection.create(collection,sliceMap,- Collections.singletonMap(- ZkStateReader.CONFIGNAME_PROP, ConfigSetsHandler.DEFAULT_CONFIGSET_NAME),+ Map.of(ZkStateReader.CONFIGNAME_PROP, ConfigSetsHandler.DEFAULT_CONFIGSET_NAME),DocRouter.DEFAULT,Integer.MAX_VALUE,Instant.EPOCH,diff --git a/solr/core/src/test/org/apache/solr/core/DirectoryFactoriesTest.java b/solr/core/src/test/org/apache/solr/core/DirectoryFactoriesTest.javaindex f3a9bc5da50..1cdcaf3e8ed 100644--- a/solr/core/src/test/org/apache/solr/core/DirectoryFactoriesTest.java+++ b/solr/core/src/test/org/apache/solr/core/DirectoryFactoriesTest.java@@ -18,8 +18,8 @@package org.apache.solr.core;import java.util.Arrays;-import java.util.Collections;import java.util.List;+import java.util.Set;import org.apache.lucene.store.Directory;import org.apache.lucene.store.IOContext;import org.apache.lucene.store.IndexOutput;@@ -81,7 +81,7 @@ public class DirectoryFactoriesTest extends SolrTestCaseJ4 {// ... or should *all* Caching DirFactories consult the cache as well as the disk itself?// assertTrue(path + " should exist once file is closed", dirFac.exists(path));- dir.sync(Collections.singleton("test_file"));+ dir.sync(Set.of("test_file"));assertTrue(path + " should exist once file is synced", dirFac.exists(path));} finally {diff --git a/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.java b/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.javaindex f2169aca648..1b1c1de0662 100644--- a/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.java+++ b/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.java@@ -26,7 +26,6 @@ import java.io.InputStream;import java.nio.charset.CharacterCodingException;import java.nio.file.Files;import java.nio.file.Path;-import java.util.Collections;import java.util.HashMap;import java.util.List;import java.util.Map;@@ -227,8 +226,7 @@ public class ResourceLoaderTest extends SolrTestCaseJ4 {assertNotNull(loader.getClassLoader().getResource("aLibFile"));// add individual jars from other paths- loader.addToClassLoader(- Collections.singletonList(otherLib.resolve("jar2.jar").toUri().toURL()));+ loader.addToClassLoader(List.of(otherLib.resolve("jar2.jar").toUri().toURL()));assertNotNull(loader.getClassLoader().getResource("explicitFile"));assertNull(loader.getClassLoader().getResource("otherFile"));diff --git a/solr/core/src/test/org/apache/solr/core/TestConfigSetService.java b/solr/core/src/test/org/apache/solr/core/TestConfigSetService.javaindex 883567b6734..3d259c95e8a 100644--- a/solr/core/src/test/org/apache/solr/core/TestConfigSetService.java+++ b/solr/core/src/test/org/apache/solr/core/TestConfigSetService.java@@ -23,9 +23,9 @@ import java.nio.charset.StandardCharsets;import java.nio.file.Files;import java.nio.file.Path;import java.util.Arrays;-import java.util.Collections;import java.util.HashMap;import java.util.List;+import java.util.Map;import java.util.function.Supplier;import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.cloud.ZkConfigSetService;@@ -91,8 +91,7 @@ public class TestConfigSetService extends SolrTestCaseJ4 {configSetService.uploadFileToConfig(configName, "subdir/file4", data, true);assertArrayEquals(configSetService.downloadFileFromConfig(configName, "subdir/file4"), data);- configSetService.setConfigMetadata(- configName, new HashMap<>(Collections.singletonMap("foo", true)));+ configSetService.setConfigMetadata(configName, new HashMap<>(Map.of("foo", true)));assertTrue(configSetService.getConfigMetadata(configName).containsKey("foo"));List<String> configFiles = configSetService.getAllConfigFiles(configName);diff --git a/solr/core/src/test/org/apache/solr/core/TestInitParams.java b/solr/core/src/test/org/apache/solr/core/TestInitParams.javaindex c328055d126..89ae2fb08e1 100644--- a/solr/core/src/test/org/apache/solr/core/TestInitParams.java+++ b/solr/core/src/test/org/apache/solr/core/TestInitParams.java@@ -16,10 +16,9 @@*/package org.apache.solr.core;-import static java.util.Collections.singletonMap;-import java.util.Arrays;import java.util.HashMap;+import java.util.Map;import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.common.util.NamedList;import org.apache.solr.request.SolrRequestHandler;@@ -55,7 +54,7 @@ public class TestInitParams extends SolrTestCaseJ4 {new PluginInfo("requestHandler",new HashMap<>(),- new NamedList<>(singletonMap("defaults", new NamedList<>(singletonMap("a", "A1")))),+ new NamedList<>(Map.of("defaults", new NamedList<>(Map.of("a", "A1")))),null);initParams.apply(pluginInfo);assertEquals("A", initParams.defaults.get("a"));@@ -116,15 +115,14 @@ public class TestInitParams extends SolrTestCaseJ4 {public void testMatchPath() {InitParams initParams =- new InitParams(new PluginInfo(InitParams.TYPE, singletonMap("path", "/update/json/docs")));+ new InitParams(new PluginInfo(InitParams.TYPE, Map.of("path", "/update/json/docs")));assertFalse(initParams.matchPath("/update"));assertTrue(initParams.matchPath("/update/json/docs"));- initParams =- new InitParams(new PluginInfo(InitParams.TYPE, singletonMap("path", "/update/**")));+ initParams = new InitParams(new PluginInfo(InitParams.TYPE, Map.of("path", "/update/**")));assertTrue(initParams.matchPath("/update/json/docs"));assertTrue(initParams.matchPath("/update/json"));assertTrue(initParams.matchPath("/update"));- initParams = new InitParams(new PluginInfo(InitParams.TYPE, singletonMap("path", "/update/*")));+ initParams = new InitParams(new PluginInfo(InitParams.TYPE, Map.of("path", "/update/*")));assertFalse(initParams.matchPath("/update/json/docs"));assertTrue(initParams.matchPath("/update/json"));assertTrue(initParams.matchPath("/update"));diff --git a/solr/core/src/test/org/apache/solr/filestore/TestDistribFileStore.java b/solr/core/src/test/org/apache/solr/filestore/TestDistribFileStore.javaindex a5c0d8fdb86..8e7b5ab80ed 100644--- a/solr/core/src/test/org/apache/solr/filestore/TestDistribFileStore.java+++ b/solr/core/src/test/org/apache/solr/filestore/TestDistribFileStore.java@@ -47,6 +47,7 @@ import org.apache.solr.common.params.CommonParams;import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.common.util.JavaBinCodec;import org.apache.solr.common.util.StrUtils;+import org.apache.solr.common.util.SuppressForbidden;import org.apache.solr.common.util.Utils;import org.apache.solr.embedded.JettySolrRunner;import org.apache.solr.packagemanager.PackageUtils;@@ -68,6 +69,7 @@ public class TestDistribFileStore extends SolrCloudTestCase {}@Test+ @SuppressForbidden(reason = "singletonMap with null value is intentional")public void testFileStoreManagement() throws Exception {MiniSolrCloudCluster cluster =configureCluster(4)diff --git a/solr/core/src/test/org/apache/solr/handler/DocumentAnalysisRequestHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/DocumentAnalysisRequestHandlerTest.javaindex 4ce6b67a06e..07b912a50b8 100644--- a/solr/core/src/test/org/apache/solr/handler/DocumentAnalysisRequestHandlerTest.java+++ b/solr/core/src/test/org/apache/solr/handler/DocumentAnalysisRequestHandlerTest.java@@ -21,8 +21,8 @@ import java.io.IOException;import java.io.InputStream;import java.io.Reader;import java.nio.charset.StandardCharsets;-import java.util.Collections;import java.util.List;+import java.util.Set;import org.apache.lucene.tests.analysis.MockTokenizer;import org.apache.solr.client.solrj.request.DocumentAnalysisRequest;import org.apache.solr.common.SolrInputDocument;@@ -83,7 +83,7 @@ public class DocumentAnalysisRequestHandlerTest extends AnalysisRequestHandlerTenew SolrQueryRequestBase(h.getCore(), params) {@Overridepublic Iterable<ContentStream> getContentStreams() {- return Collections.singleton(cs);+ return Set.of(cs);}};@@ -154,7 +154,7 @@ public class DocumentAnalysisRequestHandlerTest extends AnalysisRequestHandlerTenew SolrQueryRequestBase(h.getCore(), params) {@Overridepublic Iterable<ContentStream> getContentStreams() {- return Collections.singleton(cs);+ return Set.of(cs);}};@@ -187,7 +187,7 @@ public class DocumentAnalysisRequestHandlerTest extends AnalysisRequestHandlerTenew SolrQueryRequestBase(h.getCore(), params) {@Overridepublic Iterable<ContentStream> getContentStreams() {- return Collections.singleton(cs);+ return Set.of(cs);}};diff --git a/solr/core/src/test/org/apache/solr/handler/TestContainerPlugin.java b/solr/core/src/test/org/apache/solr/handler/TestContainerPlugin.javaindex 06593f4b3ab..8f6208449da 100644--- a/solr/core/src/test/org/apache/solr/handler/TestContainerPlugin.java+++ b/solr/core/src/test/org/apache/solr/handler/TestContainerPlugin.java@@ -17,8 +17,6 @@package org.apache.solr.handler;-import static java.util.Collections.singletonList;-import static java.util.Collections.singletonMap;import static org.apache.solr.client.solrj.SolrRequest.METHOD.GET;import static org.apache.solr.filestore.TestDistribFileStore.readFile;import static org.apache.solr.filestore.TestDistribFileStore.uploadKey;@@ -27,6 +25,7 @@ import static org.hamcrest.Matchers.containsString;import java.io.IOException;import java.io.InputStream;import java.nio.ByteBuffer;+import java.util.List;import java.util.Map;import java.util.Objects;import java.util.concurrent.Callable;@@ -152,7 +151,7 @@ public class TestContainerPlugin extends SolrCloudTestCase {int version = phaser.getPhase();PluginMeta plugin = new PluginMeta();- V2Request addPlugin = postPlugin(singletonMap("add", plugin));+ V2Request addPlugin = postPlugin(Map.of("add", plugin));// test with an invalid classtry (ErrorLogMuter errors = ErrorLogMuter.substring("TestContainerPlugin$C2")) {@@ -238,7 +237,7 @@ public class TestContainerPlugin extends SolrCloudTestCase {// update the clusterSingleton configc6Cfg.strVal = "updated";- postPlugin(singletonMap("update", plugin)).process(cluster.getSolrClient());+ postPlugin(Map.of("update", plugin)).process(cluster.getSolrClient());version = phaser.awaitAdvanceInterruptibly(version, 10, TimeUnit.SECONDS);assertTrue("stopCalled", C6.stopCalled);@@ -259,7 +258,7 @@ public class TestContainerPlugin extends SolrCloudTestCase {p.klass = CC.class.getName();p.config = cfg;- postPlugin(singletonMap("add", p)).process(cluster.getSolrClient());+ postPlugin(Map.of("add", p)).process(cluster.getSolrClient());version = phaser.awaitAdvanceInterruptibly(version, 10, TimeUnit.SECONDS);@@ -269,7 +268,7 @@ public class TestContainerPlugin extends SolrCloudTestCase {"/config/boolVal", "true", "/config/strVal", "Something", "/config/longVal", "1234"));cfg.strVal = "Something else";- postPlugin(singletonMap("update", p)).process(cluster.getSolrClient());+ postPlugin(Map.of("update", p)).process(cluster.getSolrClient());version = phaser.awaitAdvanceInterruptibly(version, 10, TimeUnit.SECONDS);TestDistribFileStore.assertResponseValues(@@ -312,12 +311,12 @@ public class TestContainerPlugin extends SolrCloudTestCase {PackagePayload.AddVersion add = new PackagePayload.AddVersion();add.version = "1.0";add.pkg = "mypkg";- add.files = singletonList(FILE1);+ add.files = List.of(FILE1);V2Request addPkgVersionReq =new V2Request.Builder("/cluster/package").forceV2(forceV2).POST()- .withPayload(singletonMap("add", add))+ .withPayload(Map.of("add", add)).build();addPkgVersionReq.process(cluster.getSolrClient());assertTrue(@@ -337,7 +336,7 @@ public class TestContainerPlugin extends SolrCloudTestCase {plugin.name = "myplugin";plugin.klass = "mypkg:org.apache.solr.handler.MyPlugin";plugin.version = add.version;- final V2Request addPluginReq = postPlugin(singletonMap("add", plugin));+ final V2Request addPluginReq = postPlugin(Map.of("add", plugin));addPluginReq.process(cluster.getSolrClient());version = phaser.awaitAdvanceInterruptibly(version, 10, TimeUnit.SECONDS);@@ -353,12 +352,12 @@ public class TestContainerPlugin extends SolrCloudTestCase {// now let's upload the jar file for version 2.0 of the pluginadd.version = "2.0";- add.files = singletonList(FILE2);+ add.files = List.of(FILE2);addPkgVersionReq.process(cluster.getSolrClient());// here the plugin version is updatedplugin.version = add.version;- postPlugin(singletonMap("update", plugin)).process(cluster.getSolrClient());+ postPlugin(Map.of("update", plugin)).process(cluster.getSolrClient());version = phaser.awaitAdvanceInterruptibly(version, 10, TimeUnit.SECONDS);// now verify if it is indeed updated@@ -390,7 +389,7 @@ public class TestContainerPlugin extends SolrCloudTestCase {plugin.klass = ConfigurablePluginWithValidation.class.getName();plugin.config = config;- final V2Request addPlugin = postPlugin(singletonMap("add", plugin));+ final V2Request addPlugin = postPlugin(Map.of("add", plugin));// Verify that the expected error is thrown and the plugin is not registeredexpectError(addPlugin, "invalid config");diff --git a/solr/core/src/test/org/apache/solr/handler/admin/AdminHandlersProxyTest.java b/solr/core/src/test/org/apache/solr/handler/admin/AdminHandlersProxyTest.javaindex 14411a38876..8e7b383db7f 100644--- a/solr/core/src/test/org/apache/solr/handler/admin/AdminHandlersProxyTest.java+++ b/solr/core/src/test/org/apache/solr/handler/admin/AdminHandlersProxyTest.java@@ -18,7 +18,7 @@package org.apache.solr.handler.admin;import java.io.IOException;-import java.util.Collections;+import java.util.Map;import java.util.Set;import org.apache.solr.client.solrj.SolrServerException;import org.apache.solr.client.solrj.impl.CloudSolrClient;@@ -50,7 +50,7 @@ public class AdminHandlersProxyTest extends SolrCloudTestCase {@Testpublic void proxySystemInfoHandlerAllNodes() throws IOException, SolrServerException {- MapSolrParams params = new MapSolrParams(Collections.singletonMap("nodes", "all"));+ MapSolrParams params = new MapSolrParams(Map.of("nodes", "all"));SystemInfoRequest req = new SystemInfoRequest(params);SystemInfoResponse rsp = req.process(solrClient, null);@@ -64,8 +64,7 @@ public class AdminHandlersProxyTest extends SolrCloudTestCase {@Test(expected = SolrException.class)public void proxySystemInfoHandlerNonExistingNode() throws IOException, SolrServerException {- MapSolrParams params =- new MapSolrParams(Collections.singletonMap("nodes", "example.com:1234_solr"));+ MapSolrParams params = new MapSolrParams(Map.of("nodes", "example.com:1234_solr"));SystemInfoRequest req = new SystemInfoRequest(params);SystemInfoResponse rsp = req.process(solrClient, null);}@@ -76,7 +75,7 @@ public class AdminHandlersProxyTest extends SolrCloudTestCase {assertEquals(2, nodes.size());nodes.forEach(node -> {- MapSolrParams params = new MapSolrParams(Collections.singletonMap("nodes", node));+ MapSolrParams params = new MapSolrParams(Map.of("nodes", node));SystemInfoRequest req = new SystemInfoRequest(params);try {SystemInfoResponse rsp = req.process(solrClient, null);diff --git a/solr/core/src/test/org/apache/solr/handler/admin/SecurityConfHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/SecurityConfHandlerTest.javaindex 687171d7fad..6177c9f1a3a 100644--- a/solr/core/src/test/org/apache/solr/handler/admin/SecurityConfHandlerTest.java+++ b/solr/core/src/test/org/apache/solr/handler/admin/SecurityConfHandlerTest.java@@ -19,7 +19,6 @@ package org.apache.solr.handler.admin;import static org.apache.solr.handler.admin.SecurityConfHandler.SecurityConfig;import java.nio.charset.StandardCharsets;-import java.util.Collections;import java.util.HashMap;import java.util.List;import java.util.Map;@@ -49,7 +48,7 @@ public class SecurityConfHandlerTest extends SolrTestCaseJ4 {req.getContext().put("path", "/admin/authentication");ContentStreamBase.ByteArrayStream o =new ContentStreamBase.ByteArrayStream(command.getBytes(StandardCharsets.UTF_8), "");- req.setContentStreams(Collections.singletonList(o));+ req.setContentStreams(List.of(o));handler.handleRequestBody(req, new SolrQueryResponse());try (BasicAuthPlugin basicAuth = new BasicAuthPlugin()) {@@ -59,7 +58,7 @@ public class SecurityConfHandlerTest extends SolrTestCaseJ4 {command = "{\n" + "'set-user': {'harry':'HarryIsCool'},\n" + "'delete-user': ['tom']\n" + "}";o = new ContentStreamBase.ByteArrayStream(command.getBytes(StandardCharsets.UTF_8), "");- req.setContentStreams(Collections.singletonList(o));+ req.setContentStreams(List.of(o));handler.handleRequestBody(req, new SolrQueryResponse());securityCfg = handler.m.get("/security.json");assertEquals(3, securityCfg.getVersion());@@ -81,7 +80,7 @@ public class SecurityConfHandlerTest extends SolrTestCaseJ4 {req.getContext().put("httpMethod", SolrRequest.METHOD.POST);req.getContext().put("path", "/admin/authorization");o = new ContentStreamBase.ByteArrayStream(command.getBytes(StandardCharsets.UTF_8), "");- req.setContentStreams(Collections.singletonList(o));+ req.setContentStreams(List.of(o));SolrQueryResponse rsp = new SolrQueryResponse();handler.handleRequestBody(req, rsp);assertNull(rsp.getValues().get(CommandOperation.ERR_MSGS));@@ -105,7 +104,7 @@ public class SecurityConfHandlerTest extends SolrTestCaseJ4 {req.getContext().put("httpMethod", SolrRequest.METHOD.POST);req.getContext().put("path", "/admin/authorization");o = new ContentStreamBase.ByteArrayStream(command.getBytes(StandardCharsets.UTF_8), "");- req.setContentStreams(Collections.singletonList(o));+ req.setContentStreams(List.of(o));rsp = new SolrQueryResponse();handler.handleRequestBody(req, rsp);authzconf = (Map) handler.m.get("/security.json").getData().get("authorization");@@ -126,7 +125,7 @@ public class SecurityConfHandlerTest extends SolrTestCaseJ4 {req.getContext().put("httpMethod", SolrRequest.METHOD.POST);req.getContext().put("path", "/admin/authorization");o = new ContentStreamBase.ByteArrayStream(command.getBytes(StandardCharsets.UTF_8), "");- req.setContentStreams(Collections.singletonList(o));+ req.setContentStreams(List.of(o));rsp = new SolrQueryResponse();handler.handleRequestBody(req, rsp);authzconf = (Map) handler.m.get("/security.json").getData().get("authorization");@@ -143,7 +142,7 @@ public class SecurityConfHandlerTest extends SolrTestCaseJ4 {req.getContext().put("httpMethod", SolrRequest.METHOD.POST);req.getContext().put("path", "/admin/authorization");o = new ContentStreamBase.ByteArrayStream(command.getBytes(StandardCharsets.UTF_8), "");- req.setContentStreams(Collections.singletonList(o));+ req.setContentStreams(List.of(o));rsp = new SolrQueryResponse();handler.handleRequestBody(req, rsp);assertNull(rsp.getValues().get(CommandOperation.ERR_MSGS));@@ -167,7 +166,7 @@ public class SecurityConfHandlerTest extends SolrTestCaseJ4 {req.getContext().put("httpMethod", SolrRequest.METHOD.POST);req.getContext().put("path", "/admin/authorization");o = new ContentStreamBase.ByteArrayStream(command.getBytes(StandardCharsets.UTF_8), "");- req.setContentStreams(Collections.singletonList(o));+ req.setContentStreams(List.of(o));rsp = new SolrQueryResponse();handler.handleRequestBody(req, rsp);@SuppressWarnings({"rawtypes"})@@ -242,7 +241,7 @@ public class SecurityConfHandlerTest extends SolrTestCaseJ4 {req.getContext().put("path", "/admin/authentication");ContentStreamBase.ByteArrayStream o =new ContentStreamBase.ByteArrayStream(command.getBytes(StandardCharsets.UTF_8), "");- req.setContentStreams(Collections.singletonList(o));+ req.setContentStreams(List.of(o));handleRequestBody(req, new SolrQueryResponse());command =@@ -253,7 +252,7 @@ public class SecurityConfHandlerTest extends SolrTestCaseJ4 {req.getContext().put("httpMethod", SolrRequest.METHOD.POST);req.getContext().put("path", "/admin/authorization");o = new ContentStreamBase.ByteArrayStream(command.getBytes(StandardCharsets.UTF_8), "");- req.setContentStreams(Collections.singletonList(o));+ req.setContentStreams(List.of(o));SolrQueryResponse rsp = new SolrQueryResponse();handleRequestBody(req, rsp);Map<String, Object> data = m.get("/security.json").getData();diff --git a/solr/core/src/test/org/apache/solr/handler/admin/TestApiFramework.java b/solr/core/src/test/org/apache/solr/handler/admin/TestApiFramework.javaindex 69813bf75c9..101ee2a09b3 100644--- a/solr/core/src/test/org/apache/solr/handler/admin/TestApiFramework.java+++ b/solr/core/src/test/org/apache/solr/handler/admin/TestApiFramework.java@@ -32,7 +32,6 @@ import static org.mockito.Mockito.when;import java.io.ByteArrayInputStream;import java.io.InputStream;import java.nio.file.Path;-import java.util.Collections;import java.util.HashMap;import java.util.HashSet;import java.util.List;@@ -263,7 +262,7 @@ public class TestApiFramework extends SolrTestCaseJ4 {@Overridepublic Iterable<ContentStream> getContentStreams() {- return Collections.singletonList(+ return List.of(new ContentStreamBase() {@Overridepublic InputStream getStream() {diff --git a/solr/core/src/test/org/apache/solr/handler/admin/ZookeeperStatusHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/ZookeeperStatusHandlerTest.javaindex 2324b4cce07..a180edacfbe 100644--- a/solr/core/src/test/org/apache/solr/handler/admin/ZookeeperStatusHandlerTest.java+++ b/solr/core/src/test/org/apache/solr/handler/admin/ZookeeperStatusHandlerTest.java@@ -25,7 +25,6 @@ import static org.mockito.Mockito.when;import java.io.IOException;import java.net.URL;import java.util.Arrays;-import java.util.Collections;import java.util.List;import java.util.Map;import java.util.concurrent.ExecutionException;@@ -170,9 +169,7 @@ public class ZookeeperStatusHandlerTest extends SolrCloudTestCase {public void validateNotWhitelisted() {try (ZookeeperStatusHandler zsh = new ZookeeperStatusHandler(null)) {zsh.validateZkRawResponse(- Collections.singletonList("mntr is not executed because it is not in the whitelist."),- "zoo1:2181",- "mntr");+ List.of("mntr is not executed because it is not in the whitelist."), "zoo1:2181", "mntr");} catch (IOException e) {fail("Error closing ZookeeperStatusHandler");}@@ -191,7 +188,7 @@ public class ZookeeperStatusHandlerTest extends SolrCloudTestCase {public void validateNotServingRequestsResponse() {try (ZookeeperStatusHandler zsh = new ZookeeperStatusHandler(null)) {zsh.validateZkRawResponse(- Collections.singletonList("This ZooKeeper instance is not currently serving requests"),+ List.of("This ZooKeeper instance is not currently serving requests"),"zoo1:2181","mntr");} catch (IOException e) {diff --git a/solr/core/src/test/org/apache/solr/handler/component/ParallelHttpShardHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/component/ParallelHttpShardHandlerTest.javaindex ebdcbe658fb..4eb0db8858f 100644--- a/solr/core/src/test/org/apache/solr/handler/component/ParallelHttpShardHandlerTest.java+++ b/solr/core/src/test/org/apache/solr/handler/component/ParallelHttpShardHandlerTest.java@@ -16,7 +16,6 @@*/package org.apache.solr.handler.component;-import java.util.Collections;import java.util.List;import java.util.concurrent.AbstractExecutorService;import java.util.concurrent.TimeUnit;@@ -87,8 +86,7 @@ public class ParallelHttpShardHandlerTest extends SolrTestCaseJ4 {ModifiableSolrParams params = new ModifiableSolrParams();QueryRequest queryRequest = new QueryRequest(params);LBSolrClient.Endpoint endpoint = new LBSolrClient.Endpoint("http://ignored:8983/solr");- LBSolrClient.Req lbReq =- new LBSolrClient.Req(queryRequest, Collections.singletonList(endpoint));+ LBSolrClient.Req lbReq = new LBSolrClient.Req(queryRequest, List.of(endpoint));handler.makeShardRequest(shardRequest, "shardA", params, lbReq, simpleResponse, shardResponse, System.nanoTime());diff --git a/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java b/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.javaindex d2fe25fdcec..033901bf2f6 100644--- a/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java+++ b/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java@@ -1517,8 +1517,7 @@ public class StatsComponentTest extends SolrTestCaseJ4 {perShardXpaths.addAll(expectedDep.perShardXpaths);}}- ALL.put(- stat, new ExpectedStat(stat, input, perShardXpaths, Collections.singletonList(xpath)));+ ALL.put(stat, new ExpectedStat(stat, input, perShardXpaths, List.of(xpath)));}public static void create(@@ -1608,10 +1607,7 @@ public class StatsComponentTest extends SolrTestCaseJ4 {ExpectedStat.createSimple(Stat.stddev, "true", "double", String.valueOf(stddev));final String distinctValsXpath = "count(" + kpre + "arr[@name='distinctValues']/*)=10";ExpectedStat.create(- Stat.distinctValues,- "true",- Collections.singletonList(distinctValsXpath),- Collections.singletonList(distinctValsXpath));+ Stat.distinctValues, "true", List.of(distinctValsXpath), List.of(distinctValsXpath));ExpectedStat.createSimple(Stat.countDistinct, "true", "long", "10");final String percentileShardXpath =kpre@@ -1624,7 +1620,7 @@ public class StatsComponentTest extends SolrTestCaseJ4 {ExpectedStat.create(Stat.percentiles,"'90, 99'",- Collections.singletonList(percentileShardXpath),+ List.of(percentileShardXpath),Arrays.asList("count(" + kpre + "lst[@name='percentiles']/*)=2",kpre + "lst[@name='percentiles']/double[@name='90.0'][.=" + p90 + "]",@@ -1636,10 +1632,7 @@ public class StatsComponentTest extends SolrTestCaseJ4 {+ "']";final String cardinalityXpath = kpre + "long[@name='cardinality'][.='10']";ExpectedStat.create(- Stat.cardinality,- "true",- Collections.singletonList(cardinalityShardXpath),- Collections.singletonList(cardinalityXpath));+ Stat.cardinality, "true", List.of(cardinalityShardXpath), List.of(cardinalityXpath));// canary in the coal mineassertEquals(diff --git a/solr/core/src/test/org/apache/solr/handler/designer/ManagedSchemaDiffTest.java b/solr/core/src/test/org/apache/solr/handler/designer/ManagedSchemaDiffTest.javaindex fa0ad697bb2..023f310399d 100644--- a/solr/core/src/test/org/apache/solr/handler/designer/ManagedSchemaDiffTest.java+++ b/solr/core/src/test/org/apache/solr/handler/designer/ManagedSchemaDiffTest.java@@ -21,7 +21,6 @@ import static org.apache.solr.handler.admin.ConfigSetsHandler.DEFAULT_CONFIGSET_import static org.apache.solr.handler.designer.ManagedSchemaDiff.mapFieldsToPropertyValues;import java.util.Arrays;-import java.util.Collections;import java.util.HashMap;import java.util.List;import java.util.Map;@@ -110,7 +109,7 @@ public class ManagedSchemaDiffTest extends SolrCloudTestCase {Map<String, Object> diff = ManagedSchemaDiff.diff(list1, list2);assertTrue(diff.containsKey("old"));assertTrue(diff.containsKey("new"));- assertEquals(Collections.singletonList(obj2), diff.get("old"));+ assertEquals(List.of(obj2), diff.get("old"));assertEquals(Arrays.asList(obj3, obj4), diff.get("new"));}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.javaindex 59dac14425a..ed1aba6ceb5 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@@ -28,7 +28,6 @@ import java.nio.file.Files;import java.nio.file.Path;import java.util.Arrays;import java.util.Collection;-import java.util.Collections;import java.util.HashMap;import java.util.List;import java.util.Map;@@ -108,7 +107,7 @@ public class TestSchemaDesignerAPI extends SolrCloudTestCase implements SchemaDe// POST some sample TSV docsContentStream stream = new ContentStreamBase.StringStream(tsv, "text/csv");- when(req.getContentStreams()).thenReturn(Collections.singletonList(stream));+ when(req.getContentStreams()).thenReturn(List.of(stream));// POST /schema-designer/analyzeschemaDesignerAPI.analyze(req, rsp);@@ -196,7 +195,7 @@ public class TestSchemaDesignerAPI extends SolrCloudTestCase implements SchemaDeContentStreamBase.FileStream stream = new ContentStreamBase.FileStream(next);stream.setContentType(TestSampleDocumentsLoader.guessContentTypeFromFilename(next.getFileName().toString()));- when(req.getContentStreams()).thenReturn(Collections.singletonList(stream));+ when(req.getContentStreams()).thenReturn(List.of(stream));rsp = new SolrQueryResponse();@@ -228,7 +227,7 @@ public class TestSchemaDesignerAPI extends SolrCloudTestCase implements SchemaDeENABLE_DYNAMIC_FIELDS_PARAM, false,ENABLE_FIELD_GUESSING_PARAM, true,ENABLE_NESTED_DOCS_PARAM, false,- LANGUAGES_PARAM, Collections.singletonList("en"),+ LANGUAGES_PARAM, List.of("en"),COPY_FROM_PARAM, "_default");assertDesignerSettings(expSettings, rsp.getValues());@@ -308,7 +307,7 @@ public class TestSchemaDesignerAPI extends SolrCloudTestCase implements SchemaDe// POST some sample XML docsContentStreamBase.FileStream stream = new ContentStreamBase.FileStream(filmsXml);stream.setContentType("application/xml");- when(req.getContentStreams()).thenReturn(Collections.singletonList(stream));+ when(req.getContentStreams()).thenReturn(List.of(stream));SolrQueryResponse rsp = new SolrQueryResponse();@@ -362,7 +361,7 @@ public class TestSchemaDesignerAPI extends SolrCloudTestCase implements SchemaDePath booksJson = ExternalPaths.SOURCE_HOME.resolve("example/exampledocs/books.json");ContentStreamBase.FileStream stream = new ContentStreamBase.FileStream(booksJson);stream.setContentType(JSON_MIME);- when(req.getContentStreams()).thenReturn(Collections.singletonList(stream));+ when(req.getContentStreams()).thenReturn(List.of(stream));rsp = new SolrQueryResponse();@@ -414,9 +413,7 @@ public class TestSchemaDesignerAPI extends SolrCloudTestCase implements SchemaDereq = mock(SolrQueryRequest.class);when(req.getParams()).thenReturn(reqParams);when(req.getContentStreams())- .thenReturn(- Collections.singletonList(- new ContentStreamBase.StringStream(solrconfigXml, "application/xml")));+ .thenReturn(List.of(new ContentStreamBase.StringStream(solrconfigXml, "application/xml")));schemaDesignerAPI.updateFileContents(req, rsp);rspData = rsp.getValues().toSolrParams();@@ -432,9 +429,7 @@ public class TestSchemaDesignerAPI extends SolrCloudTestCase implements SchemaDereq = mock(SolrQueryRequest.class);when(req.getParams()).thenReturn(reqParams);when(req.getContentStreams())- .thenReturn(- Collections.singletonList(- new ContentStreamBase.StringStream("<config/>", "application/xml")));+ .thenReturn(List.of(new ContentStreamBase.StringStream("<config/>", "application/xml")));// this should fail b/c the updated solrconfig.xml is invalidschemaDesignerAPI.updateFileContents(req, rsp);@@ -459,7 +454,7 @@ public class TestSchemaDesignerAPI extends SolrCloudTestCase implements SchemaDeENABLE_DYNAMIC_FIELDS_PARAM, false,ENABLE_FIELD_GUESSING_PARAM, false,ENABLE_NESTED_DOCS_PARAM, false,- LANGUAGES_PARAM, Collections.singletonList("en"),+ LANGUAGES_PARAM, List.of("en"),COPY_FROM_PARAM, "_default");assertDesignerSettings(expSettings, rsp.getValues());@@ -561,7 +556,7 @@ public class TestSchemaDesignerAPI extends SolrCloudTestCase implements SchemaDewhen(req.getParams()).thenReturn(reqParams);stream = new ContentStreamBase.FileStream(getFile("schema-designer/add-new-field.json"));stream.setContentType(JSON_MIME);- when(req.getContentStreams()).thenReturn(Collections.singletonList(stream));+ when(req.getContentStreams()).thenReturn(List.of(stream));rsp = new SolrQueryResponse();// POST /schema-designer/add@@ -582,7 +577,7 @@ public class TestSchemaDesignerAPI extends SolrCloudTestCase implements SchemaDe// "temp" collectionstream = new ContentStreamBase.FileStream(getFile("schema-designer/update-author-field.json"));stream.setContentType(JSON_MIME);- when(req.getContentStreams()).thenReturn(Collections.singletonList(stream));+ when(req.getContentStreams()).thenReturn(List.of(stream));rsp = new SolrQueryResponse();@@ -600,7 +595,7 @@ public class TestSchemaDesignerAPI extends SolrCloudTestCase implements SchemaDewhen(req.getParams()).thenReturn(reqParams);stream = new ContentStreamBase.FileStream(getFile("schema-designer/add-new-type.json"));stream.setContentType(JSON_MIME);- when(req.getContentStreams()).thenReturn(Collections.singletonList(stream));+ when(req.getContentStreams()).thenReturn(List.of(stream));rsp = new SolrQueryResponse();// POST /schema-designer/add@@ -626,7 +621,7 @@ public class TestSchemaDesignerAPI extends SolrCloudTestCase implements SchemaDewhen(req.getParams()).thenReturn(reqParams);stream = new ContentStreamBase.FileStream(getFile("schema-designer/update-type.json"));stream.setContentType(JSON_MIME);- when(req.getContentStreams()).thenReturn(Collections.singletonList(stream));+ when(req.getContentStreams()).thenReturn(List.of(stream));rsp = new SolrQueryResponse();// POST /schema-designer/update@@ -722,7 +717,7 @@ public class TestSchemaDesignerAPI extends SolrCloudTestCase implements SchemaDeContentStreamBase.FileStream stream =new ContentStreamBase.FileStream(getFile("schema-designer/add-new-field.json"));stream.setContentType(JSON_MIME);- when(req.getContentStreams()).thenReturn(Collections.singletonList(stream));+ when(req.getContentStreams()).thenReturn(List.of(stream));rsp = new SolrQueryResponse();// POST /schema-designer/add@@ -794,7 +789,7 @@ public class TestSchemaDesignerAPI extends SolrCloudTestCase implements SchemaDeassertFalse(schemaField.isRequired());assertTrue(schemaField.stored());List<String> srcFields = schema.getCopySources("_text_");- assertEquals(Collections.singletonList(fieldName), srcFields);+ assertEquals(List.of(fieldName), srcFields);}@SuppressWarnings({"unchecked"})@@ -857,7 +852,7 @@ public class TestSchemaDesignerAPI extends SolrCloudTestCase implements SchemaDeContentStreamBase.StringStream stringStream =new ContentStreamBase.StringStream(JSONUtil.toJSON(mapParams), JSON_MIME);- when(req.getContentStreams()).thenReturn(Collections.singletonList(stringStream));+ when(req.getContentStreams()).thenReturn(List.of(stringStream));rsp = new SolrQueryResponse();schemaDesignerAPI.updateSchemaObject(req, rsp);@@ -868,7 +863,7 @@ public class TestSchemaDesignerAPI extends SolrCloudTestCase implements SchemaDeContentStreamBase.FileStream fileStream =new ContentStreamBase.FileStream(getFile("schema-designer/add-new-field.json"));fileStream.setContentType(JSON_MIME);- when(req.getContentStreams()).thenReturn(Collections.singletonList(fileStream));+ when(req.getContentStreams()).thenReturn(List.of(fileStream));rsp = new SolrQueryResponse();// POST /schema-designer/addschemaDesignerAPI.addSchemaObject(req, rsp);@@ -879,7 +874,7 @@ public class TestSchemaDesignerAPI extends SolrCloudTestCase implements SchemaDereqParams.set(SCHEMA_VERSION_PARAM, schemaVersion);fileStream = new ContentStreamBase.FileStream(getFile("schema-designer/add-new-type.json"));fileStream.setContentType(JSON_MIME);- when(req.getContentStreams()).thenReturn(Collections.singletonList(fileStream));+ when(req.getContentStreams()).thenReturn(List.of(fileStream));rsp = new SolrQueryResponse();// POST /schema-designer/addschemaDesignerAPI.addSchemaObject(req, rsp);diff --git a/solr/core/src/test/org/apache/solr/handler/designer/TestSchemaDesignerConfigSetHelper.java b/solr/core/src/test/org/apache/solr/handler/designer/TestSchemaDesignerConfigSetHelper.javaindex 4552a8a65bc..82231061bdf 100644--- a/solr/core/src/test/org/apache/solr/handler/designer/TestSchemaDesignerConfigSetHelper.java+++ b/solr/core/src/test/org/apache/solr/handler/designer/TestSchemaDesignerConfigSetHelper.java@@ -26,7 +26,6 @@ import static org.apache.solr.schema.IndexSchema.ROOT_FIELD_NAME;import java.io.ByteArrayInputStream;import java.io.IOException;import java.util.Arrays;-import java.util.Collections;import java.util.List;import java.util.Map;import java.util.zip.ZipEntry;@@ -150,14 +149,14 @@ public class TestSchemaDesignerConfigSetHelper extends SolrCloudTestCaseschema =helper.syncLanguageSpecificObjectsAndFiles(- configSet, schema, Collections.singletonList("en"), true, DEFAULT_CONFIGSET_NAME);+ configSet, schema, List.of("en"), true, DEFAULT_CONFIGSET_NAME);assertNotNull(schema.getFieldTypeByName("text_en"));assertNotNull(schema.getFieldOrNull("*_txt_en"));assertNull(schema.getFieldTypeByName("text_fr"));schema =helper.syncLanguageSpecificObjectsAndFiles(- configSet, schema, Collections.singletonList("en"), false, DEFAULT_CONFIGSET_NAME);+ configSet, schema, List.of("en"), false, DEFAULT_CONFIGSET_NAME);assertNotNull(schema.getFieldTypeByName("text_en"));assertNull(schema.getFieldOrNull("*_txt_en"));assertNull(schema.getFieldTypeByName("text_fr"));@@ -185,8 +184,7 @@ public class TestSchemaDesignerConfigSetHelper extends SolrCloudTestCase// add a field that uses text_en and then try removing "en" from the lang sethelper.createCollection(mutableId, mutableId); // need to create fieldMap<String, Object> addField = Map.of("name", "title", "type", "text_en");- String addedFieldName =- helper.addSchemaObject(configSet, Collections.singletonMap("add-field", addField));+ String addedFieldName = helper.addSchemaObject(configSet, Map.of("add-field", addField));assertEquals("title", addedFieldName);schema = helper.loadLatestSchema(helper.loadSolrConfig(mutableId));@@ -194,7 +192,7 @@ public class TestSchemaDesignerConfigSetHelper extends SolrCloudTestCaseschema =helper.syncLanguageSpecificObjectsAndFiles(- configSet, schema, Collections.singletonList("fr"), true, DEFAULT_CONFIGSET_NAME);+ configSet, schema, List.of("fr"), true, DEFAULT_CONFIGSET_NAME);assertNotNull(schema.getFieldTypeByName("text_en")); // being used, so not removedassertNotNull(schema.getFieldOrNull("*_txt_en"));assertTrue(@@ -283,8 +281,7 @@ public class TestSchemaDesignerConfigSetHelper extends SolrCloudTestCasehelper.createCollection(mutableId, mutableId);Map<String, Object> addField = Map.of("name", "title", "type", "text_en");- String addedFieldName =- helper.addSchemaObject(configSet, Collections.singletonMap("add-field", addField));+ String addedFieldName = helper.addSchemaObject(configSet, Map.of("add-field", addField));assertEquals("title", addedFieldName);Map<String, Object> analysis =@@ -309,14 +306,11 @@ public class TestSchemaDesignerConfigSetHelper extends SolrCloudTestCase// add / update fieldMap<String, Object> addField = Map.of("name", "author", "type", "string");- String addedFieldName =- helper.addSchemaObject(configSet, Collections.singletonMap("add-field", addField));+ String addedFieldName = helper.addSchemaObject(configSet, Map.of("add-field", addField));assertEquals("author", addedFieldName);helper.addSchemaObject(- configSet,- Collections.singletonMap(- "add-field", Map.of("name", "_catch_all_", "type", "text_general")));+ configSet, Map.of("add-field", Map.of("name", "_catch_all_", "type", "text_general")));Map<String, Object> updateField =Map.of("name", "author", "type", "string", "copyDest", "_text_");@@ -336,8 +330,8 @@ public class TestSchemaDesignerConfigSetHelper extends SolrCloudTestCaseassertEquals(false, resp.get("rebuild"));latest = helper.loadLatestSchema(helper.loadSolrConfig(mutableId));- assertEquals(Collections.singletonList("author"), latest.getCopySources("_text_"));- assertEquals(Collections.singletonList("author"), latest.getCopySources("_catch_all_"));+ assertEquals(List.of("author"), latest.getCopySources("_text_"));+ assertEquals(List.of("author"), latest.getCopySources("_catch_all_"));updateField = Map.of("name", "author", "type", "string", "copyDest", "");latest = helper.loadLatestSchema(helper.loadSolrConfig(mutableId));@@ -362,8 +356,7 @@ public class TestSchemaDesignerConfigSetHelper extends SolrCloudTestCase// add / update fieldMap<String, Object> addField = Map.of("name", "author", "type", "string");- String addedFieldName =- helper.addSchemaObject(configSet, Collections.singletonMap("add-field", addField));+ String addedFieldName = helper.addSchemaObject(configSet, Map.of("add-field", addField));assertEquals("author", addedFieldName);Map<String, Object> updateField = Map.of("name", "author", "type", "string", "required", true);@@ -401,7 +394,7 @@ public class TestSchemaDesignerConfigSetHelper extends SolrCloudTestCase// did the copy field update get applied?latest = helper.loadLatestSchema(helper.loadSolrConfig(mutableId));- assertEquals(Collections.singletonList("author"), latest.getCopySources("_text_"));+ assertEquals(List.of("author"), latest.getCopySources("_text_"));// switch the author field type to stringsupdateField =@@ -417,8 +410,7 @@ public class TestSchemaDesignerConfigSetHelper extends SolrCloudTestCase// add / update field typeMap<String, Object> addType =Map.of("name", "testType", "class", "solr.StrField", "docValues", true);- String addTypeName =- helper.addSchemaObject(configSet, Collections.singletonMap("add-field-type", addType));+ String addTypeName = helper.addSchemaObject(configSet, Map.of("add-field-type", addType));assertEquals("testType", addTypeName);latest = helper.loadLatestSchema(helper.loadSolrConfig(mutableId));@@ -441,8 +433,7 @@ public class TestSchemaDesignerConfigSetHelper extends SolrCloudTestCase// add / update dynamic fieldMap<String, Object> addDynField = Map.of("name", "*_test", "type", "string");String addedDynFieldName =- helper.addSchemaObject(- configSet, Collections.singletonMap("add-dynamic-field", addDynField));+ helper.addSchemaObject(configSet, Map.of("add-dynamic-field", addDynField));assertEquals("*_test", addedDynFieldName);// update the dynamic fielddiff --git a/solr/core/src/test/org/apache/solr/handler/designer/TestSchemaDesignerSettingsDAO.java b/solr/core/src/test/org/apache/solr/handler/designer/TestSchemaDesignerSettingsDAO.javaindex 3b1989c06a0..e7826e1e77a 100644--- a/solr/core/src/test/org/apache/solr/handler/designer/TestSchemaDesignerSettingsDAO.java+++ b/solr/core/src/test/org/apache/solr/handler/designer/TestSchemaDesignerSettingsDAO.java@@ -19,7 +19,6 @@ package org.apache.solr.handler.designer;import static org.apache.solr.handler.admin.ConfigSetsHandler.DEFAULT_CONFIGSET_NAME;-import java.util.Collections;import java.util.List;import java.util.Map;import org.apache.solr.client.solrj.SolrResponse;@@ -119,7 +118,7 @@ public class TestSchemaDesignerSettingsDAO extends SolrCloudTestCasesettings.setDynamicFieldsEnabled(false);settings.setNestedDocsEnabled(true);settings.setFieldGuessingEnabled(false);- settings.setLanguages(Collections.singletonList("en"));+ settings.setLanguages(List.of("en"));assertTrue("updated settings should have changed in ZK", dao.persistIfChanged(configSet, settings));@@ -139,7 +138,7 @@ public class TestSchemaDesignerSettingsDAO extends SolrCloudTestCaseDESIGNER_KEY + ENABLE_NESTED_DOCS_PARAM,true,DESIGNER_KEY + LANGUAGES_PARAM,- Collections.singletonList("en"));+ List.of("en"));assertDesignerSettings(expSettings, settings);assertTrue("should be disabled", dao.isDesignerDisabled(configSet));diff --git a/solr/core/src/test/org/apache/solr/handler/tagger/EmbeddedSolrNoSerializeTest.java b/solr/core/src/test/org/apache/solr/handler/tagger/EmbeddedSolrNoSerializeTest.javaindex e0792724df3..ca70f22b066 100644--- a/solr/core/src/test/org/apache/solr/handler/tagger/EmbeddedSolrNoSerializeTest.java+++ b/solr/core/src/test/org/apache/solr/handler/tagger/EmbeddedSolrNoSerializeTest.java@@ -24,7 +24,7 @@ package org.apache.solr.handler.tagger;import java.io.IOException;import java.util.Collection;-import java.util.Collections;+import java.util.Set;import java.util.concurrent.atomic.AtomicReference;import java.util.function.BiFunction;import org.apache.lucene.document.Field;@@ -99,7 +99,7 @@ public class EmbeddedSolrNoSerializeTest extends SolrTestCaseJ4 {@SuppressWarnings("deprecation")@Overridepublic Collection<ContentStream> getContentStreams() {- return Collections.singleton(new ContentStreamBase.StringStream(input));+ return Set.of(new ContentStreamBase.StringStream(input));}// As of 7.2. But won't work until: https://issues.apache.org/jira/browse/SOLR-12142diff --git a/solr/core/src/test/org/apache/solr/handler/tagger/TaggerTestCase.java b/solr/core/src/test/org/apache/solr/handler/tagger/TaggerTestCase.javaindex 06c75e8a305..5caa906369e 100644--- a/solr/core/src/test/org/apache/solr/handler/tagger/TaggerTestCase.java+++ b/solr/core/src/test/org/apache/solr/handler/tagger/TaggerTestCase.java@@ -26,11 +26,11 @@ import java.io.IOException;import java.lang.invoke.MethodHandles;import java.util.ArrayList;import java.util.Arrays;-import java.util.Collections;import java.util.HashMap;import java.util.List;import java.util.Map;import java.util.Objects;+import java.util.Set;import java.util.TreeSet;import org.apache.lucene.document.Document;import org.apache.solr.SolrTestCaseJ4;@@ -182,7 +182,7 @@ public abstract class TaggerTestCase extends SolrTestCaseJ4 {SolrParams params = SolrParams.wrapDefaults(moreParams, baseParams);SolrQueryRequestBase req = new SolrQueryRequestBase(h.getCore(), params) {};Iterable<ContentStream> stream =- Collections.singleton((ContentStream) new ContentStreamBase.StringStream(doc));+ Set.of((ContentStream) new ContentStreamBase.StringStream(doc));req.setContentStreams(stream);return req;}diff --git a/solr/core/src/test/org/apache/solr/handler/tagger/XmlInterpolationTest.java b/solr/core/src/test/org/apache/solr/handler/tagger/XmlInterpolationTest.javaindex 38b24490d26..0e4a8c383c5 100644--- a/solr/core/src/test/org/apache/solr/handler/tagger/XmlInterpolationTest.java+++ b/solr/core/src/test/org/apache/solr/handler/tagger/XmlInterpolationTest.java@@ -26,9 +26,9 @@ import java.io.IOException;import java.io.Reader;import java.io.StringReader;import java.util.ArrayList;-import java.util.Collections;import java.util.List;import java.util.Locale;+import java.util.Set;import javax.xml.parsers.DocumentBuilder;import javax.xml.parsers.DocumentBuilderFactory;import org.apache.lucene.analysis.charfilter.HTMLStripCharFilter;@@ -203,8 +203,7 @@ public class XmlInterpolationTest extends TaggerTestCase {private String[] analyzeReturnTokens(String docText) {List<String> result = new ArrayList<>();- Reader filter =- new HTMLStripCharFilter(new StringReader(docText), Collections.singleton("unescaped"));+ Reader filter = new HTMLStripCharFilter(new StringReader(docText), Set.of("unescaped"));WhitespaceTokenizer ts = new WhitespaceTokenizer();final CharTermAttribute termAttribute = ts.addAttribute(CharTermAttribute.class);try {diff --git a/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java b/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.javaindex ab8c4cd2512..0f50498c75b 100644--- a/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java+++ b/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java@@ -18,7 +18,6 @@ package org.apache.solr.highlight;import java.io.IOException;import java.util.Arrays;-import java.util.Collections;import java.util.HashMap;import java.util.HashSet;import java.util.List;@@ -1388,8 +1387,7 @@ public class HighlighterTest extends SolrTestCaseJ4 {Query query =new SpanPayloadCheckQuery(new SpanTermQuery(new Term(FIELD_NAME, "word")),- Collections.singletonList(- new BytesRef(new byte[] {0, 0, 0, 7}))); // bytes for integer 7+ List.of(new BytesRef(new byte[] {0, 0, 0, 7}))); // bytes for integer 7// invoke highlight component... the hard wayfinal SearchComponent hlComp = h.getCore().getSearchComponent("highlight");@@ -1397,7 +1395,7 @@ public class HighlighterTest extends SolrTestCaseJ4 {req("hl", "true", "hl.fl", FIELD_NAME, HighlightParams.USE_PHRASE_HIGHLIGHTER, "true");try {SolrQueryResponse resp = new SolrQueryResponse();- ResponseBuilder rb = new ResponseBuilder(req, resp, Collections.singletonList(hlComp));+ ResponseBuilder rb = new ResponseBuilder(req, resp, List.of(hlComp));rb.setHighlightQuery(query);rb.setResults(req.getSearcher().getDocListAndSet(query, null, 0, 1));// highlight:diff --git a/solr/core/src/test/org/apache/solr/packagemanager/TestPackageManager.java b/solr/core/src/test/org/apache/solr/packagemanager/TestPackageManager.javaindex 69f590136ae..4d6bedf078a 100644--- a/solr/core/src/test/org/apache/solr/packagemanager/TestPackageManager.java+++ b/solr/core/src/test/org/apache/solr/packagemanager/TestPackageManager.java@@ -19,7 +19,7 @@ package org.apache.solr.packagemanager;import com.jayway.jsonpath.InvalidPathException;import java.io.IOException;import java.net.URL;-import java.util.Collections;+import java.util.List;import java.util.Map;import org.apache.solr.cli.CLITestHelper;import org.apache.solr.cli.ToolRuntime;@@ -64,13 +64,8 @@ public class TestPackageManager extends SolrCloudTestCase {plugin.verifyCommand.condition = "&[no_quotes_error_jpath]";manager.verify(new SolrPackageInstance(- "",- "",- "1.0",- new SolrPackage.Manifest(),- Collections.singletonList(plugin),- Map.of()),- Collections.singletonList(COLLECTION_NAME),+ "", "", "1.0", new SolrPackage.Manifest(), List.of(plugin), Map.of()),+ List.of(COLLECTION_NAME),plugin.type.equals("cluster"),new String[0]);fail();diff --git a/solr/core/src/test/org/apache/solr/pkg/TestPackages.java b/solr/core/src/test/org/apache/solr/pkg/TestPackages.javaindex 9f32d698b19..597e2044544 100644--- a/solr/core/src/test/org/apache/solr/pkg/TestPackages.java+++ b/solr/core/src/test/org/apache/solr/pkg/TestPackages.java@@ -31,7 +31,6 @@ import java.io.IOException;import java.io.InputStream;import java.nio.ByteBuffer;import java.util.Arrays;-import java.util.Collections;import java.util.LinkedHashMap;import java.util.List;import java.util.Map;@@ -141,7 +140,7 @@ public class TestPackages extends SolrCloudTestCase {new V2Request.Builder("/cluster/package").forceV2(true).withMethod(SolrRequest.METHOD.POST)- .withPayload(Collections.singletonMap("add", add))+ .withPayload(Map.of("add", add)).build();req.process(cluster.getSolrClient());@@ -222,7 +221,7 @@ public class TestPackages extends SolrCloudTestCase {new V2Request.Builder("/cluster/package").forceV2(true).withMethod(SolrRequest.METHOD.POST)- .withPayload(Collections.singletonMap("add", add))+ .withPayload(Map.of("add", add)).build();req.process(cluster.getSolrClient());@@ -412,7 +411,7 @@ public class TestPackages extends SolrCloudTestCase {new V2Request.Builder("/cluster/package").withMethod(SolrRequest.METHOD.POST).forceV2(true)- .withPayload(Collections.singletonMap("delete", delVersion))+ .withPayload(Map.of("delete", delVersion)).build();delete.process(cluster.getSolrClient());@@ -595,7 +594,7 @@ public class TestPackages extends SolrCloudTestCase {new V2Request.Builder("/cluster/package").forceV2(true).withMethod(SolrRequest.METHOD.POST)- .withPayload(Collections.singletonMap("add", add))+ .withPayload(Map.of("add", add)).build();// the files are not yet there. The command should fail with error saying "No such file"@@ -604,7 +603,7 @@ public class TestPackages extends SolrCloudTestCase {// post the jar file. No signature is sentpostFileAndWait(cluster, "runtimecode/runtimelibs.jar.bin", FILE1, null);- add.files = Collections.singletonList(FILE1);+ add.files = List.of(FILE1);expectError(req, cluster.getSolrClient(), errPath, FILE1 + " has no signature");// now we upload the keysbyte[] derFile = readFile("cryptokeys/pub_key512.der");@@ -617,7 +616,7 @@ public class TestPackages extends SolrCloudTestCase {"L3q/qIGs4NaF6JiO0ZkMUFa88j0OmYc+I6O7BOdNuMct/xoZ4h73aZHZGc0+nmI1f/U3bOlMPINlSOM6LK3JpQ==");// with correct signature// after uploading the file, let's delete the keys to see if we get proper error message- add.files = Collections.singletonList(FILE2);+ add.files = List.of(FILE2);/*expectError(req, cluster.getSolrClient(), errPath,"ZooKeeper does not have any public keys");*/@@ -645,7 +644,7 @@ public class TestPackages extends SolrCloudTestCase {// this time we are adding the second version of the package (0.13)add.version = "0.13";add.pkg = "test_pkg";- add.files = Collections.singletonList(FILE3);+ add.files = List.of(FILE3);// this request should succeedreq.process(cluster.getSolrClient());@@ -665,7 +664,7 @@ public class TestPackages extends SolrCloudTestCase {new V2Request.Builder("/cluster/package").forceV2(true).withMethod(SolrRequest.METHOD.POST)- .withPayload(Collections.singletonMap("delete", delVersion))+ .withPayload(Map.of("delete", delVersion)).build();// we are expecting an error@@ -772,7 +771,7 @@ public class TestPackages extends SolrCloudTestCase {new V2Request.Builder("/cluster/package").forceV2(true).withMethod(SolrRequest.METHOD.POST)- .withPayload(Collections.singletonMap("add", add))+ .withPayload(Map.of("add", add)).build();req.process(cluster.getSolrClient());@@ -814,7 +813,7 @@ public class TestPackages extends SolrCloudTestCase {new V2Request.Builder("/cluster/package").forceV2(true).withMethod(SolrRequest.METHOD.POST)- .withPayload(Collections.singletonMap("add", add))+ .withPayload(Map.of("add", add)).build();req.process(cluster.getSolrClient());diff --git a/solr/core/src/test/org/apache/solr/request/macro/TestMacroExpander.java b/solr/core/src/test/org/apache/solr/request/macro/TestMacroExpander.javaindex 231fa299c94..a31e4f37e2a 100644--- a/solr/core/src/test/org/apache/solr/request/macro/TestMacroExpander.java+++ b/solr/core/src/test/org/apache/solr/request/macro/TestMacroExpander.java@@ -16,7 +16,6 @@*/package org.apache.solr.request.macro;-import java.util.Collections;import java.util.HashMap;import java.util.Map;import org.apache.solr.SolrTestCase;@@ -154,7 +153,7 @@ public class TestMacroExpander extends SolrTestCase {@Testpublic void testUnbalanced() { // SOLR-13181- final Map<String, String[]> request = Collections.singletonMap("answer", new String[] {"42"});+ final Map<String, String[]> request = Map.of("answer", new String[] {"42"});final MacroExpander meSkipOnMissingParams = new MacroExpander(request);final MacroExpander meFailOnMissingParams = new MacroExpander(request, true);assertEquals("${noClose", meSkipOnMissingParams.expand("${noClose"));diff --git a/solr/core/src/test/org/apache/solr/response/TestPushWriter.java b/solr/core/src/test/org/apache/solr/response/TestPushWriter.javaindex 08e01b3830b..8cf3d154687 100644--- a/solr/core/src/test/org/apache/solr/response/TestPushWriter.java+++ b/solr/core/src/test/org/apache/solr/response/TestPushWriter.java@@ -17,8 +17,6 @@package org.apache.solr.response;-import static java.util.Collections.singletonMap;-import java.io.ByteArrayOutputStream;import java.io.IOException;import java.io.OutputStreamWriter;@@ -102,7 +100,7 @@ public class TestPushWriter extends SolrTestCaseJ4 {protected void writeData(PushWriter pw) throws IOException {pw.writeMap(m -> {- m.put("responseHeader", singletonMap("status", 0))+ m.put("responseHeader", Map.of("status", 0)).put("response",(MapWriter)@@ -113,8 +111,8 @@ public class TestPushWriter extends SolrTestCaseJ4 {(IteratorWriter)w -> {w.add((MapWriter) m3 -> m3.put("id", 1))- .add(singletonMap("id", 2))- .add(singletonMap("id", 3));+ .add(Map.of("id", 2))+ .add(Map.of("id", 3));});});});@@ -125,7 +123,7 @@ public class TestPushWriter extends SolrTestCaseJ4 {pw.writeMap(name,m -> {- m.put("responseHeader", singletonMap("status", 0))+ m.put("responseHeader", Map.of("status", 0)).put("response",(MapWriter)@@ -136,8 +134,8 @@ public class TestPushWriter extends SolrTestCaseJ4 {(IteratorWriter)w -> {w.add((MapWriter) m3 -> m3.put("id", 1))- .add(singletonMap("id", 2))- .add(singletonMap("id", 3));+ .add(Map.of("id", 2))+ .add(Map.of("id", 3));});});});diff --git a/solr/core/src/test/org/apache/solr/response/TestRetrieveFieldsOptimizer.java b/solr/core/src/test/org/apache/solr/response/TestRetrieveFieldsOptimizer.javaindex 9f413673236..df8c8cb60c6 100644--- a/solr/core/src/test/org/apache/solr/response/TestRetrieveFieldsOptimizer.java+++ b/solr/core/src/test/org/apache/solr/response/TestRetrieveFieldsOptimizer.java@@ -180,9 +180,9 @@ public class TestRetrieveFieldsOptimizer extends SolrTestCaseJ4 {String id = "str" + idx;sdoc.addField("str", id);sdoc.addField(idNotStoredDv, id);- fieldsExpectedVals.put(idNotStoredDv, Collections.singletonList(id));+ fieldsExpectedVals.put(idNotStoredDv, List.of(id));sdoc.addField(idStoredNotDv, id);- fieldsExpectedVals.put(idStoredNotDv, Collections.singletonList(id));+ fieldsExpectedVals.put(idStoredNotDv, List.of(id));for (RetrieveField field : fieldsHolder.fields.values()) {if (field.name.equals(idNotStoredDv) || field.name.equals(idStoredNotDv)) {diff --git a/solr/core/src/test/org/apache/solr/response/transform/TestSubQueryTransformerDistrib.java b/solr/core/src/test/org/apache/solr/response/transform/TestSubQueryTransformerDistrib.javaindex e2fd0110d4d..108196031f7 100644--- a/solr/core/src/test/org/apache/solr/response/transform/TestSubQueryTransformerDistrib.java+++ b/solr/core/src/test/org/apache/solr/response/transform/TestSubQueryTransformerDistrib.java@@ -16,8 +16,6 @@*/package org.apache.solr.response.transform;-import static java.util.Collections.singletonList;-import static java.util.Collections.singletonMap;import static org.apache.solr.security.Sha256AuthenticationProvider.getSaltedHashedValue;import java.io.ByteArrayOutputStream;@@ -86,9 +84,9 @@ public class TestSubQueryTransformerDistrib extends SolrCloudTestCase {"class",RuleBasedAuthorizationPlugin.class.getName(),"user-role",- singletonMap(USER, "admin"),+ Map.of(USER, "admin"),"permissions",- singletonList(Map.of("name", "all", "role", "admin"))),+ List.of(Map.of("name", "all", "role", "admin"))),"authentication",Map.of("class",@@ -96,7 +94,7 @@ public class TestSubQueryTransformerDistrib extends SolrCloudTestCase {"blockUnknown",true,"credentials",- singletonMap(USER, getSaltedHashedValue(PASS)),+ Map.of(USER, getSaltedHashedValue(PASS)),"forwardCredentials", // forward basic auth credentials during internode// requests instead of relying on PKI authentication; the test should pass// regardless of the setting here, but "true" is the more interesting case thatdiff --git a/solr/core/src/test/org/apache/solr/search/CurrencyRangeFacetCloudTest.java b/solr/core/src/test/org/apache/solr/search/CurrencyRangeFacetCloudTest.javaindex fe24a7050ea..5df58d9e0f2 100644--- a/solr/core/src/test/org/apache/solr/search/CurrencyRangeFacetCloudTest.java+++ b/solr/core/src/test/org/apache/solr/search/CurrencyRangeFacetCloudTest.java@@ -18,8 +18,8 @@ package org.apache.solr.search;import java.lang.invoke.MethodHandles;import java.util.Arrays;-import java.util.Collections;import java.util.List;+import java.util.Map;import org.apache.lucene.tests.util.TestUtil;import org.apache.solr.client.solrj.request.CollectionAdminRequest;import org.apache.solr.client.solrj.request.SolrQuery;@@ -68,8 +68,7 @@ public class CurrencyRangeFacetCloudTest extends SolrCloudTestCase {assertEquals(0,(CollectionAdminRequest.createCollection(COLLECTION, CONF, numShards, numReplicas)- .setProperties(- Collections.singletonMap(CoreAdminParams.CONFIG, "solrconfig-minimal.xml"))+ .setProperties(Map.of(CoreAdminParams.CONFIG, "solrconfig-minimal.xml")).process(cluster.getSolrClient())).getStatus());diff --git a/solr/core/src/test/org/apache/solr/search/LargeFieldTest.java b/solr/core/src/test/org/apache/solr/search/LargeFieldTest.javaindex 6d0a6a385be..ef3af492fdb 100644--- a/solr/core/src/test/org/apache/solr/search/LargeFieldTest.java+++ b/solr/core/src/test/org/apache/solr/search/LargeFieldTest.java@@ -19,7 +19,7 @@ package org.apache.solr.search;import java.io.StringWriter;import java.util.Arrays;-import java.util.Collections;+import java.util.List;import java.util.Map;import java.util.Objects;import org.apache.lucene.document.Document;@@ -54,7 +54,7 @@ public class LargeFieldTest extends SolrTestCaseJ4 {IndexSchema schema = h.getCore().getLatestSchema();schema =schema.addFieldTypes(- Collections.singletonList(+ List.of(schema.newFieldType("textType","solr.TextField", // redundant; TODO improve apidiff --git a/solr/core/src/test/org/apache/solr/search/TestMaxScoreQueryParser.java b/solr/core/src/test/org/apache/solr/search/TestMaxScoreQueryParser.javaindex 6612be6ae04..942601f81dd 100644--- a/solr/core/src/test/org/apache/solr/search/TestMaxScoreQueryParser.java+++ b/solr/core/src/test/org/apache/solr/search/TestMaxScoreQueryParser.java@@ -21,7 +21,7 @@ import static org.hamcrest.Matchers.hasItem;import java.util.ArrayList;import java.util.Arrays;import java.util.Collection;-import java.util.Collections;+import java.util.Map;import java.util.stream.Collectors;import org.apache.lucene.index.Term;import org.apache.lucene.search.BooleanClause;@@ -197,9 +197,7 @@ public class TestMaxScoreQueryParser extends SolrTestCaseJ4 {while (al.size() >= 2) {p.add(al.remove(0), al.remove(0));}- return new MaxScoreQParser(- q, p, new MapSolrParams(Collections.singletonMap("df", "text")), req(q))- .parse();+ return new MaxScoreQParser(q, p, new MapSolrParams(Map.of("df", "text")), req(q)).parse();} catch (SyntaxError syntaxError) {fail("Failed with exception " + syntaxError.getMessage());}diff --git a/solr/core/src/test/org/apache/solr/search/TestRandomCollapseQParserPlugin.java b/solr/core/src/test/org/apache/solr/search/TestRandomCollapseQParserPlugin.javaindex 09f3b7008e9..ad4d7ac5b22 100644--- a/solr/core/src/test/org/apache/solr/search/TestRandomCollapseQParserPlugin.java+++ b/solr/core/src/test/org/apache/solr/search/TestRandomCollapseQParserPlugin.java@@ -20,7 +20,6 @@ import static org.hamcrest.core.StringContains.containsString;import java.util.ArrayList;import java.util.Arrays;-import java.util.Collections;import java.util.List;import org.apache.lucene.tests.util.TestUtil;import org.apache.solr.CursorPagingTest;@@ -276,10 +275,9 @@ public class TestRandomCollapseQParserPlugin extends SolrTestCaseJ4 {+ ", size="+ collapseSize+ "))";- List<String> expectedParsedFilterQuery = Collections.singletonList(expectedParsedFilterString);+ List<String> expectedParsedFilterQuery = List.of(expectedParsedFilterString);assertEquals(expectedParsedFilterQuery, response.getDebugMap().get("parsed_filter_queries"));- assertEquals(- Collections.singletonList(filterQuery), response.getDebugMap().get("filter_queries"));+ assertEquals(List.of(filterQuery), response.getDebugMap().get("filter_queries"));}public void testNullPolicy() {diff --git a/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial2.java b/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial2.javaindex 166d17e8e94..d5e23623bfa 100644--- a/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial2.java+++ b/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial2.java@@ -339,7 +339,7 @@ public class TestSolr4Spatial2 extends SolrTestCaseJ4 {RetrievalCombo(String fieldName, String indexValue, String returnValue) {this.fieldName = fieldName;- this.indexValues = Collections.singletonList(indexValue);+ this.indexValues = List.of(indexValue);this.expectReturnJSON = "'" + returnValue + "'";}}diff --git a/solr/core/src/test/org/apache/solr/search/TestThinCache.java b/solr/core/src/test/org/apache/solr/search/TestThinCache.javaindex e8828b57e81..fb39a019913 100644--- a/solr/core/src/test/org/apache/solr/search/TestThinCache.java+++ b/solr/core/src/test/org/apache/solr/search/TestThinCache.java@@ -25,7 +25,6 @@ import io.prometheus.metrics.model.snapshots.Labels;import java.io.IOException;import java.nio.file.Files;import java.nio.file.Path;-import java.util.Collections;import java.util.HashMap;import java.util.Map;import org.apache.lucene.tests.util.TestUtil;@@ -131,8 +130,7 @@ public class TestThinCache extends SolrTestCaseJ4 {NoOpRegenerator regenerator = new NoOpRegenerator();backing.init(params, null, null);- Object initObj =- lfuCache.init(Collections.singletonMap("autowarmCount", "25"), null, regenerator);+ Object initObj = lfuCache.init(Map.of("autowarmCount", "25"), null, regenerator);lfuCache.setState(SolrCache.State.LIVE);for (int i = 0; i < 101; i++) {lfuCache.put(i + 1, Integer.toString(i + 1));@@ -151,7 +149,7 @@ public class TestThinCache extends SolrTestCaseJ4 {assertNull(lfuCache.get(1)); // first item put in should be the first out// Test autowarming- newLFUCache.init(Collections.singletonMap("autowarmCount", "25"), initObj, regenerator);+ newLFUCache.init(Map.of("autowarmCount", "25"), initObj, regenerator);newLFUCache.warm(null, lfuCache);newLFUCache.setState(SolrCache.State.LIVE);diff --git a/solr/core/src/test/org/apache/solr/search/facet/RangeFacetCloudTest.java b/solr/core/src/test/org/apache/solr/search/facet/RangeFacetCloudTest.javaindex 697a2f8b680..4bc7174eb3c 100644--- a/solr/core/src/test/org/apache/solr/search/facet/RangeFacetCloudTest.java+++ b/solr/core/src/test/org/apache/solr/search/facet/RangeFacetCloudTest.java@@ -20,7 +20,6 @@ import java.lang.invoke.MethodHandles;import java.lang.reflect.Array;import java.util.ArrayList;import java.util.Arrays;-import java.util.Collections;import java.util.EnumSet;import java.util.LinkedHashMap;import java.util.List;@@ -97,8 +96,7 @@ public class RangeFacetCloudTest extends SolrCloudTestCase {assertEquals(0,(CollectionAdminRequest.createCollection(COLLECTION, CONF, numShards, numReplicas)- .setProperties(- Collections.singletonMap(CoreAdminParams.CONFIG, "solrconfig-minimal.xml"))+ .setProperties(Map.of(CoreAdminParams.CONFIG, "solrconfig-minimal.xml")).process(cluster.getSolrClient())).getStatus());diff --git a/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKGEquiv.java b/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKGEquiv.javaindex 087f2a2ec5c..deec286fd21 100644--- a/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKGEquiv.java+++ b/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKGEquiv.java@@ -821,10 +821,7 @@ public class TestCloudJSONFacetSKGEquiv extends SolrCloudTestCase {// it ignores the order of the keys in each bucket...final String pathToMismatch =BaseDistributedSearchTestCase.compare(- expected,- actual,- 0,- Collections.singletonMap("buckets", BaseDistributedSearchTestCase.UNORDERED));+ expected, actual, 0, Map.of("buckets", BaseDistributedSearchTestCase.UNORDERED));if (null != pathToMismatch) {log.error("{}: expected = {}", options, expected);log.error("{}: actual = {}", options, actual);diff --git a/solr/core/src/test/org/apache/solr/search/facet/TestJsonFacets.java b/solr/core/src/test/org/apache/solr/search/facet/TestJsonFacets.javaindex 41186cf4bef..ee6bd9b3543 100644--- a/solr/core/src/test/org/apache/solr/search/facet/TestJsonFacets.java+++ b/solr/core/src/test/org/apache/solr/search/facet/TestJsonFacets.java@@ -27,6 +27,7 @@ import java.util.List;import java.util.Locale;import java.util.Map;import java.util.Random;+import java.util.Set;import java.util.concurrent.atomic.AtomicLong;import org.apache.lucene.tests.util.LuceneTestCase;import org.apache.solr.JSONTestUtil;@@ -112,7 +113,7 @@ public class TestJsonFacets extends SolrTestCaseHS {@ParametersFactorypublic static Iterable<Object[]> parameters() {if (null != TEST_ONLY_ONE_FACET_METHOD) {- return Collections.singleton(new Object[] {TEST_ONLY_ONE_FACET_METHOD});+ return Set.<Object[]>of(new Object[] {TEST_ONLY_ONE_FACET_METHOD});} else if (TEST_NIGHTLY) {// wrap each enum val in an Object[] and return as Iterablereturn () ->@@ -123,8 +124,7 @@ public class TestJsonFacets extends SolrTestCaseHS {// can't use LuceneTestCase.random() because we're not in the runner context yetString seed = System.getProperty("tests.seed", "");- return Collections.singleton(- new Object[] {methods[Math.abs(seed.hashCode()) % methods.length]});+ return Set.<Object[]>of(new Object[] {methods[Math.abs(seed.hashCode()) % methods.length]});}}@@ -1446,10 +1446,10 @@ public class TestJsonFacets extends SolrTestCaseHS {List<String> getAlternatives(String field) {int idx = field.lastIndexOf('_');- if (idx <= 0 || idx >= field.length()) return Collections.singletonList(field);+ if (idx <= 0 || idx >= field.length()) return List.of(field);String suffix = field.substring(idx);String[] alternativeSuffixes = suffixMap.get(suffix);- if (alternativeSuffixes == null) return Collections.singletonList(field);+ if (alternativeSuffixes == null) return List.of(field);String base = field.substring(0, idx);List<String> out = new ArrayList<>(alternativeSuffixes.length);for (String altS : alternativeSuffixes) {diff --git a/solr/core/src/test/org/apache/solr/search/join/ShardToShardJoinAbstract.java b/solr/core/src/test/org/apache/solr/search/join/ShardToShardJoinAbstract.javaindex 099d070bc61..682c19dbf3f 100644--- a/solr/core/src/test/org/apache/solr/search/join/ShardToShardJoinAbstract.java+++ b/solr/core/src/test/org/apache/solr/search/join/ShardToShardJoinAbstract.java@@ -16,8 +16,6 @@*/package org.apache.solr.search.join;-import static java.util.Collections.singletonMap;-import java.io.IOException;import java.lang.invoke.MethodHandles;import java.util.AbstractMap;@@ -86,7 +84,7 @@ public abstract class ShardToShardJoinAbstract extends SolrCloudTestCase {new V2Request.Builder("/cluster/plugin").forceV2(true).POST()- .withPayload(singletonMap("add", plugin))+ .withPayload(Map.of("add", plugin)).build();req.process(cluster.getSolrClient());// TODO await completiondiff --git a/solr/core/src/test/org/apache/solr/search/similarities/TestSweetSpotSimilarityFactory.java b/solr/core/src/test/org/apache/solr/search/similarities/TestSweetSpotSimilarityFactory.javaindex d930cf37127..46eeb17d447 100644--- a/solr/core/src/test/org/apache/solr/search/similarities/TestSweetSpotSimilarityFactory.java+++ b/solr/core/src/test/org/apache/solr/search/similarities/TestSweetSpotSimilarityFactory.java@@ -17,7 +17,7 @@package org.apache.solr.search.similarities;import java.io.IOException;-import java.util.Collections;+import java.util.Set;import java.util.stream.Collectors;import java.util.stream.IntStream;import org.apache.lucene.document.Field.Store;@@ -44,7 +44,7 @@ public class TestSweetSpotSimilarityFactory extends BaseSimilarityTestCase {String value = IntStream.range(0, length).mapToObj(i -> "a").collect(Collectors.joining(" "));Directory dir = newDirectory();IndexWriter w = new IndexWriter(dir, newIndexWriterConfig().setSimilarity(sim));- w.addDocument(Collections.singleton(newTextField("foo", value, Store.NO)));+ w.addDocument(Set.of(newTextField("foo", value, Store.NO)));DirectoryReader reader = DirectoryReader.open(w);w.close();IndexSearcher searcher = new IndexSearcher(reader);diff --git a/solr/core/src/test/org/apache/solr/security/AuditLoggerIntegrationTest.java b/solr/core/src/test/org/apache/solr/security/AuditLoggerIntegrationTest.javaindex bf946962968..efe89a4a9b7 100644--- a/solr/core/src/test/org/apache/solr/security/AuditLoggerIntegrationTest.java+++ b/solr/core/src/test/org/apache/solr/security/AuditLoggerIntegrationTest.java@@ -47,9 +47,9 @@ import java.nio.charset.StandardCharsets;import java.nio.file.Files;import java.util.ArrayList;import java.util.Arrays;-import java.util.Collections;import java.util.List;import java.util.Locale;+import java.util.Map;import java.util.concurrent.BlockingQueue;import java.util.concurrent.LinkedBlockingDeque;import java.util.concurrent.Semaphore;@@ -277,7 +277,7 @@ public class AuditLoggerIntegrationTest extends SolrCloudAuthTestCase {.get().cluster.getSolrClient()- .query("test", new MapSolrParams(Collections.singletonMap("q", "a(bc")));+ .query("test", new MapSolrParams(Map.of("q", "a(bc")));});final List<AuditEvent> events = testHarness.get().receiver.waitForAuditEvents(3);assertAuditEvent(events.get(0), COMPLETED, "/admin/cores");diff --git a/solr/core/src/test/org/apache/solr/security/AuditLoggerPluginTest.java b/solr/core/src/test/org/apache/solr/security/AuditLoggerPluginTest.javaindex 3e2b3165cca..571b8a6f5fc 100644--- a/solr/core/src/test/org/apache/solr/security/AuditLoggerPluginTest.java+++ b/solr/core/src/test/org/apache/solr/security/AuditLoggerPluginTest.java@@ -20,10 +20,10 @@ package org.apache.solr.security;import io.opentelemetry.api.common.Attributes;import java.util.ArrayList;import java.util.Arrays;-import java.util.Collections;import java.util.Date;import java.util.HashMap;import java.util.List;+import java.util.Map;import java.util.concurrent.atomic.AtomicInteger;import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.common.SolrException;@@ -88,7 +88,7 @@ public class AuditLoggerPluginTest extends SolrTestCaseJ4 {.setHttpMethod("POST").setMessage("Error occurred").setDate(SAMPLE_DATE)- .setSolrParams(Collections.singletonMap("action", Collections.singletonList("DELETE")))+ .setSolrParams(Map.of("action", List.of("DELETE"))).setResource("/admin/collections");protected static final AuditEvent EVENT_UPDATE =new AuditEvent(AuditEvent.EventType.COMPLETED)@@ -97,7 +97,7 @@ public class AuditLoggerPluginTest extends SolrTestCaseJ4 {.setRequestType(AuditEvent.RequestType.UPDATE).setMessage("Success").setDate(SAMPLE_DATE)- .setCollections(Collections.singletonList("updatecoll"))+ .setCollections(List.of("updatecoll")).setRequestType(AuditEvent.RequestType.UPDATE).setResource("/update");protected static final AuditEvent EVENT_STREAMING =@@ -107,7 +107,7 @@ public class AuditLoggerPluginTest extends SolrTestCaseJ4 {.setRequestType(AuditEvent.RequestType.STREAMING).setMessage("Success").setDate(SAMPLE_DATE)- .setCollections(Collections.singletonList("streamcoll"))+ .setCollections(List.of("streamcoll")).setResource("/stream");protected static final AuditEvent EVENT_HEALTH_API =new AuditEvent(AuditEvent.EventType.COMPLETED)@@ -152,7 +152,7 @@ public class AuditLoggerPluginTest extends SolrTestCaseJ4 {@Testpublic void init() {config = new HashMap<>();- config.put("eventTypes", Collections.singletonList("REJECTED"));+ config.put("eventTypes", List.of("REJECTED"));config.put("async", false);plugin.init(config);assertTrue(plugin.shouldLog(EVENT_REJECTED.getEventType()));@@ -174,7 +174,7 @@ public class AuditLoggerPluginTest extends SolrTestCaseJ4 {@Test(expected = SolrException.class)public void invalidMuteRule() {- config.put("muteRules", Collections.singletonList("foo:bar"));+ config.put("muteRules", List.of("foo:bar"));plugin.init(config);}diff --git a/solr/core/src/test/org/apache/solr/security/BaseTestRuleBasedAuthorizationPlugin.java b/solr/core/src/test/org/apache/solr/security/BaseTestRuleBasedAuthorizationPlugin.javaindex 9cfa057b4df..374e3fc1e5d 100644--- a/solr/core/src/test/org/apache/solr/security/BaseTestRuleBasedAuthorizationPlugin.java+++ b/solr/core/src/test/org/apache/solr/security/BaseTestRuleBasedAuthorizationPlugin.java@@ -16,8 +16,6 @@*/package org.apache.solr.security;-import static java.util.Collections.singletonList;-import static java.util.Collections.singletonMap;import static org.apache.solr.common.util.CommandOperation.captureErrors;import static org.apache.solr.common.util.Utils.getObjectByPath;@@ -36,6 +34,7 @@ import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.common.params.MapSolrParams;import org.apache.solr.common.params.SolrParams;import org.apache.solr.common.util.CommandOperation;+import org.apache.solr.common.util.SuppressForbidden;import org.apache.solr.common.util.Utils;import org.apache.solr.handler.DumpRequestHandler;import org.apache.solr.handler.ReplicationHandler;@@ -214,7 +213,7 @@ public class BaseTestRuleBasedAuthorizationPlugin extends SolrTestCaseJ4 {"handler",new CollectionsHandler(),"params",- new MapSolrParams(singletonMap("action", "LIST"))),+ new MapSolrParams(Map.of("action", "LIST"))),STATUS_OK);checkRules(@@ -228,7 +227,7 @@ public class BaseTestRuleBasedAuthorizationPlugin extends SolrTestCaseJ4 {"handler",new CollectionsHandler(),"params",- new MapSolrParams(singletonMap("action", "LIST"))),+ new MapSolrParams(Map.of("action", "LIST"))),STATUS_OK);checkRules(@@ -240,7 +239,7 @@ public class BaseTestRuleBasedAuthorizationPlugin extends SolrTestCaseJ4 {"handler",new CollectionsHandler(),"params",- new MapSolrParams(singletonMap("action", "CREATE"))),+ new MapSolrParams(Map.of("action", "CREATE"))),PROMPT_FOR_CREDENTIALS);checkRules(@@ -252,7 +251,7 @@ public class BaseTestRuleBasedAuthorizationPlugin extends SolrTestCaseJ4 {"handler",new CollectionsHandler(),"params",- new MapSolrParams(singletonMap("action", "RELOAD"))),+ new MapSolrParams(Map.of("action", "RELOAD"))),PROMPT_FOR_CREDENTIALS);checkRules(@@ -266,7 +265,7 @@ public class BaseTestRuleBasedAuthorizationPlugin extends SolrTestCaseJ4 {"handler",new CollectionsHandler(),"params",- new MapSolrParams(singletonMap("action", "CREATE"))),+ new MapSolrParams(Map.of("action", "CREATE"))),FORBIDDEN);checkRules(@@ -280,7 +279,7 @@ public class BaseTestRuleBasedAuthorizationPlugin extends SolrTestCaseJ4 {"handler",new CollectionsHandler(),"params",- new MapSolrParams(singletonMap("action", "CREATE"))),+ new MapSolrParams(Map.of("action", "CREATE"))),STATUS_OK);checkRules(@@ -292,7 +291,7 @@ public class BaseTestRuleBasedAuthorizationPlugin extends SolrTestCaseJ4 {"handler",new SearchHandler(),"collectionRequests",- singletonList(new CollectionRequest("mycoll")),+ List.of(new CollectionRequest("mycoll")),"userPrincipal","joe"),FORBIDDEN);@@ -311,7 +310,7 @@ public class BaseTestRuleBasedAuthorizationPlugin extends SolrTestCaseJ4 {"handler",new ReplicationHandler(),"collectionRequests",- singletonList(new CollectionRequest("mycoll"))),+ List.of(new CollectionRequest("mycoll"))),STATUS_OK); // Replication requires "READ" permission, which Tim hascheckRules(@@ -325,7 +324,7 @@ public class BaseTestRuleBasedAuthorizationPlugin extends SolrTestCaseJ4 {"handler",new ReplicationHandler(),"collectionRequests",- singletonList(new CollectionRequest("mycoll"))),+ List.of(new CollectionRequest("mycoll"))),FORBIDDEN); // User cio has role 'su' which does not have 'read' permissioncheckRules(@@ -339,7 +338,7 @@ public class BaseTestRuleBasedAuthorizationPlugin extends SolrTestCaseJ4 {"handler",new CollectionsHandler(),"params",- new MapSolrParams(singletonMap("action", "CREATE"))),+ new MapSolrParams(Map.of("action", "CREATE"))),STATUS_OK);}@@ -359,7 +358,7 @@ public class BaseTestRuleBasedAuthorizationPlugin extends SolrTestCaseJ4 {"handler",new CoreAdminHandler(null),"params",- new MapSolrParams(singletonMap("action", "CREATE"))),+ new MapSolrParams(Map.of("action", "CREATE"))),PROMPT_FOR_CREDENTIALS);checkRules(@@ -373,7 +372,7 @@ public class BaseTestRuleBasedAuthorizationPlugin extends SolrTestCaseJ4 {"handler",new CoreAdminHandler(null),"params",- new MapSolrParams(singletonMap("action", "CREATE"))),+ new MapSolrParams(Map.of("action", "CREATE"))),FORBIDDEN);checkRules(@@ -387,7 +386,7 @@ public class BaseTestRuleBasedAuthorizationPlugin extends SolrTestCaseJ4 {"handler",new CoreAdminHandler(null),"params",- new MapSolrParams(singletonMap("action", "STATUS"))),+ new MapSolrParams(Map.of("action", "STATUS"))),STATUS_OK);checkRules(@@ -401,7 +400,7 @@ public class BaseTestRuleBasedAuthorizationPlugin extends SolrTestCaseJ4 {"handler",new CoreAdminHandler(null),"params",- new MapSolrParams(singletonMap("action", "CREATE"))),+ new MapSolrParams(Map.of("action", "CREATE"))),STATUS_OK);}@@ -421,7 +420,7 @@ public class BaseTestRuleBasedAuthorizationPlugin extends SolrTestCaseJ4 {"handler",new DumpRequestHandler(),"params",- new MapSolrParams(singletonMap("key", "VAL1"))),+ new MapSolrParams(Map.of("key", "VAL1"))),PROMPT_FOR_CREDENTIALS);checkRules(@@ -435,7 +434,7 @@ public class BaseTestRuleBasedAuthorizationPlugin extends SolrTestCaseJ4 {"handler",new DumpRequestHandler(),"params",- new MapSolrParams(singletonMap("key", "Val1"))),+ new MapSolrParams(Map.of("key", "Val1"))),PROMPT_FOR_CREDENTIALS);checkRules(@@ -449,7 +448,7 @@ public class BaseTestRuleBasedAuthorizationPlugin extends SolrTestCaseJ4 {"handler",new DumpRequestHandler(),"params",- new MapSolrParams(singletonMap("key", "Val1"))),+ new MapSolrParams(Map.of("key", "Val1"))),PROMPT_FOR_CREDENTIALS);checkRules(@@ -465,7 +464,7 @@ public class BaseTestRuleBasedAuthorizationPlugin extends SolrTestCaseJ4 {"handler",new DumpRequestHandler(),"params",- new MapSolrParams(singletonMap("key", "Val1"))),+ new MapSolrParams(Map.of("key", "Val1"))),FORBIDDEN);checkRules(@@ -481,7 +480,7 @@ public class BaseTestRuleBasedAuthorizationPlugin extends SolrTestCaseJ4 {"handler",new DumpRequestHandler(),"params",- new MapSolrParams(singletonMap("key", "Val2"))),+ new MapSolrParams(Map.of("key", "Val2"))),STATUS_OK);checkRules(@@ -497,7 +496,7 @@ public class BaseTestRuleBasedAuthorizationPlugin extends SolrTestCaseJ4 {"handler",new DumpRequestHandler(),"params",- new MapSolrParams(singletonMap("key", "VAL2"))),+ new MapSolrParams(Map.of("key", "VAL2"))),FORBIDDEN);}@@ -524,7 +523,7 @@ public class BaseTestRuleBasedAuthorizationPlugin extends SolrTestCaseJ4 {"handler",new UpdateRequestHandler(),"params",- new MapSolrParams(singletonMap("key", "VAL2"))),+ new MapSolrParams(Map.of("key", "VAL2"))),FORBIDDEN,customRules);}@@ -554,7 +553,7 @@ public class BaseTestRuleBasedAuthorizationPlugin extends SolrTestCaseJ4 {"handler",handler,"params",- new MapSolrParams(singletonMap("key", "VAL2"))),+ new MapSolrParams(Map.of("key", "VAL2"))),STATUS_OK);handler = new PropertiesRequestHandler();@@ -601,7 +600,7 @@ public class BaseTestRuleBasedAuthorizationPlugin extends SolrTestCaseJ4 {"handler",new UpdateRequestHandler(),"params",- new MapSolrParams(singletonMap("key", "VAL2"))),+ new MapSolrParams(Map.of("key", "VAL2"))),STATUS_OK);handler = new PropertiesRequestHandler();@@ -648,7 +647,7 @@ public class BaseTestRuleBasedAuthorizationPlugin extends SolrTestCaseJ4 {"handler",new UpdateRequestHandler(),"params",- new MapSolrParams(singletonMap("key", "VAL2"))),+ new MapSolrParams(Map.of("key", "VAL2"))),FORBIDDEN);handler = new PropertiesRequestHandler();@@ -671,6 +670,7 @@ public class BaseTestRuleBasedAuthorizationPlugin extends SolrTestCaseJ4 {}@Test+ @SuppressForbidden(reason = "singletonList(null) is intentional")public void testGetPermissionNamesForRoles() {// Tests the method that maps role(s) to permissions, used by SystemInfoHandler to provide UI// with logged-in user's permissions@@ -689,8 +689,7 @@ public class BaseTestRuleBasedAuthorizationPlugin extends SolrTestCaseJ4 {assertEquals(Set.of("collection-admin-read"),plugin.getPermissionNamesForRoles(Collections.singletonList(null)));- assertEquals(- Set.of("freeforall"), plugin.getPermissionNamesForRoles(Collections.singletonList("*")));+ assertEquals(Set.of("freeforall"), plugin.getPermissionNamesForRoles(List.of("*")));} catch (IOException e) {; // swallow error, otherwise you have to add a _lot_ of exceptions to methods.}@@ -870,7 +869,7 @@ public class BaseTestRuleBasedAuthorizationPlugin extends SolrTestCaseJ4 {public List<CollectionRequest> getCollectionRequests() {Object collectionRequests = values.get("collectionRequests");if (collectionRequests instanceof String) {- return singletonList(new CollectionRequest((String) collectionRequests));+ return List.of(new CollectionRequest((String) collectionRequests));}return (List<CollectionRequest>) collectionRequests;}diff --git a/solr/core/src/test/org/apache/solr/security/BasicAuthIntegrationTest.java b/solr/core/src/test/org/apache/solr/security/BasicAuthIntegrationTest.javaindex 2ef080c6ef1..d08280c17bc 100644--- a/solr/core/src/test/org/apache/solr/security/BasicAuthIntegrationTest.java+++ b/solr/core/src/test/org/apache/solr/security/BasicAuthIntegrationTest.java@@ -17,10 +17,8 @@package org.apache.solr.security;import static java.nio.charset.StandardCharsets.UTF_8;-import static java.util.Collections.singletonMap;import java.io.IOException;-import java.lang.invoke.MethodHandles;import java.util.ArrayList;import java.util.Collections;import java.util.Map;@@ -63,13 +61,9 @@ import org.eclipse.jetty.client.StringRequestContent;import org.junit.After;import org.junit.Before;import org.junit.Test;-import org.slf4j.Logger;-import org.slf4j.LoggerFactory;public class BasicAuthIntegrationTest extends SolrCloudAuthTestCase {- private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());-private static final String COLLECTION = "authCollection";@Before@@ -191,7 +185,7 @@ public class BasicAuthIntegrationTest extends SolrCloudAuthTestCase {httpClient,baseUrl + authzPrefix,Utils.toJSONString(- singletonMap(+ Map.of("set-permission", Map.of("collection", "x", "path", "/update/*", "role", "dev"))),"harry","HarryIsUberCool");@@ -204,8 +198,7 @@ public class BasicAuthIntegrationTest extends SolrCloudAuthTestCase {httpClient,baseUrl + authzPrefix,Utils.toJSONString(- singletonMap(- "set-permission", Map.of("name", "collection-admin-edit", "role", "admin"))),+ Map.of("set-permission", Map.of("name", "collection-admin-edit", "role", "admin"))),"harry","HarryIsUberCool");verifySecurityStatus(@@ -298,7 +291,7 @@ public class BasicAuthIntegrationTest extends SolrCloudAuthTestCase {fail("Request should have failed because of missing auth");}- SolrParams params = new MapSolrParams(Collections.singletonMap("q", "*:*"));+ SolrParams params = new MapSolrParams(Map.of("q", "*:*"));// Query that fails due to missing credentialsexp =expectThrows(@@ -372,7 +365,7 @@ public class BasicAuthIntegrationTest extends SolrCloudAuthTestCase {new V2Request.Builder("/cluster/plugin").forceV2(true).POST()- .withPayload(singletonMap("add", plugin))+ .withPayload(Map.of("add", plugin)).build();v2Request.setBasicAuthCredentials("harry", "HarryIsUberCool");v2Request.process(cluster.getSolrClient());diff --git a/solr/core/src/test/org/apache/solr/security/BasicAuthStandaloneTest.java b/solr/core/src/test/org/apache/solr/security/BasicAuthStandaloneTest.javaindex 1f06eecd21a..63c83c13579 100644--- a/solr/core/src/test/org/apache/solr/security/BasicAuthStandaloneTest.java+++ b/solr/core/src/test/org/apache/solr/security/BasicAuthStandaloneTest.java@@ -22,10 +22,9 @@ import static org.apache.solr.security.BasicAuthIntegrationTest.STD_CONF;import static org.apache.solr.security.BasicAuthIntegrationTest.verifySecurityStatus;import java.io.IOException;-import java.lang.invoke.MethodHandles;import java.nio.file.Path;import java.util.Base64;-import java.util.Collections;+import java.util.Map;import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.client.solrj.SolrClient;import org.apache.solr.common.params.MapSolrParams;@@ -38,13 +37,9 @@ import org.eclipse.jetty.client.StringRequestContent;import org.junit.After;import org.junit.Before;import org.junit.Test;-import org.slf4j.Logger;-import org.slf4j.LoggerFactory;public class BasicAuthStandaloneTest extends SolrTestCaseJ4 {- private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());-SecurityConfHandlerLocalForTesting securityConfHandler;SolrInstance instance = null;JettySolrRunner jetty;@@ -124,7 +119,7 @@ public class BasicAuthStandaloneTest extends SolrTestCaseJ4 {command = "{\n" + "'set-permission': {'name': 'read', 'role':'solr'}\n" + "}";doHttpPost(httpClient, baseUrl + authzPrefix, command, "solr", "SolrRocks");try {- solrClient.query("collection1", new MapSolrParams(Collections.singletonMap("q", "foo")));+ solrClient.query("collection1", new MapSolrParams(Map.of("q", "foo")));fail("Should return a 401 response");} catch (Exception e) {// Test that the second doPost request to /security/authorization went throughdiff --git a/solr/core/src/test/org/apache/solr/security/PKIAuthenticationIntegrationTest.java b/solr/core/src/test/org/apache/solr/security/PKIAuthenticationIntegrationTest.javaindex 5e82c858a22..402f1fa2920 100644--- a/solr/core/src/test/org/apache/solr/security/PKIAuthenticationIntegrationTest.java+++ b/solr/core/src/test/org/apache/solr/security/PKIAuthenticationIntegrationTest.java@@ -16,8 +16,6 @@*/package org.apache.solr.security;-import static java.util.Collections.singletonMap;-import jakarta.servlet.http.HttpServletRequest;import java.lang.invoke.MethodHandles;import java.security.Principal;@@ -47,9 +45,9 @@ public class PKIAuthenticationIntegrationTest extends SolrCloudAuthTestCase {Utils.toJSONString(Map.of("authorization",- singletonMap("class", MockAuthorizationPlugin.class.getName()),+ Map.of("class", MockAuthorizationPlugin.class.getName()),"authentication",- singletonMap("class", MockAuthenticationPlugin.class.getName())));+ Map.of("class", MockAuthenticationPlugin.class.getName())));configureCluster(2).addConfig("conf", configset("cloud-minimal"))diff --git a/solr/core/src/test/org/apache/solr/security/TestExternalRoleRuleBasedAuthorizationPlugin.java b/solr/core/src/test/org/apache/solr/security/TestExternalRoleRuleBasedAuthorizationPlugin.javaindex cf0c0dc1e23..f3d2f5b815c 100644--- a/solr/core/src/test/org/apache/solr/security/TestExternalRoleRuleBasedAuthorizationPlugin.java+++ b/solr/core/src/test/org/apache/solr/security/TestExternalRoleRuleBasedAuthorizationPlugin.java@@ -19,10 +19,10 @@ package org.apache.solr.security;import java.security.Principal;import java.util.Arrays;-import java.util.Collections;import java.util.HashMap;import java.util.HashSet;import java.util.Map;+import java.util.Set;/*** Tests {@link ExternalRoleRuleBasedAuthorizationPlugin} through simulating principals with roles@@ -49,7 +49,7 @@ public class TestExternalRoleRuleBasedAuthorizationPlugin@Overrideprotected void setUserRole(String user, String role) {- principals.put(user, new PrincipalWithUserRoles(user, Collections.singleton(role)));+ principals.put(user, new PrincipalWithUserRoles(user, Set.of(role)));}@Overridediff --git a/solr/core/src/test/org/apache/solr/security/TestSha256AuthenticationProvider.java b/solr/core/src/test/org/apache/solr/security/TestSha256AuthenticationProvider.javaindex 1646f2a772e..632fd16b35a 100644--- a/solr/core/src/test/org/apache/solr/security/TestSha256AuthenticationProvider.java+++ b/solr/core/src/test/org/apache/solr/security/TestSha256AuthenticationProvider.java@@ -16,12 +16,10 @@*/package org.apache.solr.security;-import static java.util.Collections.singletonMap;-import java.io.IOException;import java.util.Arrays;-import java.util.Collections;import java.util.HashMap;+import java.util.List;import java.util.Map;import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.common.util.CommandOperation;@@ -35,10 +33,10 @@ public class TestSha256AuthenticationProvider extends SolrTestCaseJ4 {String pwd = "Friendly";String user = "marcus";Map<String, Object> latestConf = createConfigMap(user, pwd);- Map<String, Object> params = singletonMap(user, pwd);+ Map<String, Object> params = Map.of(user, pwd);Map<String, Object> result =zkAuthenticationProvider.edit(- latestConf, Collections.singletonList(new CommandOperation("set-user", params)));+ latestConf, List.of(new CommandOperation("set-user", params)));zkAuthenticationProvider = new Sha256AuthenticationProvider();zkAuthenticationProvider.init(result);@@ -54,13 +52,13 @@ public class TestSha256AuthenticationProvider extends SolrTestCaseJ4 {Map<String, Object> latestConf = createConfigMap("solr", "SolrRocks");CommandOperation blockUnknown =- new CommandOperation("set-property", singletonMap("blockUnknown", true));- basicAuthPlugin.edit(latestConf, Collections.singletonList(blockUnknown));+ new CommandOperation("set-property", Map.of("blockUnknown", true));+ basicAuthPlugin.edit(latestConf, List.of(blockUnknown));assertEquals(Boolean.TRUE, latestConf.get("blockUnknown"));basicAuthPlugin.init(latestConf);assertTrue(basicAuthPlugin.getBlockUnknown());- blockUnknown = new CommandOperation("set-property", singletonMap("blockUnknown", false));- basicAuthPlugin.edit(latestConf, Collections.singletonList(blockUnknown));+ blockUnknown = new CommandOperation("set-property", Map.of("blockUnknown", false));+ basicAuthPlugin.edit(latestConf, List.of(blockUnknown));assertEquals(Boolean.FALSE, latestConf.get("blockUnknown"));basicAuthPlugin.init(latestConf);assertFalse(basicAuthPlugin.getBlockUnknown());diff --git a/solr/core/src/test/org/apache/solr/spelling/DirectSolrSpellCheckerTest.java b/solr/core/src/test/org/apache/solr/spelling/DirectSolrSpellCheckerTest.javaindex e6fc2bd328e..9091f650184 100644--- a/solr/core/src/test/org/apache/solr/spelling/DirectSolrSpellCheckerTest.java+++ b/solr/core/src/test/org/apache/solr/spelling/DirectSolrSpellCheckerTest.java@@ -17,7 +17,7 @@package org.apache.solr.spelling;import java.util.Collection;-import java.util.Collections;+import java.util.List;import java.util.Map;import org.apache.lucene.tests.util.LuceneTestCase.SuppressTempFileChecks;import org.apache.solr.SolrTestCaseJ4;@@ -89,7 +89,7 @@ public class DirectSolrSpellCheckerTest extends SolrTestCaseJ4 {assertTrue("suggestions should be empty", suggestions.isEmpty());// Check empty token due to spellcheck.q = ""- spellOpts.tokens = Collections.singletonList(new Token("", 0, 0));+ spellOpts.tokens = List.of(new Token("", 0, 0));result = checker.getSuggestions(spellOpts);assertNotNull("result shouldn't be null", result);suggestions = result.get(spellOpts.tokens.iterator().next());diff --git a/solr/core/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java b/solr/core/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.javaindex 61e17dbfca8..5065e0c398a 100644--- a/solr/core/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java+++ b/solr/core/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java@@ -19,7 +19,7 @@ package org.apache.solr.spelling;import java.nio.file.Files;import java.nio.file.Path;import java.util.Collection;-import java.util.Collections;+import java.util.List;import java.util.Map;import org.apache.lucene.tests.util.LuceneTestCase;import org.apache.lucene.tests.util.LuceneTestCase.SuppressTempFileChecks;@@ -99,7 +99,7 @@ public class FileBasedSpellCheckerTest extends SolrTestCaseJ4 {assertTrue("suggestions should be empty", suggestions.isEmpty());// Check empty token due to spellcheck.q = ""- spellOpts.tokens = Collections.singletonList(new Token("", 0, 0));+ spellOpts.tokens = List.of(new Token("", 0, 0));result = checker.getSuggestions(spellOpts);assertNotNull("result shouldn't be null", result);suggestions = result.get(spellOpts.tokens.iterator().next());diff --git a/solr/core/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java b/solr/core/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.javaindex da25b002a7e..6ee537f814d 100644--- a/solr/core/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java+++ b/solr/core/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java@@ -19,9 +19,9 @@ package org.apache.solr.spelling;import java.nio.file.Files;import java.nio.file.Path;import java.util.Collection;-import java.util.Collections;import java.util.Comparator;import java.util.Date;+import java.util.List;import java.util.Map;import org.apache.lucene.analysis.core.WhitespaceAnalyzer;import org.apache.lucene.document.Document;@@ -197,7 +197,7 @@ public class IndexBasedSpellCheckerTest extends SolrTestCaseJ4 {(int) entry.getValue());// Check empty token due to spellcheck.q = ""- spellOpts.tokens = Collections.singletonList(new Token("", 0, 0));+ spellOpts.tokens = List.of(new Token("", 0, 0));result = checker.getSuggestions(spellOpts);assertNotNull(result);suggestions = result.get(spellOpts.tokens.iterator().next());diff --git a/solr/core/src/test/org/apache/solr/uninverting/TestFieldCacheSort.java b/solr/core/src/test/org/apache/solr/uninverting/TestFieldCacheSort.javaindex 31267a9be62..36b6598fd66 100644--- a/solr/core/src/test/org/apache/solr/uninverting/TestFieldCacheSort.java+++ b/solr/core/src/test/org/apache/solr/uninverting/TestFieldCacheSort.java@@ -17,7 +17,6 @@package org.apache.solr.uninverting;import java.io.IOException;-import java.util.Collections;import java.util.HashMap;import java.util.Map;import org.apache.lucene.document.Document;@@ -80,8 +79,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(newStringField("value", "bar", Field.Store.YES));writer.addDocument(doc);Type type = sortType == SortField.Type.STRING ? Type.SORTED : Type.BINARY;- IndexReader ir =- UninvertingReader.wrap(writer.getReader(), Collections.singletonMap("value", type));+ IndexReader ir = UninvertingReader.wrap(writer.getReader(), Map.of("value", type));writer.close();IndexSearcher searcher = newSearcher(ir);@@ -119,8 +117,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(newStringField("value", "bar", Field.Store.YES));writer.addDocument(doc);Type type = sortType == SortField.Type.STRING ? Type.SORTED : Type.BINARY;- IndexReader ir =- UninvertingReader.wrap(writer.getReader(), Collections.singletonMap("value", type));+ IndexReader ir = UninvertingReader.wrap(writer.getReader(), Map.of("value", type));writer.close();IndexSearcher searcher = newSearcher(ir);@@ -156,8 +153,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(newStringField("value", "foo", Field.Store.YES));writer.addDocument(doc);Type type = sortType == SortField.Type.STRING ? Type.SORTED : Type.BINARY;- IndexReader ir =- UninvertingReader.wrap(writer.getReader(), Collections.singletonMap("value", type));+ IndexReader ir = UninvertingReader.wrap(writer.getReader(), Map.of("value", type));writer.close();IndexSearcher searcher = newSearcher(ir);@@ -194,8 +190,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(newStringField("value", "bar", Field.Store.YES));writer.addDocument(doc);Type type = sortType == SortField.Type.STRING ? Type.SORTED : Type.BINARY;- IndexReader ir =- UninvertingReader.wrap(writer.getReader(), Collections.singletonMap("value", type));+ IndexReader ir = UninvertingReader.wrap(writer.getReader(), Map.of("value", type));writer.close();IndexSearcher searcher = newSearcher(ir);@@ -234,8 +229,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(newStringField("value", "bar", Field.Store.YES));writer.addDocument(doc);Type type = sortType == SortField.Type.STRING ? Type.SORTED : Type.BINARY;- IndexReader ir =- UninvertingReader.wrap(writer.getReader(), Collections.singletonMap("value", type));+ IndexReader ir = UninvertingReader.wrap(writer.getReader(), Map.of("value", type));writer.close();IndexSearcher searcher = newSearcher(ir);@@ -274,8 +268,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(newStringField("value", "bar", Field.Store.YES));writer.addDocument(doc);Type type = sortType == SortField.Type.STRING ? Type.SORTED : Type.BINARY;- IndexReader ir =- UninvertingReader.wrap(writer.getReader(), Collections.singletonMap("value", type));+ IndexReader ir = UninvertingReader.wrap(writer.getReader(), Map.of("value", type));writer.close();IndexSearcher searcher = newSearcher(ir);@@ -315,8 +308,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(newStringField("value", "bar", Field.Store.YES));writer.addDocument(doc);Type type = sortType == SortField.Type.STRING ? Type.SORTED : Type.BINARY;- IndexReader ir =- UninvertingReader.wrap(writer.getReader(), Collections.singletonMap("value", type));+ IndexReader ir = UninvertingReader.wrap(writer.getReader(), Map.of("value", type));writer.close();IndexSearcher searcher = newSearcher(ir);@@ -465,8 +457,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(new StoredField("value", 4));writer.addDocument(doc);IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.INTEGER_POINT));+ UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.INTEGER_POINT));writer.close();IndexSearcher searcher = newSearcher(ir, false);@@ -498,8 +489,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(new StoredField("value", 4));writer.addDocument(doc);IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.INTEGER_POINT));+ UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.INTEGER_POINT));writer.close();IndexSearcher searcher = newSearcher(ir, false);@@ -533,8 +523,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(new StoredField("value", 4));writer.addDocument(doc);IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.INTEGER_POINT));+ UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.INTEGER_POINT));writer.close();IndexSearcher searcher = newSearcher(ir, false);@@ -570,8 +559,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(new StoredField("value", 4));writer.addDocument(doc);IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.INTEGER_POINT));+ UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.INTEGER_POINT));writer.close();IndexSearcher searcher = newSearcher(ir, false);@@ -602,8 +590,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(new LegacyIntField("value", 4, Field.Store.YES));writer.addDocument(doc);IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.LEGACY_INTEGER));+ UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.LEGACY_INTEGER));writer.close();IndexSearcher searcher = newSearcher(ir);@@ -633,8 +620,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(new LegacyIntField("value", 4, Field.Store.YES));writer.addDocument(doc);IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.LEGACY_INTEGER));+ UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.LEGACY_INTEGER));writer.close();IndexSearcher searcher = newSearcher(ir);@@ -667,8 +653,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(new LegacyIntField("value", 4, Field.Store.YES));writer.addDocument(doc);IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.LEGACY_INTEGER));+ UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.LEGACY_INTEGER));writer.close();IndexSearcher searcher = newSearcher(ir);@@ -701,8 +686,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(new LegacyIntField("value", 4, Field.Store.YES));writer.addDocument(doc);IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.LEGACY_INTEGER));+ UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.LEGACY_INTEGER));writer.close();IndexSearcher searcher = newSearcher(ir);@@ -735,9 +719,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(new LongPoint("value", 4));doc.add(new StoredField("value", 4));writer.addDocument(doc);- IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.LONG_POINT));+ IndexReader ir = UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.LONG_POINT));writer.close();IndexSearcher searcher = newSearcher(ir, false);@@ -768,9 +750,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(new LongPoint("value", 4));doc.add(new StoredField("value", 4));writer.addDocument(doc);- IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.LONG_POINT));+ IndexReader ir = UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.LONG_POINT));writer.close();IndexSearcher searcher = newSearcher(ir, false);@@ -803,9 +783,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(new LongPoint("value", 4));doc.add(new StoredField("value", 4));writer.addDocument(doc);- IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.LONG_POINT));+ IndexReader ir = UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.LONG_POINT));writer.close();IndexSearcher searcher = newSearcher(ir, false);@@ -840,9 +818,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(new LongPoint("value", 4));doc.add(new StoredField("value", 4));writer.addDocument(doc);- IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.LONG_POINT));+ IndexReader ir = UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.LONG_POINT));writer.close();IndexSearcher searcher = newSearcher(ir, false);@@ -872,9 +848,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc = new Document();doc.add(new LegacyLongField("value", 4, Field.Store.YES));writer.addDocument(doc);- IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.LEGACY_LONG));+ IndexReader ir = UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.LEGACY_LONG));writer.close();IndexSearcher searcher = newSearcher(ir);@@ -903,9 +877,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc = new Document();doc.add(new LegacyLongField("value", 4, Field.Store.YES));writer.addDocument(doc);- IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.LEGACY_LONG));+ IndexReader ir = UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.LEGACY_LONG));writer.close();IndexSearcher searcher = newSearcher(ir);@@ -937,9 +909,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc = new Document();doc.add(new LegacyLongField("value", 4, Field.Store.YES));writer.addDocument(doc);- IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.LEGACY_LONG));+ IndexReader ir = UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.LEGACY_LONG));writer.close();IndexSearcher searcher = newSearcher(ir);@@ -971,9 +941,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc = new Document();doc.add(new LegacyLongField("value", 4, Field.Store.YES));writer.addDocument(doc);- IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.LEGACY_LONG));+ IndexReader ir = UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.LEGACY_LONG));writer.close();IndexSearcher searcher = newSearcher(ir);@@ -1006,9 +974,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(new FloatPoint("value", 4.2f));doc.add(new StoredField("value", 4.2f));writer.addDocument(doc);- IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.FLOAT_POINT));+ IndexReader ir = UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.FLOAT_POINT));writer.close();IndexSearcher searcher = newSearcher(ir, false);@@ -1039,9 +1005,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(new FloatPoint("value", 4.2f));doc.add(new StoredField("value", 4.2f));writer.addDocument(doc);- IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.FLOAT_POINT));+ IndexReader ir = UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.FLOAT_POINT));writer.close();IndexSearcher searcher = newSearcher(ir, false);@@ -1074,9 +1038,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(new FloatPoint("value", 4.2f));doc.add(new StoredField("value", 4.2f));writer.addDocument(doc);- IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.FLOAT_POINT));+ IndexReader ir = UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.FLOAT_POINT));writer.close();IndexSearcher searcher = newSearcher(ir, false);@@ -1111,9 +1073,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(new FloatPoint("value", 4.2f));doc.add(new StoredField("value", 4.2f));writer.addDocument(doc);- IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.FLOAT_POINT));+ IndexReader ir = UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.FLOAT_POINT));writer.close();IndexSearcher searcher = newSearcher(ir, false);@@ -1143,9 +1103,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc = new Document();doc.add(new LegacyFloatField("value", 4.2f, Field.Store.YES));writer.addDocument(doc);- IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.LEGACY_FLOAT));+ IndexReader ir = UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.LEGACY_FLOAT));writer.close();IndexSearcher searcher = newSearcher(ir);@@ -1174,9 +1132,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc = new Document();doc.add(new LegacyFloatField("value", 4.2f, Field.Store.YES));writer.addDocument(doc);- IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.LEGACY_FLOAT));+ IndexReader ir = UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.LEGACY_FLOAT));writer.close();IndexSearcher searcher = newSearcher(ir);@@ -1208,9 +1164,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc = new Document();doc.add(new LegacyFloatField("value", 4.2f, Field.Store.YES));writer.addDocument(doc);- IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.LEGACY_FLOAT));+ IndexReader ir = UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.LEGACY_FLOAT));writer.close();IndexSearcher searcher = newSearcher(ir);@@ -1242,9 +1196,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc = new Document();doc.add(new LegacyFloatField("value", 4.2f, Field.Store.YES));writer.addDocument(doc);- IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.LEGACY_FLOAT));+ IndexReader ir = UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.LEGACY_FLOAT));writer.close();IndexSearcher searcher = newSearcher(ir);@@ -1281,9 +1233,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(new DoublePoint("value", 4.2333333333332));doc.add(new StoredField("value", 4.2333333333332));writer.addDocument(doc);- IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.DOUBLE_POINT));+ IndexReader ir = UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.DOUBLE_POINT));writer.close();IndexSearcher searcher = newSearcher(ir, false);@@ -1316,9 +1266,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(new StoredField("value", -0d));writer.addDocument(doc);doc = new Document();- IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.DOUBLE_POINT));+ IndexReader ir = UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.DOUBLE_POINT));writer.close();IndexSearcher searcher = newSearcher(ir, false);@@ -1369,9 +1317,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(new DoublePoint("value", 4.2333333333332));doc.add(new StoredField("value", 4.2333333333332));writer.addDocument(doc);- IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.DOUBLE_POINT));+ IndexReader ir = UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.DOUBLE_POINT));writer.close();IndexSearcher searcher = newSearcher(ir, false);@@ -1412,9 +1358,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(new DoublePoint("value", 4.2333333333332));doc.add(new StoredField("value", 4.2333333333332));writer.addDocument(doc);- IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.DOUBLE_POINT));+ IndexReader ir = UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.DOUBLE_POINT));writer.close();IndexSearcher searcher = newSearcher(ir, false);@@ -1456,9 +1400,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(new DoublePoint("value", 4.2333333333332));doc.add(new StoredField("value", 4.2333333333332));writer.addDocument(doc);- IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.DOUBLE_POINT));+ IndexReader ir = UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.DOUBLE_POINT));writer.close();IndexSearcher searcher = newSearcher(ir, false);@@ -1495,8 +1437,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(new LegacyDoubleField("value", 4.2333333333332, Field.Store.YES));writer.addDocument(doc);IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.LEGACY_DOUBLE));+ UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.LEGACY_DOUBLE));writer.close();IndexSearcher searcher = newSearcher(ir);@@ -1528,8 +1469,7 @@ public class TestFieldCacheSort extends SolrTestCase {writer.addDocument(doc);doc = new Document();IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.LEGACY_DOUBLE));+ UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.LEGACY_DOUBLE));writer.close();IndexSearcher searcher = newSearcher(ir);@@ -1578,8 +1518,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(new LegacyDoubleField("value", 4.2333333333332, Field.Store.YES));writer.addDocument(doc);IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.LEGACY_DOUBLE));+ UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.LEGACY_DOUBLE));writer.close();IndexSearcher searcher = newSearcher(ir);@@ -1618,8 +1557,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(new LegacyDoubleField("value", 4.2333333333332, Field.Store.YES));writer.addDocument(doc);IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.LEGACY_DOUBLE));+ UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.LEGACY_DOUBLE));writer.close();IndexSearcher searcher = newSearcher(ir);@@ -1658,8 +1596,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(new LegacyDoubleField("value", 4.2333333333332, Field.Store.YES));writer.addDocument(doc);IndexReader ir =- UninvertingReader.wrap(- writer.getReader(), Collections.singletonMap("value", Type.LEGACY_DOUBLE));+ UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.LEGACY_DOUBLE));writer.close();IndexSearcher searcher = newSearcher(ir);@@ -1695,8 +1632,7 @@ public class TestFieldCacheSort extends SolrTestCase {doc.add(newStringField("t", "1", Field.Store.NO));w.addDocument(doc);- IndexReader r =- UninvertingReader.wrap(DirectoryReader.open(w), Collections.singletonMap("f", Type.SORTED));+ IndexReader r = UninvertingReader.wrap(DirectoryReader.open(w), Map.of("f", Type.SORTED));w.close();IndexSearcher s = newSearcher(r);TopDocs hits =@@ -1731,8 +1667,7 @@ public class TestFieldCacheSort extends SolrTestCase {writer.close();Sort sort = new Sort(new SortField("string", SortField.Type.STRING), SortField.FIELD_DOC);IndexReader reader =- UninvertingReader.wrap(- DirectoryReader.open(indexStore), Collections.singletonMap("string", Type.SORTED));+ UninvertingReader.wrap(DirectoryReader.open(indexStore), Map.of("string", Type.SORTED));IndexSearcher searcher = new IndexSearcher(reader);expectThrows(IllegalStateException.class,@@ -1765,8 +1700,7 @@ public class TestFieldCacheSort extends SolrTestCase {}IndexReader r =- UninvertingReader.wrap(- DirectoryReader.open(w), Collections.singletonMap("id", Type.LEGACY_INTEGER));+ UninvertingReader.wrap(DirectoryReader.open(w), Map.of("id", Type.LEGACY_INTEGER));w.close();Query q = new TermQuery(new Term("body", "text"));TestUtil.checkReader(r);@@ -1815,8 +1749,7 @@ public class TestFieldCacheSort extends SolrTestCase {Document doc = new Document();doc.add(newStringField("value", "foo", Field.Store.YES));writer.addDocument(doc);- IndexReader ir =- UninvertingReader.wrap(writer.getReader(), Collections.singletonMap("value", Type.SORTED));+ IndexReader ir = UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.SORTED));writer.close();IndexSearcher searcher = newSearcher(ir);@@ -1837,8 +1770,7 @@ public class TestFieldCacheSort extends SolrTestCase {Document doc = new Document();doc.add(newStringField("value", "foo", Field.Store.YES));writer.addDocument(doc);- IndexReader ir =- UninvertingReader.wrap(writer.getReader(), Collections.singletonMap("value", Type.SORTED));+ IndexReader ir = UninvertingReader.wrap(writer.getReader(), Map.of("value", Type.SORTED));writer.close();IndexSearcher searcher = newSearcher(ir);diff --git a/solr/core/src/test/org/apache/solr/uninverting/TestUninvertingReader.java b/solr/core/src/test/org/apache/solr/uninverting/TestUninvertingReader.javaindex 1f45e10ff2a..9da8894ea37 100644--- a/solr/core/src/test/org/apache/solr/uninverting/TestUninvertingReader.java+++ b/solr/core/src/test/org/apache/solr/uninverting/TestUninvertingReader.java@@ -17,7 +17,6 @@package org.apache.solr.uninverting;import java.io.IOException;-import java.util.Collections;import java.util.EnumSet;import java.util.HashMap;import java.util.LinkedHashMap;@@ -78,8 +77,7 @@ public class TestUninvertingReader extends SolrTestCase {iw.close();DirectoryReader ir =- UninvertingReader.wrap(- DirectoryReader.open(dir), Collections.singletonMap("foo", Type.SORTED_SET_INTEGER));+ UninvertingReader.wrap(DirectoryReader.open(dir), Map.of("foo", Type.SORTED_SET_INTEGER));LeafReader ar = ir.leaves().get(0).reader();SortedSetDocValues v = ar.getSortedSetDocValues("foo");assertEquals(2, v.getValueCount());@@ -120,8 +118,7 @@ public class TestUninvertingReader extends SolrTestCase {iw.close();DirectoryReader ir =- UninvertingReader.wrap(- DirectoryReader.open(dir), Collections.singletonMap("foo", Type.SORTED_SET_FLOAT));+ UninvertingReader.wrap(DirectoryReader.open(dir), Map.of("foo", Type.SORTED_SET_FLOAT));LeafReader ar = ir.leaves().get(0).reader();SortedSetDocValues v = ar.getSortedSetDocValues("foo");@@ -163,8 +160,7 @@ public class TestUninvertingReader extends SolrTestCase {iw.close();DirectoryReader ir =- UninvertingReader.wrap(- DirectoryReader.open(dir), Collections.singletonMap("foo", Type.SORTED_SET_LONG));+ UninvertingReader.wrap(DirectoryReader.open(dir), Map.of("foo", Type.SORTED_SET_LONG));LeafReader ar = ir.leaves().get(0).reader();SortedSetDocValues v = ar.getSortedSetDocValues("foo");assertEquals(2, v.getValueCount());@@ -205,8 +201,7 @@ public class TestUninvertingReader extends SolrTestCase {iw.close();DirectoryReader ir =- UninvertingReader.wrap(- DirectoryReader.open(dir), Collections.singletonMap("foo", Type.SORTED_SET_DOUBLE));+ UninvertingReader.wrap(DirectoryReader.open(dir), Map.of("foo", Type.SORTED_SET_DOUBLE));LeafReader ar = ir.leaves().get(0).reader();SortedSetDocValues v = ar.getSortedSetDocValues("foo");assertEquals(2, v.getValueCount());diff --git a/solr/core/src/test/org/apache/solr/update/AddBlockUpdateTest.java b/solr/core/src/test/org/apache/solr/update/AddBlockUpdateTest.javaindex 963796a1b27..2612ab71e92 100644--- a/solr/core/src/test/org/apache/solr/update/AddBlockUpdateTest.java+++ b/solr/core/src/test/org/apache/solr/update/AddBlockUpdateTest.java@@ -32,6 +32,7 @@ import java.util.Collection;import java.util.Collections;import java.util.List;import java.util.Locale;+import java.util.Set;import java.util.concurrent.Callable;import java.util.concurrent.ExecutorService;import java.util.concurrent.Future;@@ -615,7 +616,7 @@ public class AddBlockUpdateTest extends SolrTestCaseJ4 {"child_s","b","grandChild",- Collections.singleton(sdoc("id", "7", "child_s", "d"))),+ Set.of(sdoc("id", "7", "child_s", "d"))),sdoc("id", "6", "child_s", "c"))).toString());}diff --git a/solr/core/src/test/org/apache/solr/update/DeleteByIdWithRouterFieldTest.java b/solr/core/src/test/org/apache/solr/update/DeleteByIdWithRouterFieldTest.javaindex cf5ead4b685..ff9ff482e53 100644--- a/solr/core/src/test/org/apache/solr/update/DeleteByIdWithRouterFieldTest.java+++ b/solr/core/src/test/org/apache/solr/update/DeleteByIdWithRouterFieldTest.java@@ -18,7 +18,6 @@package org.apache.solr.update;import java.util.ArrayList;-import java.util.Collections;import java.util.LinkedHashMap;import java.util.List;import java.util.Map;@@ -304,9 +303,7 @@ public class DeleteByIdWithRouterFieldTest extends SolrCloudTestCase {final Map<String, List<String>> urlMap =docCol.getActiveSlices().stream().collect(- Collectors.toMap(- s -> s.getName(),- s -> Collections.singletonList(fakeSolrUrlForShard(s.getName()))));+ Collectors.toMap(s -> s.getName(), s -> List.of(fakeSolrUrlForShard(s.getName()))));// simplified rote info we'll build up with the shards for each delete (after sanity checking// they have routing info at all)...diff --git a/solr/core/src/test/org/apache/solr/update/PeerSyncTest.java b/solr/core/src/test/org/apache/solr/update/PeerSyncTest.javaindex 0b7a3f3c2a0..ebb46d43e81 100644--- a/solr/core/src/test/org/apache/solr/update/PeerSyncTest.java+++ b/solr/core/src/test/org/apache/solr/update/PeerSyncTest.java@@ -22,7 +22,6 @@ import static org.hamcrest.core.StringContains.containsString;import java.io.IOException;import java.util.ArrayList;import java.util.Arrays;-import java.util.Collections;import java.util.LinkedHashSet;import java.util.LinkedList;import java.util.List;@@ -457,7 +456,7 @@ public class PeerSyncTest extends BaseDistributedSearchTestCase {// no other, solitary usfor (boolean completeList : new boolean[] {false, true}) {List<Long> otherVersions = List.of();- List<Long> ourUpdates = Collections.singletonList(42L);+ List<Long> ourUpdates = List.of(42L);assertEquals(1, ourUpdates.size());long ourLowThreshold = ourUpdates.get(0);MissedUpdatesRequest mur =@@ -471,8 +470,8 @@ public class PeerSyncTest extends BaseDistributedSearchTestCase {private static void testHandleVersionsWithRangesSameOne() {for (boolean completeList : new boolean[] {false, true}) {- List<Long> otherVersions = Collections.singletonList(42L);- List<Long> ourUpdates = Collections.singletonList(42L);+ List<Long> otherVersions = List.of(42L);+ List<Long> ourUpdates = List.of(42L);assertEquals(1, ourUpdates.size());long ourLowThreshold = ourUpdates.get(0);MissedUpdatesRequest mur =diff --git a/solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.java b/solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.javaindex a237ac49c97..59f28f3409e 100644--- a/solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.java+++ b/solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.java@@ -21,7 +21,6 @@ import java.io.IOException;import java.net.SocketException;import java.nio.file.Path;import java.util.ArrayList;-import java.util.Collections;import java.util.List;import java.util.concurrent.CountDownLatch;import java.util.concurrent.atomic.AtomicBoolean;@@ -213,7 +212,7 @@ public class SolrCmdDistributorTest extends BaseDistributedSearchTestCase {params = new ModifiableSolrParams();params.set(DistributedUpdateProcessor.COMMIT_END_POINT, true);- cmdDistrib.distribAdd(cmd3, Collections.singletonList(nodes.get(1)), params);+ cmdDistrib.distribAdd(cmd3, List.of(nodes.get(1)), params);params = new ModifiableSolrParams();params.set(DistributedUpdateProcessor.COMMIT_END_POINT, true);diff --git a/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesDistrib.java b/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesDistrib.javaindex 011bad9e556..084f94aa964 100644--- a/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesDistrib.java+++ b/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesDistrib.java@@ -1223,7 +1223,7 @@ public class TestInPlaceUpdatesDistrib extends AbstractFullDistribZkTestBase {commit();float inplace_updatable_float = 1F;- buildRandomIndex(inplace_updatable_float, Collections.singletonList(1));+ buildRandomIndex(inplace_updatable_float, List.of(1));float newinplace_updatable_float = 100F;List<UpdateRequest> updates = new ArrayList<>();@@ -1631,7 +1631,7 @@ public class TestInPlaceUpdatesDistrib extends AbstractFullDistribZkTestBase {commit();float inplace_updatable_float = 1F;- buildRandomIndex(inplace_updatable_float, Collections.singletonList(1));+ buildRandomIndex(inplace_updatable_float, List.of(1));List<UpdateRequest> updates = new ArrayList<>();updates.add(diff --git a/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesStandalone.java b/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesStandalone.javaindex 42d3d41c121..a589eafdf4c 100644--- a/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesStandalone.java+++ b/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesStandalone.java@@ -167,7 +167,7 @@ public class TestInPlaceUpdatesStandalone extends SolrTestCaseJ4 {"id","1","inplace_updatable_float",- map("inc", new ArrayList<>(Collections.singletonList(123)))));+ map("inc", new ArrayList<>(List.of(123)))));assertEquals(SolrException.ErrorCode.BAD_REQUEST.code, e.code());assertThat(e.getMessage(), containsString("Invalid input '[123]' for field inplace_updatable_float"));diff --git a/solr/core/src/test/org/apache/solr/update/processor/AddSchemaFieldsUpdateProcessorFactoryTest.java b/solr/core/src/test/org/apache/solr/update/processor/AddSchemaFieldsUpdateProcessorFactoryTest.javaindex ef470d5e3fc..c556070e2bf 100644--- a/solr/core/src/test/org/apache/solr/update/processor/AddSchemaFieldsUpdateProcessorFactoryTest.java+++ b/solr/core/src/test/org/apache/solr/update/processor/AddSchemaFieldsUpdateProcessorFactoryTest.java@@ -22,9 +22,9 @@ import java.time.Instant;import java.time.LocalDateTime;import java.time.ZoneOffset;import java.time.format.DateTimeFormatter;-import java.util.Collections;import java.util.Date;import java.util.Locale;+import java.util.Set;import org.apache.commons.io.file.PathUtils;import org.apache.lucene.tests.mockfile.FilterPath;import org.apache.solr.common.SolrInputDocument;@@ -134,8 +134,7 @@ public class AddSchemaFieldsUpdateProcessorFactoryTest extends UpdateProcessorTeschema = h.getCore().getLatestSchema();assertNotNull(schema.getFieldOrNull(fieldName));assertEquals("text", schema.getFieldType(fieldName).getTypeName());- assertEquals(- 0, schema.getCopyFieldProperties(true, Collections.singleton(fieldName), null).size());+ assertEquals(0, schema.getCopyFieldProperties(true, Set.of(fieldName), null).size());assertU(commit());assertQ(req("id:4"),@@ -159,8 +158,7 @@ public class AddSchemaFieldsUpdateProcessorFactoryTest extends UpdateProcessorTeschema = h.getCore().getLatestSchema();assertNotNull(schema.getFieldOrNull(fieldName));assertEquals("text", schema.getFieldType(fieldName).getTypeName());- assertEquals(- 1, schema.getCopyFieldProperties(true, Collections.singleton(fieldName), null).size());+ assertEquals(1, schema.getCopyFieldProperties(true, Set.of(fieldName), null).size());assertU(commit());assertQ(req("id:4"),@@ -278,11 +276,7 @@ public class AddSchemaFieldsUpdateProcessorFactoryTest extends UpdateProcessorTeassertNotNull(schema.getFieldOrNull(strFieldName));assertEquals("text", schema.getFieldType(fieldName).getTypeName());assertEquals(- 1,- schema- .getCopyFieldProperties(- true, Collections.singleton(fieldName), Collections.singleton(strFieldName))- .size());+ 1, schema.getCopyFieldProperties(true, Set.of(fieldName), Set.of(strFieldName)).size());}public void testStringWithCopyFieldAndMaxChars() throws Exception {@@ -301,30 +295,26 @@ public class AddSchemaFieldsUpdateProcessorFactoryTest extends UpdateProcessorTeassertNotNull(schema.getFieldOrNull(strFieldName));assertEquals("text", schema.getFieldType(fieldName).getTypeName());// We have three copyFields, one with maxChars 10 and two with maxChars 20- assertEquals(- 3, schema.getCopyFieldProperties(true, Collections.singleton(fieldName), null).size());+ assertEquals(3, schema.getCopyFieldProperties(true, Set.of(fieldName), null).size());assertEquals("The configured maxChars cutoff does not exist on the copyField",10,schema- .getCopyFieldProperties(- true, Collections.singleton(fieldName), Collections.singleton(strFieldName))+ .getCopyFieldProperties(true, Set.of(fieldName), Set.of(strFieldName)).get(0).get("maxChars"));assertEquals("The configured maxChars cutoff does not exist on the copyField",20,schema- .getCopyFieldProperties(- true, Collections.singleton(fieldName), Collections.singleton(fieldName + "_t"))+ .getCopyFieldProperties(true, Set.of(fieldName), Set.of(fieldName + "_t")).get(0).get("maxChars"));assertEquals("The configured maxChars cutoff does not exist on the copyField",20,schema- .getCopyFieldProperties(- true, Collections.singleton(fieldName), Collections.singleton(fieldName + "2_t"))+ .getCopyFieldProperties(true, Set.of(fieldName), Set.of(fieldName + "2_t")).get(0).get("maxChars"));}diff --git a/solr/core/src/test/org/apache/solr/update/processor/NestedAtomicUpdateTest.java b/solr/core/src/test/org/apache/solr/update/processor/NestedAtomicUpdateTest.javaindex 01852b9d8fd..ec4f00775c2 100644--- a/solr/core/src/test/org/apache/solr/update/processor/NestedAtomicUpdateTest.java+++ b/solr/core/src/test/org/apache/solr/update/processor/NestedAtomicUpdateTest.java@@ -27,6 +27,7 @@ import java.util.Collections;import java.util.Iterator;import java.util.List;import java.util.Map;+import java.util.Set;import java.util.stream.Collectors;import java.util.stream.IntStream;import org.apache.lucene.util.BytesRef;@@ -34,6 +35,7 @@ import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.common.SolrException;import org.apache.solr.common.SolrInputDocument;import org.apache.solr.common.SolrInputField;+import org.apache.solr.common.util.SuppressForbidden;import org.apache.solr.core.SolrCore;import org.apache.solr.handler.component.RealTimeGetComponent;import org.apache.solr.util.RandomNoReverseMergePolicyFactory;@@ -65,13 +67,7 @@ public class NestedAtomicUpdateTest extends SolrTestCaseJ4 {public void testMergeChildDoc() {SolrInputDocument newChildDoc = sdoc("id", "3", "cat_ss", "child");SolrInputDocument addedDoc =- sdoc(- "id",- "1",- "cat_ss",- Collections.singletonMap("add", "bbb"),- "child",- Collections.singletonMap("add", sdocs(newChildDoc)));+ sdoc("id", "1", "cat_ss", Map.of("add", "bbb"), "child", Map.of("add", sdocs(newChildDoc)));SolrInputDocument dummyBlock =sdoc(@@ -95,9 +91,7 @@ public class NestedAtomicUpdateTest extends SolrTestCaseJ4 {assertDocContainsSubset(preMergeDoc, dummyBlock);assertDocContainsSubset(addedDoc, dummyBlock);final List<SolrInputDocument> children =- dummyBlock.getFieldValues("child").stream()- .map(SolrInputDocument.class::cast)- .collect(Collectors.toList());+ dummyBlock.getFieldValues("child").stream().map(SolrInputDocument.class::cast).toList();assertDocContainsSubset(newChildDoc, children.get(1));assertEquals(dummyBlock.getFieldValue("id"), dummyBlock.getFieldValue("id"));}@@ -122,10 +116,9 @@ public class NestedAtomicUpdateTest extends SolrTestCaseJ4 {"id","1","cat_ss",- Collections.singletonMap("add", "bbb"), // add value to collection on parent+ Map.of("add", "bbb"), // add value to collection on parent"child",- Collections.singletonMap(- "add", sdocs(updatedChildDoc))); // child with same id and updated "cat_ss" field+ Map.of("add", sdocs(updatedChildDoc))); // child with same id and updated "cat_ss" fieldSolrInputDocument preMergeDoc = new SolrInputDocument(existingDoc);AtomicUpdateDocumentMerger docMerger = new AtomicUpdateDocumentMerger(req());@@ -155,16 +148,15 @@ public class NestedAtomicUpdateTest extends SolrTestCaseJ4 {"child",new ArrayList<>(sdocs(existingChild)));- SolrInputDocument updatedChildDoc =- sdoc("id", "2", "cat_ss", Collections.singletonMap("set", "updated child"));+ SolrInputDocument updatedChildDoc = sdoc("id", "2", "cat_ss", Map.of("set", "updated child"));SolrInputDocument updateDoc =sdoc("id","1","cat_ss",- Collections.singletonMap("add", "bbb"), // add value to collection on parent+ Map.of("add", "bbb"), // add value to collection on parent"child",- Collections.singletonMap(+ Map.of("add",sdocs(updatedChildDoc))); // child with same id and nested set on "cat_ss" field@@ -204,10 +196,9 @@ public class NestedAtomicUpdateTest extends SolrTestCaseJ4 {"id","1","cat_ss",- Collections.singletonMap("add", "bbb"), // add value to collection on parent+ Map.of("add", "bbb"), // add value to collection on parent"child",- Collections.singletonMap(- "add", sdocs(updatedChildDoc))); // child with same id and updated "cat_ss" field+ Map.of("add", sdocs(updatedChildDoc))); // child with same id and updated "cat_ss" fieldSolrInputDocument preMergeDoc = new SolrInputDocument(existingDoc);AtomicUpdateDocumentMerger docMerger = new AtomicUpdateDocumentMerger(req());@@ -242,8 +233,7 @@ public class NestedAtomicUpdateTest extends SolrTestCaseJ4 {"id","1","child_ss",- Collections.singletonMap(- "add", sdoc("id", "3", "cat_ss", Map.of("set", "child2")))); // an atomic update+ Map.of("add", sdoc("id", "3", "cat_ss", Map.of("set", "child2")))); // an atomic updateAtomicUpdateDocumentMerger docMerger = new AtomicUpdateDocumentMerger(req());@@ -274,7 +264,7 @@ public class NestedAtomicUpdateTest extends SolrTestCaseJ4 {sdoc("id", String.valueOf(x), "string_s", "child", "inplace_updatable_int", "0")).collect(Collectors.toList());- doc = sdoc("id", "1", "_root_", "1", "children", Collections.singletonMap("add", docs));+ doc = sdoc("id", "1", "_root_", "1", "children", Map.of("add", docs));addAndGetVersion(doc, null);assertU(commit());@@ -288,26 +278,14 @@ public class NestedAtomicUpdateTest extends SolrTestCaseJ4 {for (int i = 10; i < 20; ++i) {doc =- sdoc(- "id",- String.valueOf(i),- "_root_",- "1",- "inplace_updatable_int",- Collections.singletonMap("inc", "1"));+ sdoc("id", String.valueOf(i), "_root_", "1", "inplace_updatable_int", Map.of("inc", "1"));addAndGetVersion(doc, null);assertU(commit());}for (int i = 10; i < 20; ++i) {doc =- sdoc(- "id",- String.valueOf(i),- "_root_",- "1",- "inplace_updatable_int",- Collections.singletonMap("inc", "1"));+ sdoc("id", String.valueOf(i), "_root_", "1", "inplace_updatable_int", Map.of("inc", "1"));addAndGetVersion(doc, null);assertU(commit());}@@ -317,28 +295,15 @@ public class NestedAtomicUpdateTest extends SolrTestCaseJ4 {docs =IntStream.range(i * 10, (i * 10) + 5).mapToObj(x -> sdoc("id", String.valueOf(x), "string_s", "grandChild"))- .collect(Collectors.toList());- doc =- sdoc(- "id",- String.valueOf(i),- "_root_",- "1",- "grandChildren",- Collections.singletonMap("add", docs));+ .toList();+ doc = sdoc("id", String.valueOf(i), "_root_", "1", "grandChildren", Map.of("add", docs));addAndGetVersion(doc, null);assertU(commit());}for (int i = 10; i < 20; ++i) {doc =- sdoc(- "id",- String.valueOf(i),- "_root_",- "1",- "inplace_updatable_int",- Collections.singletonMap("inc", "1"));+ sdoc("id", String.valueOf(i), "_root_", "1", "inplace_updatable_int", Map.of("inc", "1"));addAndGetVersion(doc, null);assertU(commit());}@@ -375,7 +340,7 @@ public class NestedAtomicUpdateTest extends SolrTestCaseJ4 {IntStream.range(10, 20).mapToObj(x -> sdoc("id", String.valueOf(x), "string_s", "child")).collect(Collectors.toList());- doc = sdoc("id", "1", "children", Collections.singletonMap("add", docs));+ doc = sdoc("id", "1", "children", Map.of("add", docs));addAndGetVersion(doc, null);assertU(commit());@@ -392,15 +357,8 @@ public class NestedAtomicUpdateTest extends SolrTestCaseJ4 {docs =IntStream.range(i * 10, (i * 10) + 5).mapToObj(x -> sdoc("id", String.valueOf(x), "string_s", "grandChild"))- .collect(Collectors.toList());- doc =- sdoc(- "id",- String.valueOf(i),- "_root_",- "1",- "grandChildren",- Collections.singletonMap("add", docs));+ .toList();+ doc = sdoc("id", String.valueOf(i), "_root_", "1", "grandChildren", Map.of("add", docs));addAndGetVersion(doc, null);assertU(commit());}@@ -429,12 +387,7 @@ public class NestedAtomicUpdateTest extends SolrTestCaseJ4 {"/response/docs/[0]/child1/[0]/id=='2'","/response/docs/[0]/child1/[0]/child_s=='child'");- doc =- sdoc(- "id",- "1",- "child1",- Collections.singletonMap("add", sdocs(sdoc("id", "3", "child_s", "child"))));+ doc = sdoc("id", "1", "child1", Map.of("add", sdocs(sdoc("id", "3", "child_s", "child"))));addAndGetVersion(doc, null);assertU(commit());@@ -454,7 +407,7 @@ public class NestedAtomicUpdateTest extends SolrTestCaseJ4 {"_root_","1","grandChild",- Collections.singletonMap(+ Map.of("add",sdocs(sdoc("id", "4", "child_s", "grandChild"),@@ -474,12 +427,7 @@ public class NestedAtomicUpdateTest extends SolrTestCaseJ4 {"/response/docs/[0]/child1/[0]/grandChild/[0]/id=='4'","/response/docs/[0]/child1/[0]/grandChild/[0]/child_s=='grandChild'");- doc =- sdoc(- "id",- "1",- "child2",- Collections.singletonMap("add", sdocs(sdoc("id", "8", "child_s", "child"))));+ doc = sdoc("id", "1", "child2", Map.of("add", sdocs(sdoc("id", "8", "child_s", "child"))));addAndGetVersion(doc, null);assertU(commit());@@ -497,7 +445,7 @@ public class NestedAtomicUpdateTest extends SolrTestCaseJ4 {"/response/docs/[0]/child2/[0]/id=='8'","/response/docs/[0]/child2/[0]/child_s=='child'");- doc = sdoc("id", "1", "new_s", Collections.singletonMap("add", "new string"));+ doc = sdoc("id", "1", "new_s", Map.of("add", "new string"));addAndGetVersion(doc, null);assertU(commit());@@ -554,9 +502,9 @@ public class NestedAtomicUpdateTest extends SolrTestCaseJ4 {"id","1","cat_ss",- Collections.singletonMap("add", "bbb"),+ Map.of("add", "bbb"),"child2",- Collections.singletonMap("add", sdoc("id", "3", "cat_ss", "child")));+ Map.of("add", sdoc("id", "3", "cat_ss", "child")));addAndGetVersion(doc, null);assertJQ(@@ -586,7 +534,7 @@ public class NestedAtomicUpdateTest extends SolrTestCaseJ4 {"_root_","1","child3",- Collections.singletonMap("add", sdoc("id", "4", "cat_ss", "grandChild")));+ Map.of("add", sdoc("id", "4", "cat_ss", "grandChild")));addAndGetVersion(doc, null);assertJQ(@@ -611,7 +559,7 @@ public class NestedAtomicUpdateTest extends SolrTestCaseJ4 {"_root_","1","child4",- Collections.singletonMap("add", sdoc("id", "5", "cat_ss", "greatGrandChild")));+ Map.of("add", sdoc("id", "5", "cat_ss", "greatGrandChild")));addAndGetVersion(doc, null);assertJQ(@@ -636,7 +584,7 @@ public class NestedAtomicUpdateTest extends SolrTestCaseJ4 {"_root_","1","child4",- Collections.singletonMap("add", sdoc("id", "6", "cat_ss", "greatGrandChild")));+ Map.of("add", sdoc("id", "6", "cat_ss", "greatGrandChild")));addAndGetVersion(doc, null);assertU(commit());@@ -653,14 +601,14 @@ public class NestedAtomicUpdateTest extends SolrTestCaseJ4 {"id","1","child5",- Collections.singletonMap(+ Map.of("add",sdocs(sdoc("id", "7", "cat_ss", "child"), sdoc("id", "8", "cat_ss", "child"))));addAndGetVersion(doc, null);assertU(commit());- doc = sdoc("id", "1", "new_s", Collections.singletonMap("add", "new string"));+ doc = sdoc("id", "1", "new_s", Map.of("add", "new string"));addAndGetVersion(doc, null);assertU(commit());@@ -694,13 +642,7 @@ public class NestedAtomicUpdateTest extends SolrTestCaseJ4 {public void testBlockAtomicSet() throws Exception {SolrInputDocument sdoc2 = sdoc("id", "2", "cat_ss", "child");SolrInputDocument doc =- sdoc(- "id",- "1",- "cat_ss",- new String[] {"aaa", "ccc"},- "child1",- Collections.singleton(sdoc2));+ sdoc("id", "1", "cat_ss", new String[] {"aaa", "ccc"}, "child1", Set.of(sdoc2));assertU(adoc(doc));BytesRef rootDocId = new BytesRef("1");@@ -746,9 +688,9 @@ public class NestedAtomicUpdateTest extends SolrTestCaseJ4 {"_root_","1","cat_ss",- Collections.singletonMap("set", Arrays.asList("aaa", "bbb")),+ Map.of("set", Arrays.asList("aaa", "bbb")),"child1",- Collections.singletonMap("set", sdoc("id", "3", "cat_ss", "child")));+ Map.of("set", sdoc("id", "3", "cat_ss", "child")));addAndGetVersion(doc, null);assertJQ(@@ -769,13 +711,7 @@ public class NestedAtomicUpdateTest extends SolrTestCaseJ4 {+ " }}");doc =- sdoc(- "id",- "3",- "_root_",- "1",- "child2",- Collections.singletonMap("set", sdoc("id", "4", "cat_ss", "child")));+ sdoc("id", "3", "_root_", "1", "child2", Map.of("set", sdoc("id", "4", "cat_ss", "child")));addAndGetVersion(doc, null);assertJQ(@@ -821,12 +757,7 @@ public class NestedAtomicUpdateTest extends SolrTestCaseJ4 {"/response/docs/[0]/cat_ss/[0]==\"aaa\"","/response/docs/[0]/cat_ss/[1]==\"bbb\"");- doc =- sdoc(- "id",- "1",- "child1",- Collections.singletonMap("add", sdoc("id", "2", "cat_ss", "child")));+ doc = sdoc("id", "1", "child1", Map.of("add", sdoc("id", "2", "cat_ss", "child")));addAndGetVersion(doc, null);// commit the changes@@ -893,12 +824,7 @@ public class NestedAtomicUpdateTest extends SolrTestCaseJ4 {+ ", cat_ss:[\"aaa\",\"ccc\"], child1:[{\"id\":\"2\",\"cat_ss\":[\"child\"]}, {\"id\":\"3\",\"cat_ss\":[\"child\"]}]"+ " }}");- doc =- sdoc(- "id",- "1",- "child1",- Collections.singletonMap("remove", sdoc("id", "3", "cat_ss", "child")));+ doc = sdoc("id", "1", "child1", Map.of("remove", sdoc("id", "3", "cat_ss", "child")));addAndGetVersion(doc, null);assertJQ(@@ -939,6 +865,7 @@ public class NestedAtomicUpdateTest extends SolrTestCaseJ4 {testBlockAtomicSetToNullOrEmpty(true);}+ @SuppressForbidden(reason = "singletonMap with null value is intentional")private void testBlockAtomicSetToNullOrEmpty(boolean empty) throws Exception {// latlon field is included to ensure reading from LatLonDocValuesField is working due to atomic// update. See SOLR-13966 for further details.@@ -1027,9 +954,7 @@ public class NestedAtomicUpdateTest extends SolrTestCaseJ4 {expectThrows(SolrException.class,() -> {- addAndGetVersion(- sdoc("id", "2", "grandchild", Collections.singletonMap("set", sdoc("id", "3"))),- null);+ addAndGetVersion(sdoc("id", "2", "grandchild", Map.of("set", sdoc("id", "3"))), null);});assertTrue(e.toString(),diff --git a/solr/core/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java b/solr/core/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.javaindex a492d60be4e..05487931e06 100644--- a/solr/core/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java+++ b/solr/core/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java@@ -17,8 +17,8 @@package org.apache.solr.update.processor;import java.util.ArrayList;-import java.util.Collections;import java.util.HashMap;+import java.util.List;import java.util.Map;import org.apache.lucene.util.Constants;import org.apache.solr.SolrTestCaseJ4;@@ -294,8 +294,7 @@ public class SignatureUpdateProcessorFactoryTest extends SolrTestCaseJ4 {SolrQueryRequestBase req = new SolrQueryRequestBase(h.getCore(), mmparams);try {- req.setContentStreams(- Collections.singletonList(ContentStreamBase.create(new JavaBinRequestWriter(), ureq)));+ req.setContentStreams(List.of(ContentStreamBase.create(new JavaBinRequestWriter(), ureq)));UpdateRequestHandler h = new UpdateRequestHandler();h.init(new NamedList<>());h.handleRequestBody(req, new SolrQueryResponse());diff --git a/solr/core/src/test/org/apache/solr/update/processor/TimeRoutedAliasUpdateProcessorTest.java b/solr/core/src/test/org/apache/solr/update/processor/TimeRoutedAliasUpdateProcessorTest.javaindex d9028e99578..b0d0097b6d3 100644--- a/solr/core/src/test/org/apache/solr/update/processor/TimeRoutedAliasUpdateProcessorTest.java+++ b/solr/core/src/test/org/apache/solr/update/processor/TimeRoutedAliasUpdateProcessorTest.java@@ -488,7 +488,7 @@ public class TimeRoutedAliasUpdateProcessorTest extends RoutedAliasUpdateProcessassertUpdateResponse(add(alias,- Collections.singletonList(+ List.of(sdoc("id","8",@@ -579,8 +579,7 @@ public class TimeRoutedAliasUpdateProcessorTest extends RoutedAliasUpdateProcessassertUpdateResponse(add(alias,- Collections.singletonList(- sdoc("id", "13", "timestamp_dt", "2017-10-30T23:03:00Z")), // lucky?+ List.of(sdoc("id", "13", "timestamp_dt", "2017-10-30T23:03:00Z")), // lucky?params));assertUpdateResponse(solrClient.commit(alias));waitColAndAlias(alias, TRA, "2017-10-30", numShards);@@ -619,7 +618,7 @@ public class TimeRoutedAliasUpdateProcessorTest extends RoutedAliasUpdateProcessassertUpdateResponse(add(alias,- Collections.singletonList(+ List.of(sdoc("id","14",@@ -631,7 +630,7 @@ public class TimeRoutedAliasUpdateProcessorTest extends RoutedAliasUpdateProcessassertUpdateResponse(add(alias,- Collections.singletonList(+ List.of(sdoc("id","15",@@ -643,7 +642,7 @@ public class TimeRoutedAliasUpdateProcessorTest extends RoutedAliasUpdateProcessassertUpdateResponse(add(alias,- Collections.singletonList(+ List.of(sdoc("id","16",@@ -655,7 +654,7 @@ public class TimeRoutedAliasUpdateProcessorTest extends RoutedAliasUpdateProcessassertUpdateResponse(add(alias,- Collections.singletonList(+ List.of(sdoc("id","17",@@ -670,7 +669,7 @@ public class TimeRoutedAliasUpdateProcessorTest extends RoutedAliasUpdateProcessassertUpdateResponse(add(alias,- Collections.singletonList(+ List.of(sdoc("id","18",@@ -724,7 +723,7 @@ public class TimeRoutedAliasUpdateProcessorTest extends RoutedAliasUpdateProcessassertUpdateResponse(add(alias,- Collections.singletonList(+ List.of(sdoc("id","6",diff --git a/solr/core/src/test/org/apache/solr/util/SolrPluginUtilsTest.java b/solr/core/src/test/org/apache/solr/util/SolrPluginUtilsTest.javaindex 97b80a7cd45..819585acc22 100644--- a/solr/core/src/test/org/apache/solr/util/SolrPluginUtilsTest.java+++ b/solr/core/src/test/org/apache/solr/util/SolrPluginUtilsTest.java@@ -18,11 +18,11 @@ package org.apache.solr.util;import java.util.ArrayList;import java.util.Arrays;-import java.util.Collections;import java.util.HashMap;import java.util.Iterator;import java.util.List;import java.util.Map;+import java.util.Set;import org.apache.lucene.index.Term;import org.apache.lucene.search.BooleanClause;import org.apache.lucene.search.BooleanClause.Occur;@@ -377,9 +377,7 @@ public class SolrPluginUtilsTest extends SolrTestCaseJ4 {/* Simulate stopwords through uneven disjuncts */q = new BooleanQuery.Builder();- q.add(- new DisjunctionMaxQuery(Collections.singleton(new TermQuery(new Term("a", "foo"))), 0.0f),- Occur.SHOULD);+ q.add(new DisjunctionMaxQuery(Set.of(new TermQuery(new Term("a", "foo"))), 0.0f), Occur.SHOULD);DisjunctionMaxQuery dmq =new DisjunctionMaxQuery(Arrays.asList(new TermQuery(new Term("a", "foo")), new TermQuery(new Term("b", "foo"))),diff --git a/solr/core/src/test/org/apache/solr/util/TestUtils.java b/solr/core/src/test/org/apache/solr/util/TestUtils.javaindex 3e18f8e766c..1228ff0c8bd 100644--- a/solr/core/src/test/org/apache/solr/util/TestUtils.java+++ b/solr/core/src/test/org/apache/solr/util/TestUtils.java@@ -27,11 +27,11 @@ import static org.apache.solr.common.util.Utils.fromJSONString;import java.io.ByteArrayOutputStream;import java.io.IOException;import java.io.StringReader;-import java.util.Collections;import java.util.HashMap;import java.util.Iterator;import java.util.List;import java.util.Map;+import java.util.Set;import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.common.MapWriter;import org.apache.solr.common.util.CommandOperation;@@ -138,8 +138,7 @@ public class TestUtils extends SolrTestCaseJ4 {ContentStream stream =new ContentStreamBase.ByteArrayStream(baos.toByteArray(), null, "application/javabin");List<CommandOperation> commands =- CommandOperation.readCommands(- Collections.singletonList(stream), new NamedList<>(), Collections.singleton("single"));+ CommandOperation.readCommands(List.of(stream), new NamedList<>(), Set.of("single"));assertEquals(5, commands.size());}diff --git a/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/consumer/KafkaCrossDcConsumer.java b/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/consumer/KafkaCrossDcConsumer.javaindex 5e1af44d35c..c3b5bdb3a70 100644--- a/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/consumer/KafkaCrossDcConsumer.java+++ b/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/consumer/KafkaCrossDcConsumer.java@@ -20,7 +20,6 @@ import java.lang.invoke.MethodHandles;import java.time.Duration;import java.util.Arrays;import java.util.Collection;-import java.util.Collections;import java.util.List;import java.util.Optional;import java.util.Properties;@@ -126,9 +125,7 @@ public class KafkaCrossDcConsumer extends Consumer.CrossDcConsumer {protected CloudSolrClient createSolrClient() {log.debug("Creating new SolrClient...");- return new CloudSolrClient.Builder(- Collections.singletonList(zkConnectString), Optional.empty())- .build();+ return new CloudSolrClient.Builder(List.of(zkConnectString), Optional.empty()).build();}@Overridediff --git a/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/consumer/PartitionManager.java b/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/consumer/PartitionManager.javaindex 1d16b6cca58..c1004528ab6 100644--- a/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/consumer/PartitionManager.java+++ b/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/consumer/PartitionManager.java@@ -18,9 +18,9 @@ package org.apache.solr.crossdc.manager.consumer;import java.lang.invoke.MethodHandles;import java.util.ArrayDeque;-import java.util.Collections;import java.util.HashSet;import java.util.List;+import java.util.Map;import java.util.Queue;import java.util.Set;import java.util.concurrent.ConcurrentHashMap;@@ -146,7 +146,7 @@ public class PartitionManager {nextOffset);}- consumer.commitSync(Collections.singletonMap(partition, new OffsetAndMetadata(nextOffset)));+ consumer.commitSync(Map.of(partition, new OffsetAndMetadata(nextOffset)));}static long getOffsetForPartition(diff --git a/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/consumer/KafkaCrossDcConsumerTest.java b/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/consumer/KafkaCrossDcConsumerTest.javaindex b576f074b32..fcbd2edd84d 100644--- a/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/consumer/KafkaCrossDcConsumerTest.java+++ b/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/consumer/KafkaCrossDcConsumerTest.java@@ -35,7 +35,6 @@ import static org.mockito.Mockito.verify;import static org.mockito.Mockito.when;import java.util.ArrayList;-import java.util.Collections;import java.util.HashMap;import java.util.List;import java.util.Map;@@ -161,7 +160,7 @@ public class KafkaCrossDcConsumerTest {List<ConsumerRecord<String, MirroredSolrRequest<?>>> recordsList = new ArrayList<>();recordsList.add(new ConsumerRecord<>("sample-topic", 0, 0, "key", createSampleMirroredSolrRequest()));- return new ConsumerRecords<>(Collections.singletonMap(topicPartition, recordsList));+ return new ConsumerRecords<>(Map.of(topicPartition, recordsList));}private MirroredSolrRequest<?> createSampleMirroredSolrRequest() {@@ -309,8 +308,7 @@ public class KafkaCrossDcConsumerTest {ConsumerRecord<String, MirroredSolrRequest<?>> record =new ConsumerRecord<>("test-topic", 0, 0, "key", new MirroredSolrRequest<>(validRequest));ConsumerRecords<String, MirroredSolrRequest<?>> records =- new ConsumerRecords<>(- Collections.singletonMap(new TopicPartition("test-topic", 0), List.of(record)));+ new ConsumerRecords<>(Map.of(new TopicPartition("test-topic", 0), List.of(record)));when(mockConsumer.poll(any())).thenReturn(records).thenThrow(new WakeupException());@@ -358,8 +356,7 @@ public class KafkaCrossDcConsumerTest {new MirroredSolrRequest<>(MirroredSolrRequest.Type.UPDATE, new UpdateRequest()));ConsumerRecords<String, MirroredSolrRequest<?>> records =new ConsumerRecords<>(- Collections.singletonMap(- new TopicPartition("test-topic", 0), List.of(record1, record2)));+ Map.of(new TopicPartition("test-topic", 0), List.of(record1, record2)));when(mockConsumer.poll(any())).thenReturn(records).thenThrow(new WakeupException());@@ -436,8 +433,7 @@ public class KafkaCrossDcConsumerTest {records.add(record);}ConsumerRecords<String, MirroredSolrRequest<?>> consumerRecords =- new ConsumerRecords<>(- Collections.singletonMap(new TopicPartition("test-topic", 0), records));+ new ConsumerRecords<>(Map.of(new TopicPartition("test-topic", 0), records));when(mockConsumer.poll(any())).thenReturn(consumerRecords).thenThrow(new WakeupException());@@ -483,8 +479,7 @@ public class KafkaCrossDcConsumerTest {ConsumerRecord<String, MirroredSolrRequest<?>> record =new ConsumerRecord<>("test-topic", 0, 0, "key", new MirroredSolrRequest<>(invalidRequest));ConsumerRecords<String, MirroredSolrRequest<?>> records =- new ConsumerRecords<>(- Collections.singletonMap(new TopicPartition("test-topic", 0), List.of(record)));+ new ConsumerRecords<>(Map.of(new TopicPartition("test-topic", 0), List.of(record)));when(mockConsumer.poll(any())).thenReturn(records).thenThrow(new WakeupException());diff --git a/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/consumer/PartitionManagerTest.java b/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/consumer/PartitionManagerTest.javaindex 3f3cbcb6f68..91902f5f896 100644--- a/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/consumer/PartitionManagerTest.java+++ b/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/consumer/PartitionManagerTest.java@@ -25,7 +25,7 @@ import static org.mockito.Mockito.times;import static org.mockito.Mockito.verify;import static org.mockito.Mockito.when;-import java.util.Collections;+import java.util.Map;import java.util.concurrent.ExecutorService;import java.util.concurrent.Future;import java.util.concurrent.TimeUnit;@@ -125,8 +125,7 @@ public class PartitionManagerTest {// Verify that the consumer.commitSync() method was called with the correct parametersverify(consumer, times(1))- .commitSync(- Collections.singletonMap(partition, new OffsetAndMetadata(workUnit.nextOffset)));+ .commitSync(Map.of(partition, new OffsetAndMetadata(workUnit.nextOffset)));// Verify that the partitionQueue is empty after processingassertTrue(partitionWork.partitionQueue.isEmpty());@@ -178,10 +177,8 @@ public class PartitionManagerTest {// Verify that the updateOffset method was called for each partitionverify(mockConsumer, times(1))- .commitSync(- Collections.singletonMap(partition1, new OffsetAndMetadata(workUnit1.nextOffset)));+ .commitSync(Map.of(partition1, new OffsetAndMetadata(workUnit1.nextOffset)));verify(mockConsumer, times(1))- .commitSync(- Collections.singletonMap(partition2, new OffsetAndMetadata(workUnit2.nextOffset)));+ .commitSync(Map.of(partition2, new OffsetAndMetadata(workUnit2.nextOffset)));}}diff --git a/solr/modules/analysis-extras/src/java/org/apache/solr/schema/ICUCollationField.java b/solr/modules/analysis-extras/src/java/org/apache/solr/schema/ICUCollationField.javaindex 9d72b88ee38..277bbfc214a 100644--- a/solr/modules/analysis-extras/src/java/org/apache/solr/schema/ICUCollationField.java+++ b/solr/modules/analysis-extras/src/java/org/apache/solr/schema/ICUCollationField.java@@ -25,7 +25,6 @@ import java.io.IOException;import java.io.InputStream;import java.nio.charset.StandardCharsets;import java.util.ArrayList;-import java.util.Collections;import java.util.List;import java.util.Map;import org.apache.lucene.analysis.Analyzer;@@ -333,7 +332,7 @@ public class ICUCollationField extends FieldType {}return fields;} else {- return Collections.singletonList(createField(field, value));+ return List.of(createField(field, value));}}diff --git a/solr/modules/analysis-extras/src/java/org/apache/solr/update/processor/DocumentCategorizerUpdateProcessorFactory.java b/solr/modules/analysis-extras/src/java/org/apache/solr/update/processor/DocumentCategorizerUpdateProcessorFactory.javaindex 27e673a8423..b045c28ac77 100644--- a/solr/modules/analysis-extras/src/java/org/apache/solr/update/processor/DocumentCategorizerUpdateProcessorFactory.java+++ b/solr/modules/analysis-extras/src/java/org/apache/solr/update/processor/DocumentCategorizerUpdateProcessorFactory.java@@ -26,7 +26,6 @@ import java.nio.file.Files;import java.nio.file.Path;import java.util.ArrayList;import java.util.Collection;-import java.util.Collections;import java.util.HashMap;import java.util.HashSet;import java.util.List;@@ -274,7 +273,7 @@ public class DocumentCategorizerUpdateProcessorFactory extends UpdateRequestProcpe);}srcInclusions = new SelectorParams();- srcInclusions.fieldRegex = Collections.singletonList(this.pattern);+ srcInclusions.fieldRegex = List.of(this.pattern);}/**diff --git a/solr/modules/analysis-extras/src/java/org/apache/solr/update/processor/OpenNLPExtractNamedEntitiesUpdateProcessorFactory.java b/solr/modules/analysis-extras/src/java/org/apache/solr/update/processor/OpenNLPExtractNamedEntitiesUpdateProcessorFactory.javaindex 575368372c0..6c2b57b12a9 100644--- a/solr/modules/analysis-extras/src/java/org/apache/solr/update/processor/OpenNLPExtractNamedEntitiesUpdateProcessorFactory.java+++ b/solr/modules/analysis-extras/src/java/org/apache/solr/update/processor/OpenNLPExtractNamedEntitiesUpdateProcessorFactory.java@@ -23,7 +23,6 @@ import java.io.IOException;import java.lang.invoke.MethodHandles;import java.util.ArrayList;import java.util.Collection;-import java.util.Collections;import java.util.HashMap;import java.util.HashSet;import java.util.List;@@ -344,7 +343,7 @@ public class OpenNLPExtractNamedEntitiesUpdateProcessorFactory extends UpdateReqpe);}srcInclusions = new SelectorParams();- srcInclusions.fieldRegex = Collections.singletonList(this.pattern);+ srcInclusions.fieldRegex = List.of(this.pattern);}/**diff --git a/solr/modules/clustering/src/java/org/apache/solr/handler/clustering/ClusteringComponent.java b/solr/modules/clustering/src/java/org/apache/solr/handler/clustering/ClusteringComponent.javaindex 6dce932476f..e418d269fca 100644--- a/solr/modules/clustering/src/java/org/apache/solr/handler/clustering/ClusteringComponent.java+++ b/solr/modules/clustering/src/java/org/apache/solr/handler/clustering/ClusteringComponent.java@@ -20,7 +20,6 @@ import java.io.IOException;import java.lang.invoke.MethodHandles;import java.util.ArrayList;import java.util.Arrays;-import java.util.Collections;import java.util.LinkedHashMap;import java.util.LinkedHashSet;import java.util.List;@@ -156,7 +155,7 @@ public class ClusteringComponent extends SearchComponent implements SolrCoreAwarNamedList<Object> cluster = new SimpleOrderedMap<>();result.add(cluster);cluster.add(ClusteringResponse.IS_OTHER_TOPICS, true);- cluster.add(ClusteringResponse.LABELS_NODE, Collections.singletonList("Other topics"));+ cluster.add(ClusteringResponse.LABELS_NODE, List.of("Other topics"));cluster.add(ClusteringResponse.SCORE_NODE, 0d);cluster.add(ClusteringResponse.DOCS_NODE,diff --git a/solr/modules/jwt-auth/src/java/org/apache/solr/security/jwt/JWTAuthPlugin.java b/solr/modules/jwt-auth/src/java/org/apache/solr/security/jwt/JWTAuthPlugin.javaindex 439de70d0d4..3e60cd71898 100644--- a/solr/modules/jwt-auth/src/java/org/apache/solr/security/jwt/JWTAuthPlugin.java+++ b/solr/modules/jwt-auth/src/java/org/apache/solr/security/jwt/JWTAuthPlugin.java@@ -32,7 +32,6 @@ import java.util.ArrayList;import java.util.Arrays;import java.util.Base64;import java.util.Collection;-import java.util.Collections;import java.util.HashMap;import java.util.HashSet;import java.util.List;@@ -260,7 +259,7 @@ public class JWTAuthPlugin extends AuthenticationPluginredirectUris = List.of();if (redirectUrisObj != null) {if (redirectUrisObj instanceof String) {- redirectUris = Collections.singletonList((String) redirectUrisObj);+ redirectUris = List.of((String) redirectUrisObj);} else if (redirectUrisObj instanceof List) {redirectUris = (List<String>) redirectUrisObj;}diff --git a/solr/modules/jwt-auth/src/java/org/apache/solr/security/jwt/JWTIssuerConfig.java b/solr/modules/jwt-auth/src/java/org/apache/solr/security/jwt/JWTIssuerConfig.javaindex c0e074888a8..d8a6934317a 100644--- a/solr/modules/jwt-auth/src/java/org/apache/solr/security/jwt/JWTIssuerConfig.java+++ b/solr/modules/jwt-auth/src/java/org/apache/solr/security/jwt/JWTIssuerConfig.java@@ -31,7 +31,6 @@ import java.nio.charset.StandardCharsets;import java.security.cert.X509Certificate;import java.util.Arrays;import java.util.Collection;-import java.util.Collections;import java.util.HashMap;import java.util.List;import java.util.Map;@@ -129,7 +128,7 @@ public class JWTIssuerConfig {iss = wellKnownDiscoveryConfig.getIssuer();}if (jwksUrl == null) {- jwksUrl = Collections.singletonList(wellKnownDiscoveryConfig.getJwksUrl());+ jwksUrl = List.of(wellKnownDiscoveryConfig.getJwksUrl());}if (authorizationEndpoint == null) {authorizationEndpoint = wellKnownDiscoveryConfig.getAuthorizationEndpoint();@@ -265,8 +264,7 @@ public class JWTIssuerConfig {*/@SuppressWarnings("unchecked")public JWTIssuerConfig setJwksUrl(Object jwksUrlListOrString) {- if (jwksUrlListOrString instanceof String)- this.jwksUrl = Collections.singletonList((String) jwksUrlListOrString);+ if (jwksUrlListOrString instanceof String) this.jwksUrl = List.of((String) jwksUrlListOrString);else if (jwksUrlListOrString instanceof List) this.jwksUrl = (List<String>) jwksUrlListOrString;else if (jwksUrlListOrString != null)throw new SolrException(diff --git a/solr/modules/jwt-auth/src/test/org/apache/solr/security/jwt/JWTAuthPluginTest.java b/solr/modules/jwt-auth/src/test/org/apache/solr/security/jwt/JWTAuthPluginTest.javaindex 7b9ace8084b..3d4dce30729 100644--- a/solr/modules/jwt-auth/src/test/org/apache/solr/security/jwt/JWTAuthPluginTest.java+++ b/solr/modules/jwt-auth/src/test/org/apache/solr/security/jwt/JWTAuthPluginTest.java@@ -36,7 +36,6 @@ import java.security.cert.X509Certificate;import java.util.Arrays;import java.util.Base64;import java.util.Collection;-import java.util.Collections;import java.util.HashMap;import java.util.List;import java.util.Map;@@ -608,7 +607,7 @@ public class JWTAuthPluginTest extends SolrTestCaseJ4 {.setIss("1").setAud("aud1").setJwksUrl("https://127.0.0.1:9999/foo.jwk");- authConf.put("issuers", Collections.singletonList(iss1.asConfig()));+ authConf.put("issuers", List.of(iss1.asConfig()));authConf.put("aud", "aud2");authConf.put("jwksUrl",diff --git a/solr/modules/ltr/src/java/org/apache/solr/ltr/feature/FieldValueFeature.java b/solr/modules/ltr/src/java/org/apache/solr/ltr/feature/FieldValueFeature.javaindex 7a41916f29a..4e50dbd0c79 100644--- a/solr/modules/ltr/src/java/org/apache/solr/ltr/feature/FieldValueFeature.java+++ b/solr/modules/ltr/src/java/org/apache/solr/ltr/feature/FieldValueFeature.java@@ -17,7 +17,6 @@package org.apache.solr.ltr.feature;import java.io.IOException;-import java.util.Collections;import java.util.LinkedHashMap;import java.util.Map;import java.util.Set;@@ -82,7 +81,7 @@ public class FieldValueFeature extends Feature {public void setField(String field) {this.field = field;- fieldAsSet = Collections.singleton(field);+ fieldAsSet = Set.of(field);}@Overridediff --git a/solr/modules/ltr/src/test/org/apache/solr/ltr/model/TestWrapperModel.java b/solr/modules/ltr/src/test/org/apache/solr/ltr/model/TestWrapperModel.javaindex 80e2b1b3101..3d93c443c83 100644--- a/solr/modules/ltr/src/test/org/apache/solr/ltr/model/TestWrapperModel.java+++ b/solr/modules/ltr/src/test/org/apache/solr/ltr/model/TestWrapperModel.java@@ -20,7 +20,6 @@ package org.apache.solr.ltr.model;import java.lang.reflect.Method;import java.lang.reflect.Modifier;import java.util.Arrays;-import java.util.Collections;import java.util.List;import java.util.Map;import org.apache.solr.ltr.TestRerankBase;@@ -66,15 +65,13 @@ public class TestWrapperModel extends TestRerankBase {// wrapper model with featuresWrapperModel wrapperModelWithFeatures =- new StubWrapperModel(- "testModel", Collections.singletonList(new ValueFeature("val", Map.of())), List.of());+ new StubWrapperModel("testModel", List.of(new ValueFeature("val", Map.of())), List.of());ModelException e = expectThrows(ModelException.class, wrapperModelWithFeatures::validate);assertEquals("features must be empty for the wrapper model testModel", e.getMessage());// wrapper model with normsWrapperModel wrapperModelWithNorms =- new StubWrapperModel(- "testModel", List.of(), Collections.singletonList(IdentityNormalizer.INSTANCE));+ new StubWrapperModel("testModel", List.of(), List.of(IdentityNormalizer.INSTANCE));e = expectThrows(ModelException.class, wrapperModelWithNorms::validate);assertEquals("norms must be empty for the wrapper model testModel", e.getMessage());diff --git a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/PerReplicaStatesOps.java b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/PerReplicaStatesOps.javaindex d37a55ca7ec..2e28d0350af 100644--- a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/PerReplicaStatesOps.java+++ b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/PerReplicaStatesOps.java@@ -17,8 +17,6 @@package org.apache.solr.common.cloud;-import static java.util.Collections.singletonList;-import java.lang.invoke.MethodHandles;import java.util.ArrayList;import java.util.Collections;@@ -306,7 +304,7 @@ public class PerReplicaStatesOps {String replica, Replica.State state, boolean isLeader, PerReplicaStates rs) {return new PerReplicaStatesOps(perReplicaStates ->- singletonList(+ List.of(new PerReplicaStates.Operation(PerReplicaStates.Operation.Type.ADD,new PerReplicaStates.State(replica, state, isLeader, 0))))diff --git a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ZkStateReader.java b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ZkStateReader.javaindex 2b5a4695129..101d2ea983f 100644--- a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ZkStateReader.java+++ b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ZkStateReader.java@@ -506,7 +506,7 @@ public class ZkStateReader implements SolrCloseable {// What do you know, it exists!log.debug("Adding lazily-loaded reference for collection {}", collection);lazyCollectionStates.putIfAbsent(collection, tryLazyCollection);- constructState(Collections.singleton(collection));+ constructState(Set.of(collection));}} else if (ref.isLazilyLoaded()) {log.debug("Refreshing lazily-loaded state for collection {}", collection);@@ -518,7 +518,7 @@ public class ZkStateReader implements SolrCloseable {log.debug("Forcing refresh of watched collection state for {}", collection);DocCollection newState = fetchCollectionState(collection, null);if (collectionWatches.updateDocCollection(collection, newState)) {- constructState(Collections.singleton(collection));+ constructState(Set.of(collection));}} else {log.error("Collection {} is not lazy nor watched!", collection);@@ -543,7 +543,7 @@ public class ZkStateReader implements SolrCloseable {if (nu.getZNodeVersion() > collection.getZNodeVersion()) {if (collectionWatches.updateDocCollection(coll, nu)) {synchronized (getUpdateLock()) {- constructState(Collections.singleton(coll));+ constructState(Set.of(coll));}}collection = nu;@@ -1302,7 +1302,7 @@ public class ZkStateReader implements SolrCloseable {DocCollection newState = fetchCollectionState(coll, this);collectionWatches.updateDocCollection(coll, newState);synchronized (getUpdateLock()) {- constructState(Collections.singleton(coll));+ constructState(Set.of(coll));}} catch (KeeperException.SessionExpiredException@@ -1331,7 +1331,7 @@ public class ZkStateReader implements SolrCloseable {: fetchCollectionState(coll, null);collectionWatches.updateDocCollection(coll, newState);synchronized (getUpdateLock()) {- constructState(Collections.singleton(coll));+ constructState(Set.of(coll));}if (log.isDebugEnabled()) {log.debug(diff --git a/solr/solrj-zookeeper/src/test/org/apache/solr/client/solrj/impl/NodeValueFetcherTest.java b/solr/solrj-zookeeper/src/test/org/apache/solr/client/solrj/impl/NodeValueFetcherTest.javaindex 59d38f64f2c..2d07fd82964 100644--- a/solr/solrj-zookeeper/src/test/org/apache/solr/client/solrj/impl/NodeValueFetcherTest.java+++ b/solr/solrj-zookeeper/src/test/org/apache/solr/client/solrj/impl/NodeValueFetcherTest.java@@ -16,7 +16,7 @@*/package org.apache.solr.client.solrj.impl;-import java.util.Collections;+import java.util.List;import java.util.Optional;import java.util.Set;import org.apache.solr.client.solrj.impl.SolrClientNodeStateProvider.RemoteCallCtx;@@ -66,8 +66,7 @@ public class NodeValueFetcherTest extends SolrCloudTestCase {@Testpublic void testGetTags() throws Exception {try (var cloudSolrClient =- new CloudSolrClient.Builder(- Collections.singletonList(cluster.getZkServer().getZkAddress()), Optional.empty())+ new CloudSolrClient.Builder(List.of(cluster.getZkServer().getZkAddress()), Optional.empty()).build()) {int totalCores = 0;diff --git a/solr/solrj-zookeeper/src/test/org/apache/solr/common/cloud/SolrZkClientTest.java b/solr/solrj-zookeeper/src/test/org/apache/solr/common/cloud/SolrZkClientTest.javaindex 7a0fa5283cb..de5a38e00ec 100644--- a/solr/solrj-zookeeper/src/test/org/apache/solr/common/cloud/SolrZkClientTest.java+++ b/solr/solrj-zookeeper/src/test/org/apache/solr/common/cloud/SolrZkClientTest.java@@ -21,7 +21,6 @@ import java.nio.charset.StandardCharsets;import java.nio.file.Path;import java.security.NoSuchAlgorithmException;import java.util.Arrays;-import java.util.Collections;import java.util.List;import java.util.Optional;import java.util.concurrent.Semaphore;@@ -68,7 +67,7 @@ public class SolrZkClientTest extends SolrCloudTestCase {configureCluster(1).addConfig("_default", ExternalPaths.DEFAULT_CONFIGSET).configure();solrClient =new RandomizingCloudSolrClientBuilder(- Collections.singletonList(cluster.getZkServer().getZkAddress()), Optional.empty())+ List.of(cluster.getZkServer().getZkAddress()), Optional.empty()).build();final String SCHEME = "digest";@@ -123,8 +122,7 @@ public class SolrZkClientTest extends SolrCloudTestCase {@Overrideprotected ZkCredentialsProvider createZkCredentialsToAddAutomatically() {return new DefaultZkCredentialsProvider(- Collections.singletonList(- new AuthInfo(SCHEME, AUTH.getBytes(StandardCharsets.UTF_8))));+ List.of(new AuthInfo(SCHEME, AUTH.getBytes(StandardCharsets.UTF_8))));}};}diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/RemoteSolrException.java b/solr/solrj/src/java/org/apache/solr/client/solrj/RemoteSolrException.javaindex 94bbca5ebb8..4552fe0cd9d 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/RemoteSolrException.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/RemoteSolrException.java@@ -16,7 +16,6 @@*/package org.apache.solr.client.solrj;-import java.util.Collections;import java.util.List;import java.util.Map;import org.apache.solr.common.SolrErrorWrappingException;@@ -71,8 +70,7 @@ public final class RemoteSolrException extends SolrException {this.remoteErrorMessageSuffix = remoteErrorMessageSuffix;}- Object metadataObj =- Utils.getObjectByPath(remoteError, false, Collections.singletonList("metadata"));+ Object metadataObj = Utils.getObjectByPath(remoteError, false, List.of("metadata"));if (metadataObj instanceof NamedList) {setMetadata((NamedList<String>) metadataObj);} else if (metadataObj instanceof List) {diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrClient.javaindex 5b21d582d45..4512eaaa7d8 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrClient.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrClient.java@@ -21,7 +21,6 @@ import java.io.IOException;import java.io.Serializable;import java.util.ArrayList;import java.util.Collection;-import java.util.Collections;import java.util.Iterator;import java.util.List;import org.apache.solr.client.solrj.SolrRequest.METHOD;@@ -1072,7 +1071,7 @@ public abstract class SolrClient implements Serializable, Closeable {*/public SolrDocument getById(String collection, String id, SolrParams params)throws SolrServerException, IOException {- SolrDocumentList docs = getById(collection, Collections.singletonList(id), params);+ SolrDocumentList docs = getById(collection, List.of(id), params);if (!docs.isEmpty()) {return docs.get(0);}diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java b/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.javaindex 86ecd6590d1..e22ada013c7 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java@@ -28,7 +28,6 @@ import java.security.PrivilegedAction;import java.util.ArrayList;import java.util.Arrays;import java.util.Collection;-import java.util.Collections;import java.util.HashMap;import java.util.List;import java.util.Locale;@@ -476,7 +475,7 @@ public class DocumentObjectBinder {} else if (val instanceof List) {list = (List<?>) val;} else {- list = Collections.singletonList(val);+ list = List.of(val);}set(obj, list.toArray((Object[]) Array.newInstance(type, list.size())));} else if (isList && !isContainedInMap) {diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.javaindex 3f79b11801c..8eb4733ecac 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java@@ -753,8 +753,7 @@ public abstract class CloudSolrClient extends SolrClient {// Check to see if the collection is an alias. Updates to multi-collection aliases are ok as// long as they are routed aliases- List<String> aliasedCollections =- new ArrayList<>(resolveAliases(Collections.singletonList(collection)));+ List<String> aliasedCollections = new ArrayList<>(resolveAliases(List.of(collection)));if (aliasedCollections.size() == 1 || getClusterStateProvider().isRoutedAlias(collection)) {collection = aliasedCollections.get(0); // pick 1st (consistent with HttpSolrCall behavior)} else {diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/DelegatingClusterStateProvider.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/DelegatingClusterStateProvider.javaindex 48030c79c7c..6ffd111e761 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/DelegatingClusterStateProvider.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/DelegatingClusterStateProvider.java@@ -17,7 +17,6 @@package org.apache.solr.client.solrj.impl;import java.io.IOException;-import java.util.Collections;import java.util.List;import java.util.Map;import java.util.Set;@@ -55,7 +54,7 @@ public class DelegatingClusterStateProvider implements ClusterStateProvider {if (delegate != null) {return delegate.resolveAlias(alias);} else {- return Collections.singletonList(alias);+ return List.of(alias);}}diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/request/ConfigSetAdminRequest.java b/solr/solrj/src/java/org/apache/solr/client/solrj/request/ConfigSetAdminRequest.javaindex f11da334c47..e0b0a708e3f 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/request/ConfigSetAdminRequest.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/request/ConfigSetAdminRequest.java@@ -22,7 +22,6 @@ import java.io.IOException;import java.io.OutputStream;import java.nio.file.Path;import java.util.Collection;-import java.util.Collections;import java.util.Map;import java.util.Properties;import org.apache.solr.client.solrj.SolrRequest;@@ -207,7 +206,7 @@ public abstract class ConfigSetAdminRequest<@Overridepublic Collection<ContentStream> getContentStreams() throws IOException {- return Collections.singletonList(stream);+ return java.util.List.of(stream);}@Overridediff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/routing/NodePreferenceRulesComparator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/routing/NodePreferenceRulesComparator.javaindex b6cd6df90c8..e2e4ad4cd2a 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/routing/NodePreferenceRulesComparator.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/routing/NodePreferenceRulesComparator.java@@ -18,7 +18,6 @@package org.apache.solr.client.solrj.routing;import java.util.Collection;-import java.util.Collections;import java.util.Comparator;import java.util.List;import java.util.Map;@@ -219,7 +218,7 @@ public class NodePreferenceRulesComparator {// For SolrJ clients, which do not have Solr sysProps, this preference won't be usedyield null;}- Collection<String> tags = Collections.singletonList(preferenceRule.value);+ Collection<String> tags = List.of(preferenceRule.value);Map<String, Object> currentNodeMetric = sysProps.getSysProps(nodeName, tags);yield Comparator.comparing(r -> currentNodeMetric.equals(sysProps.getSysProps(r.getNodeName(), tags)));diff --git a/solr/solrj/src/java/org/apache/solr/common/SolrInputField.java b/solr/solrj/src/java/org/apache/solr/common/SolrInputField.javaindex 281d9817d07..e42935083cb 100644--- a/solr/solrj/src/java/org/apache/solr/common/SolrInputField.java+++ b/solr/solrj/src/java/org/apache/solr/common/SolrInputField.java@@ -21,6 +21,7 @@ import java.util.ArrayList;import java.util.Collection;import java.util.Collections;import java.util.Iterator;+import java.util.Set;/*** @since solr 1.3@@ -161,7 +162,7 @@ public class SolrInputField implements Iterable<Object>, Serializable {} else if (value instanceof Collection) {return ((Collection<Object>) value).iterator();}- return Collections.singleton(value).iterator();+ return Set.of(value).iterator();}@Overridediff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/Aliases.java b/solr/solrj/src/java/org/apache/solr/common/cloud/Aliases.javaindex 1e383fd91ae..f09622c3b01 100644--- a/solr/solrj/src/java/org/apache/solr/common/cloud/Aliases.java+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/Aliases.java@@ -276,7 +276,7 @@ public class Aliases {// Due to another level of indirection, this is more complicated...List<String> level1 = collectionAliasListMap.get(aliasName);if (level1 == null) {- return Collections.singletonList(aliasName); // is a collection+ return List.of(aliasName); // is a collection}// avoid allocating objects if possibleLinkedHashSet<String> uniqueResult = null;@@ -410,7 +410,7 @@ public class Aliases {}}if (level1 == null) { // create an alias that points to the collection- newColAliases.put(after, Collections.singletonList(before));+ newColAliases.put(after, List.of(before));}return new Aliases(newColAliases, newColProperties, zNodeVersion);}@@ -430,8 +430,11 @@ public class Aliases {*/public Aliases cloneWithCollectionAliasProperties(String alias, String propertiesKey, String propertiesValue) {- return cloneWithCollectionAliasProperties(- alias, Collections.singletonMap(propertiesKey, propertiesValue));+ // Use a HashMap to allow null propertiesValue (null means remove the key in the map-based+ // overload)+ Map<String, String> props = new LinkedHashMap<>();+ props.put(propertiesKey, propertiesValue);+ return cloneWithCollectionAliasProperties(alias, props);}/**diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/CompositeIdRouter.java b/solr/solrj/src/java/org/apache/solr/common/cloud/CompositeIdRouter.javaindex 39adeef1a52..fede4e6b453 100644--- a/solr/solrj/src/java/org/apache/solr/common/cloud/CompositeIdRouter.java+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/CompositeIdRouter.java@@ -18,7 +18,6 @@ package org.apache.solr.common.cloud;import java.util.ArrayList;import java.util.Collection;-import java.util.Collections;import java.util.List;import org.apache.solr.common.SolrException;import org.apache.solr.common.SolrInputDocument;@@ -218,8 +217,7 @@ public class CompositeIdRouter extends HashBasedRouter {if (shardKey.indexOf(SEPARATOR) < 0) {// shardKey is a simple id, so don't do a range- return Collections.singletonList(- hashToSlice(Hash.murmurhash3_x86_32(id, 0, id.length(), 0), collection));+ return List.of(hashToSlice(Hash.murmurhash3_x86_32(id, 0, id.length(), 0), collection));}Range completeRange = new KeyParser(id).getRange();@@ -255,7 +253,7 @@ public class CompositeIdRouter extends HashBasedRouter {throw new IllegalArgumentException("Key range does not overlap given range");}if (keyRange.equals(range)) {- return Collections.singletonList(keyRange);+ return List.of(keyRange);} else if (keyRange.isSubsetOf(range)) {result.add(new Range(range.min, keyRange.min - 1));result.add(keyRange);diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/HashBasedRouter.java b/solr/solrj/src/java/org/apache/solr/common/cloud/HashBasedRouter.javaindex 2dd6fae7d48..9d38c3e95c4 100644--- a/solr/solrj/src/java/org/apache/solr/common/cloud/HashBasedRouter.java+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/HashBasedRouter.java@@ -19,7 +19,6 @@ package org.apache.solr.common.cloud;import static org.apache.solr.common.params.CommonParams.ID;import java.util.Collection;-import java.util.Collections;import java.util.List;import org.apache.solr.common.SolrException;import org.apache.solr.common.SolrInputDocument;@@ -94,6 +93,6 @@ public abstract class HashBasedRouter extends DocRouter {// use the shardKey as an id for plain hashingSlice slice = getTargetSlice(shardKey, null, null, params, collection);- return slice == null ? List.of() : Collections.singletonList(slice);+ return slice == null ? List.of() : List.of(slice);}}diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ImplicitDocRouter.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ImplicitDocRouter.javaindex ca2f4277a59..724c03109fb 100644--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ImplicitDocRouter.java+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ImplicitDocRouter.java@@ -19,8 +19,8 @@ package org.apache.solr.common.cloud;import static org.apache.solr.common.params.ShardParams._ROUTE_;import java.util.Collection;-import java.util.Collections;import java.util.List;+import java.util.Set;import org.apache.solr.common.SolrException;import org.apache.solr.common.SolrInputDocument;import org.apache.solr.common.params.SolrParams;@@ -111,7 +111,7 @@ public class ImplicitDocRouter extends DocRouter {+ collection.getName());}- return Collections.singleton(slice);+ return Set.of(slice);}@Overridediff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkNodeProps.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkNodeProps.javaindex 1e44d700342..72ba3949b0e 100644--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkNodeProps.java+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkNodeProps.java@@ -19,7 +19,6 @@ package org.apache.solr.common.cloud;import static org.apache.solr.common.util.Utils.toJSONString;import java.io.IOException;-import java.util.Collections;import java.util.HashMap;import java.util.LinkedHashMap;import java.util.Map;@@ -47,7 +46,7 @@ public class ZkNodeProps implements MapWriter {}public ZkNodeProps plus(String key, Object val) {- return plus(Collections.singletonMap(key, val));+ return plus(Map.of(key, val));}public ZkNodeProps plus(Map<String, Object> newVals) {diff --git a/solr/solrj/src/java/org/apache/solr/common/util/CommandOperation.java b/solr/solrj/src/java/org/apache/solr/common/util/CommandOperation.javaindex 97e45a7e588..7598e90fcbb 100644--- a/solr/solrj/src/java/org/apache/solr/common/util/CommandOperation.java+++ b/solr/solrj/src/java/org/apache/solr/common/util/CommandOperation.java@@ -16,8 +16,6 @@*/package org.apache.solr.common.util;-import static java.util.Collections.singletonList;-import static java.util.Collections.singletonMap;import static org.apache.solr.common.util.StrUtils.formatString;import static org.apache.solr.common.util.Utils.toJSON;@@ -26,7 +24,6 @@ import java.io.InputStream;import java.io.Reader;import java.nio.charset.StandardCharsets;import java.util.ArrayList;-import java.util.Collections;import java.util.HashMap;import java.util.LinkedHashMap;import java.util.List;@@ -145,7 +142,7 @@ public class CommandOperation {if (l.isEmpty()) return def;return l;} else {- return singletonList(String.valueOf(v));+ return List.of(String.valueOf(v));}}}@@ -228,7 +225,7 @@ public class CommandOperation {if (value instanceof List && !singletonCommands.contains(key)) {vals = (List<?>) value;} else {- vals = Collections.singletonList(value);+ vals = List.of(value);}for (Object val : vals) {operations.add(new CommandOperation(String.valueOf(key), val));@@ -315,7 +312,7 @@ public class CommandOperation {@Overridepublic String toString() {- return new String(toJSON(singletonMap(name, commandData)), StandardCharsets.UTF_8);+ return new String(toJSON(Map.of(name, commandData)), StandardCharsets.UTF_8);}public static List<CommandOperation> readCommands(diff --git a/solr/solrj/src/java/org/apache/solr/common/util/JsonSchemaValidator.java b/solr/solrj/src/java/org/apache/solr/common/util/JsonSchemaValidator.javaindex 9988ff94c46..9d19c35b8ac 100644--- a/solr/solrj/src/java/org/apache/solr/common/util/JsonSchemaValidator.java+++ b/solr/solrj/src/java/org/apache/solr/common/util/JsonSchemaValidator.java@@ -19,7 +19,6 @@ package org.apache.solr.common.util;import java.util.ArrayList;import java.util.Arrays;-import java.util.Collections;import java.util.HashMap;import java.util.HashSet;import java.util.List;@@ -271,7 +270,7 @@ class RequiredValidator extends Validator<List<String>> {return false;}String subprop = requiredProp.substring(requiredProp.indexOf('.') + 1);- if (!validate(((Map) o).get(requiredProp), errs, Collections.singleton(subprop))) {+ if (!validate(((Map) o).get(requiredProp), errs, Set.of(subprop))) {return false;}} else {diff --git a/solr/solrj/src/java/org/apache/solr/common/util/RetryUtil.java b/solr/solrj/src/java/org/apache/solr/common/util/RetryUtil.javaindex 7c6c7c5dc55..f6fd50d2ada 100644--- a/solr/solrj/src/java/org/apache/solr/common/util/RetryUtil.java+++ b/solr/solrj/src/java/org/apache/solr/common/util/RetryUtil.java@@ -17,7 +17,6 @@package org.apache.solr.common.util;import java.lang.invoke.MethodHandles;-import java.util.Collections;import java.util.Set;import java.util.concurrent.TimeUnit;import java.util.function.Predicate;@@ -75,7 +74,7 @@ public class RetryUtil {public static void retryOnException(Class<? extends Exception> clazz, long timeoutms, long intervalms, RetryCmd cmd)throws Exception {- retryOnException(Collections.singleton(clazz), timeoutms, intervalms, cmd);+ retryOnException(Set.of(clazz), timeoutms, intervalms, cmd);}/**diff --git a/solr/solrj/src/java/org/apache/solr/common/util/Utils.java b/solr/solrj/src/java/org/apache/solr/common/util/Utils.javaindex 86c96944ace..8db2d1c0ae1 100644--- a/solr/solrj/src/java/org/apache/solr/common/util/Utils.java+++ b/solr/solrj/src/java/org/apache/solr/common/util/Utils.java@@ -17,7 +17,6 @@package org.apache.solr.common.util;import static java.nio.charset.StandardCharsets.UTF_8;-import static java.util.Collections.singletonList;import static java.util.concurrent.TimeUnit.NANOSECONDS;import static org.apache.solr.common.SolrException.ErrorCode.SERVER_ERROR;@@ -441,8 +440,11 @@ public class Utils {}}+ @SuppressForbidden(+ reason = "singletonList(null) is intentional — null is a sentinel path element")public static Object getObjectByPath(Object root, boolean onlyPrimitive, String hierarchy) {- if (hierarchy == null) return getObjectByPath(root, onlyPrimitive, singletonList(null));+ if (hierarchy == null)+ return getObjectByPath(root, onlyPrimitive, Collections.singletonList(null));List<String> parts = StrUtils.splitSmart(hierarchy, '/', true);return getObjectByPath(root, onlyPrimitive, parts);}diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientBuilderTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientBuilderTest.javaindex cd9b4d20096..62be902fa67 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientBuilderTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientBuilderTest.java@@ -25,7 +25,6 @@ import static org.mockito.Mockito.when;import java.io.IOException;import java.util.ArrayList;-import java.util.Collections;import java.util.List;import java.util.Optional;import java.util.concurrent.TimeUnit;@@ -56,8 +55,7 @@ public class CloudHttp2SolrClientBuilderTest extends SolrCloudTestCase {@Testpublic void testSingleZkHostSpecified() throws IOException {try (CloudSolrClient createdClient =- new CloudSolrClient.Builder(Collections.singletonList(ANY_ZK_HOST), Optional.of(ANY_CHROOT))- .build()) {+ new CloudSolrClient.Builder(List.of(ANY_ZK_HOST), Optional.of(ANY_CHROOT)).build()) {try (ZkClientClusterStateProvider zkClientClusterStateProvider =ZkClientClusterStateProvider.from(createdClient)) {final String clientZkHost = zkClientClusterStateProvider.getZkHost();@@ -104,8 +102,7 @@ public class CloudHttp2SolrClientBuilderTest extends SolrCloudTestCase {@Testpublic void testByDefaultConfiguresClientToSendUpdatesOnlyToShardLeaders() throws IOException {try (CloudSolrClient createdClient =- new CloudSolrClient.Builder(Collections.singletonList(ANY_ZK_HOST), Optional.of(ANY_CHROOT))- .build()) {+ new CloudSolrClient.Builder(List.of(ANY_ZK_HOST), Optional.of(ANY_CHROOT)).build()) {assertTrue(createdClient.isUpdatesToLeaders());}}@@ -113,8 +110,7 @@ public class CloudHttp2SolrClientBuilderTest extends SolrCloudTestCase {@Testpublic void testIsDirectUpdatesToLeadersOnlyDefault() throws IOException {try (CloudSolrClient createdClient =- new CloudSolrClient.Builder(Collections.singletonList(ANY_ZK_HOST), Optional.of(ANY_CHROOT))- .build()) {+ new CloudSolrClient.Builder(List.of(ANY_ZK_HOST), Optional.of(ANY_CHROOT)).build()) {assertFalse(createdClient.isDirectUpdatesToLeadersOnly());}}@@ -124,16 +120,14 @@ public class CloudHttp2SolrClientBuilderTest extends SolrCloudTestCase {expectThrows(IllegalStateException.class,() ->- new CloudSolrClient.Builder(- Collections.singletonList(ANY_ZK_HOST), Optional.of(ANY_CHROOT))+ new CloudSolrClient.Builder(List.of(ANY_ZK_HOST), Optional.of(ANY_CHROOT)).withHttpClient(mock(HttpJettySolrClient.class)).withHttpClientBuilder(mock(HttpJettySolrClient.Builder.class)).build());expectThrows(IllegalStateException.class,() ->- new CloudSolrClient.Builder(- Collections.singletonList(ANY_ZK_HOST), Optional.of(ANY_CHROOT))+ new CloudSolrClient.Builder(List.of(ANY_ZK_HOST), Optional.of(ANY_CHROOT)).withHttpClientBuilder(mock(HttpJettySolrClient.Builder.class)).withHttpClient(mock(HttpJettySolrClient.class)).build());@@ -145,7 +139,7 @@ public class CloudHttp2SolrClientBuilderTest extends SolrCloudTestCase {HttpJettySolrClient.Builder http2ClientBuilder = mock(HttpJettySolrClient.Builder.class);when(http2ClientBuilder.build()).thenReturn(http2Client);CloudSolrClient.Builder clientBuilder =- new CloudSolrClient.Builder(Collections.singletonList(ANY_ZK_HOST), Optional.of(ANY_CHROOT))+ new CloudSolrClient.Builder(List.of(ANY_ZK_HOST), Optional.of(ANY_CHROOT)).withHttpClientBuilder(http2ClientBuilder);verify(http2ClientBuilder, never()).build();try (CloudHttp2SolrClient client = clientBuilder.build()) {@@ -163,7 +157,7 @@ public class CloudHttp2SolrClientBuilderTest extends SolrCloudTestCase {HttpJdkSolrClient.Builder http2ClientBuilder = mock(HttpJdkSolrClient.Builder.class);when(http2ClientBuilder.build()).thenReturn(http2Client);CloudSolrClient.Builder clientBuilder =- new CloudSolrClient.Builder(Collections.singletonList(ANY_ZK_HOST), Optional.of(ANY_CHROOT))+ new CloudSolrClient.Builder(List.of(ANY_ZK_HOST), Optional.of(ANY_CHROOT)).withHttpClientBuilder(http2ClientBuilder);verify(http2ClientBuilder, never()).build();try (CloudHttp2SolrClient client = clientBuilder.build()) {@@ -179,7 +173,7 @@ public class CloudHttp2SolrClientBuilderTest extends SolrCloudTestCase {public void testProvideExternalJettyClient() throws IOException {HttpJettySolrClient http2Client = mock(HttpJettySolrClient.class);CloudSolrClient.Builder clientBuilder =- new CloudSolrClient.Builder(Collections.singletonList(ANY_ZK_HOST), Optional.of(ANY_CHROOT))+ new CloudSolrClient.Builder(List.of(ANY_ZK_HOST), Optional.of(ANY_CHROOT)).withHttpClient(http2Client);try (CloudHttp2SolrClient client = clientBuilder.build()) {assertEquals(http2Client, client.getHttpClient());@@ -192,7 +186,7 @@ public class CloudHttp2SolrClientBuilderTest extends SolrCloudTestCase {public void testProvideExternalJdkClient() throws IOException {HttpJdkSolrClient http2Client = mock(HttpJdkSolrClient.class);CloudSolrClient.Builder clientBuilder =- new CloudSolrClient.Builder(Collections.singletonList(ANY_ZK_HOST), Optional.of(ANY_CHROOT))+ new CloudSolrClient.Builder(List.of(ANY_ZK_HOST), Optional.of(ANY_CHROOT)).withHttpClient(http2Client);try (CloudHttp2SolrClient client = clientBuilder.build()) {assertEquals(http2Client, client.getHttpClient());@@ -204,8 +198,7 @@ public class CloudHttp2SolrClientBuilderTest extends SolrCloudTestCase {@Testpublic void testDefaultClientUsesJetty() throws IOException {try (CloudHttp2SolrClient createdClient =- new CloudSolrClient.Builder(Collections.singletonList(ANY_ZK_HOST), Optional.of(ANY_CHROOT))- .build()) {+ new CloudSolrClient.Builder(List.of(ANY_ZK_HOST), Optional.of(ANY_CHROOT)).build()) {assertTrue(createdClient.getHttpClient() instanceof HttpJettySolrClient);assertTrue(createdClient.getLbClient().getClient(null) instanceof HttpJettySolrClient);}@@ -214,7 +207,7 @@ public class CloudHttp2SolrClientBuilderTest extends SolrCloudTestCase {@Testpublic void testDefaultCollectionPassedFromBuilderToClient() throws IOException {try (CloudHttp2SolrClient createdClient =- new CloudSolrClient.Builder(Collections.singletonList(ANY_ZK_HOST), Optional.of(ANY_CHROOT))+ new CloudSolrClient.Builder(List.of(ANY_ZK_HOST), Optional.of(ANY_CHROOT)).withDefaultCollection("aCollection").build()) {assertEquals("aCollection", createdClient.getDefaultCollection());@@ -277,7 +270,7 @@ public class CloudHttp2SolrClientBuilderTest extends SolrCloudTestCase {@SuppressWarnings({"try"})public void test0Timeouts() throws IOException {try (CloudSolrClient createdClient =- new CloudSolrClient.Builder(Collections.singletonList(ANY_ZK_HOST), Optional.empty())+ new CloudSolrClient.Builder(List.of(ANY_ZK_HOST), Optional.empty()).withZkConnectTimeout(0, TimeUnit.MILLISECONDS).withZkClientTimeout(0, TimeUnit.MILLISECONDS).build()) {diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientRetryTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientRetryTest.javaindex 9584ffc65cc..c5f52ccaa61 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientRetryTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientRetryTest.java@@ -19,7 +19,7 @@ package org.apache.solr.client.solrj.impl;import static org.apache.solr.util.SolrJMetricTestUtils.getPrometheusMetricValue;-import java.util.Collections;+import java.util.List;import java.util.Optional;import org.apache.solr.client.solrj.jetty.HttpJettySolrClient;import org.apache.solr.client.solrj.request.CollectionAdminRequest;@@ -61,7 +61,7 @@ public class CloudHttp2SolrClientRetryTest extends SolrCloudTestCase {var cloudSolrclientBuilder =new CloudSolrClient.Builder(- Collections.singletonList(cluster.getZkServer().getZkAddress()), Optional.empty());+ List.of(cluster.getZkServer().getZkAddress()), Optional.empty());cloudSolrclientBuilder.withHttpClientBuilder(random().nextBoolean() ? jettyClientBuilder : jdkClientBuilder);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.javaindex 317fc48dbed..3d2f32fc2a7 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@@ -26,7 +26,6 @@ import java.net.URI;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.Iterator;@@ -155,8 +154,7 @@ public class CloudHttp2SolrClientTest extends SolrCloudTestCase {instanceof HttpJdkSolrClient);zkBasedCloudSolrClient =- new CloudSolrClient.Builder(- Collections.singletonList(cluster.getZkServer().getZkAddress()), Optional.empty())+ new CloudSolrClient.Builder(List.of(cluster.getZkServer().getZkAddress()), Optional.empty()).build();assertTrue(zkBasedCloudSolrClient.getHttpClient() instanceof HttpJettySolrClient);assertTrue(@@ -432,7 +430,7 @@ public class CloudHttp2SolrClientTest extends SolrCloudTestCase {// Test Multi-Threaded routed updates for UpdateRequesttry (CloudSolrClient threadedClient =new RandomizingCloudSolrClientBuilder(- Collections.singletonList(cluster.getZkServer().getZkAddress()), Optional.empty())+ List.of(cluster.getZkServer().getZkAddress()), Optional.empty()).sendUpdatesOnlyToShardLeaders().withParallelUpdates(true).withDefaultCollection("routing_collection")@@ -717,7 +715,7 @@ public class CloudHttp2SolrClientTest extends SolrCloudTestCase {try (CloudSolrClient client =new RandomizingCloudSolrClientBuilder(- Collections.singletonList(cluster.getZkServer().getZkAddress()), Optional.empty())+ List.of(cluster.getZkServer().getZkAddress()), Optional.empty()).withDefaultCollection("foo").build()) {// important to have one replica on each node@@ -792,7 +790,7 @@ public class CloudHttp2SolrClientTest extends SolrCloudTestCase {public void checkCollectionParameters() throws Exception {try (CloudSolrClient client =new RandomizingCloudSolrClientBuilder(- Collections.singletonList(cluster.getZkServer().getZkAddress()), Optional.empty())+ List.of(cluster.getZkServer().getZkAddress()), Optional.empty()).withDefaultCollection("multicollection1").build()) {@@ -912,9 +910,7 @@ public class CloudHttp2SolrClientTest extends SolrCloudTestCase {@Testpublic void testShutdown() throws IOException {try (CloudSolrClient client =- new RandomizingCloudSolrClientBuilder(- Collections.singletonList(DEAD_HOST_1), Optional.empty())- .build()) {+ new RandomizingCloudSolrClientBuilder(List.of(DEAD_HOST_1), Optional.empty()).build()) {try (ZkClientClusterStateProvider zkClientClusterStateProvider =ZkClientClusterStateProvider.from(client)) {zkClientClusterStateProvider.setZkConnectTimeout(100);@@ -928,8 +924,7 @@ public class CloudHttp2SolrClientTest extends SolrCloudTestCase {public void testWrongZkChrootTest() throws IOException {try (CloudSolrClient client =new RandomizingCloudSolrClientBuilder(- Collections.singletonList(cluster.getZkServer().getZkAddress() + "/xyz/foo"),- Optional.empty())+ List.of(cluster.getZkServer().getZkAddress() + "/xyz/foo"), Optional.empty()).build()) {try (ZkClientClusterStateProvider zkClientClusterStateProvider =ZkClientClusterStateProvider.from(client)) {@@ -948,9 +943,7 @@ public class CloudHttp2SolrClientTest extends SolrCloudTestCase {String baseUrl = cluster.getJettySolrRunners().get(0).getBaseUrl().toString();try (HttpJettySolrClient httpClient = new HttpJettySolrClient.Builder(baseUrl).build()) {try (CloudSolrClient cloudClient =- new CloudJettySolrClient.Builder(Collections.singletonList(baseUrl))- .withHttpClient(httpClient)- .build()) {+ new CloudJettySolrClient.Builder(List.of(baseUrl)).withHttpClient(httpClient).build()) {// Verify the CloudJettySolrClient uses the provided HttpJettySolrClientassertSame(((CloudJettySolrClient) cloudClient).getHttpClient(), httpClient);}@@ -1064,7 +1057,7 @@ public class CloudHttp2SolrClientTest extends SolrCloudTestCase {// NOTE: creating our own CloudSolrClient whose settings we can muck with...try (CloudSolrClient stale_client =new RandomizingCloudSolrClientBuilder(- Collections.singletonList(cluster.getZkServer().getZkAddress()), Optional.empty())+ List.of(cluster.getZkServer().getZkAddress()), Optional.empty()).withParallelUpdates(true).sendDirectUpdatesToAnyShardReplica().withDefaultCollection(COL)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.javaindex 521bfd0f0be..8d279ea773b 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@@ -93,7 +93,7 @@ public class CloudSolrClientCacheTest extends SolrTestCaseJ4 {}Map<String, Function<?, ?>> responses = new HashMap<>();NamedList<Object> okResponse = new NamedList<>();- okResponse.add("responseHeader", new NamedList<>(Collections.singletonMap("status", 0)));+ okResponse.add("responseHeader", new NamedList<>(Map.of("status", 0)));LBHttpSolrClient mockLbclient = getMockLbHttpSolrClient(responses);AtomicInteger lbhttpRequestCount = new AtomicInteger();@@ -332,7 +332,7 @@ public class CloudSolrClientCacheTest extends SolrTestCaseJ4 {@Overridepublic List<String> resolveAlias(String collection) {- return Collections.singletonList(collection);+ return List.of(collection);}@Overridediff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientRoutingTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientRoutingTest.javaindex a2693167833..69bc456885f 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientRoutingTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientRoutingTest.java@@ -18,7 +18,6 @@ package org.apache.solr.client.solrj.impl;import java.io.IOException;import java.util.ArrayList;-import java.util.Collections;import java.util.List;import java.util.Optional;import org.apache.lucene.tests.util.TestUtil;@@ -149,8 +148,7 @@ public final class CloudSolrClientRoutingTest extends SolrCloudTestCase {cluster.waitForActiveCollection(collectionName, 2, 2);try (CloudSolrClient client =- new CloudSolrClient.Builder(- Collections.singletonList(cluster.getZkServer().getZkAddress()), Optional.empty())+ new CloudSolrClient.Builder(List.of(cluster.getZkServer().getZkAddress()), Optional.empty()).withDefaultCollection(collectionName).sendUpdatesOnlyToShardLeaders().sendDirectUpdatesToShardLeadersOnly()diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpClusterStateSSLTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpClusterStateSSLTest.javaindex 529b95373f6..5ae877eda0a 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpClusterStateSSLTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpClusterStateSSLTest.java@@ -18,7 +18,6 @@package org.apache.solr.client.solrj.impl;import java.net.URL;-import java.util.Collections;import java.util.List;import java.util.Map;import org.apache.solr.client.solrj.request.CollectionAdminRequest;@@ -81,7 +80,7 @@ public class HttpClusterStateSSLTest extends SolrCloudTestCase {// verify the http derived cluster state (on the client side) agrees with what the server storedtry (CloudSolrClient httpBasedCloudSolrClient =- new CloudSolrClient.Builder(Collections.singletonList(url0.toExternalForm())).build()) {+ new CloudSolrClient.Builder(List.of(url0.toExternalForm())).build()) {ClusterStateProvider csp = httpBasedCloudSolrClient.getClusterStateProvider();assertTrue(csp instanceof HttpClusterStateProvider);verifyUrlSchemeInClusterState(csp.getCollection(collectionId), expectedReplicas);@@ -89,7 +88,7 @@ public class HttpClusterStateSSLTest extends SolrCloudTestCase {// http2try (CloudSolrClient http2BasedClient =- new CloudSolrClient.Builder(Collections.singletonList(url0.toExternalForm())).build()) {+ new CloudSolrClient.Builder(List.of(url0.toExternalForm())).build()) {ClusterStateProvider csp = http2BasedClient.getClusterStateProvider();assertTrue(csp instanceof HttpClusterStateProvider);verifyUrlSchemeInClusterState(csp.getCollection(collectionId), expectedReplicas);diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpJdkSolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpJdkSolrClientTest.javaindex 1c99a2caa4d..707e665d97a 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpJdkSolrClientTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpJdkSolrClientTest.java@@ -24,7 +24,7 @@ import java.net.URI;import java.net.URISyntaxException;import java.net.http.HttpClient;import java.util.Arrays;-import java.util.Collections;+import java.util.Map;import java.util.Objects;import java.util.Set;import java.util.concurrent.ExecutorService;@@ -533,7 +533,7 @@ public class HttpJdkSolrClientTest extends HttpSolrClientTestBase {* @param client the client*/private void queryToHelpJdkReleaseThreads(HttpJdkSolrClient client) throws Exception {- client.query("collection1", new MapSolrParams(Collections.singletonMap("q", "*:*")));+ client.query("collection1", new MapSolrParams(Map.of("q", "*:*")));}private void assertNoHeadRequestWithSsl(HttpJdkSolrClient client) {diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientTestBase.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientTestBase.javaindex ad122866273..771e6e1db58 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientTestBase.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientTestBase.java@@ -27,10 +27,10 @@ import java.nio.charset.StandardCharsets;import java.util.ArrayList;import java.util.Base64;import java.util.Collection;-import java.util.Collections;import java.util.Iterator;import java.util.List;import java.util.Locale;+import java.util.Map;import java.util.Properties;import java.util.Set;import java.util.concurrent.CompletableFuture;@@ -237,7 +237,7 @@ public abstract class HttpSolrClientTestBase extends SolrTestCaseJ4 {public void testGetById(HttpSolrClientBase client) throws Exception {DebugServlet.clear();- Collection<String> ids = Collections.singletonList("a");+ Collection<String> ids = List.of("a");try {client.getById("a");} catch (RemoteSolrException ignored) {@@ -577,9 +577,7 @@ public abstract class HttpSolrClientTestBase extends SolrTestCaseJ4 {client.commit(DEFAULT_COLLECTION);QueryResponse qr =client.query(- DEFAULT_COLLECTION,- new MapSolrParams(Collections.singletonMap("q", "*:*")),- SolrRequest.METHOD.POST);+ DEFAULT_COLLECTION, new MapSolrParams(Map.of("q", "*:*")), SolrRequest.METHOD.POST);assertEquals(0, qr.getResults().getNumFound());for (int i = 0; i < limit; i++) {@@ -595,9 +593,7 @@ public abstract class HttpSolrClientTestBase extends SolrTestCaseJ4 {// check that the correct number of documents were addedqr =client.query(- DEFAULT_COLLECTION,- new MapSolrParams(Collections.singletonMap("q", "*:*")),- SolrRequest.METHOD.POST);+ DEFAULT_COLLECTION, new MapSolrParams(Map.of("q", "*:*")), SolrRequest.METHOD.POST);assertEquals(limit, qr.getResults().getNumFound());// clean up@@ -620,8 +616,7 @@ public abstract class HttpSolrClientTestBase extends SolrTestCaseJ4 {"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<response><result name=\"response\" numFound=\"2\" start=\"1\" numFoundExact=\"true\"><doc><str name=\"id\">KEY-"+ i+ "</str></doc></result></response>");- QueryRequest query =- new QueryRequest(new MapSolrParams(Collections.singletonMap("id", "KEY-" + i)));+ QueryRequest query = new QueryRequest(new MapSolrParams(Map.of("id", "KEY-" + i)));query.setMethod(SolrRequest.METHOD.GET);futures.add(client.requestAsync(query));}@@ -649,7 +644,7 @@ public abstract class HttpSolrClientTestBase extends SolrTestCaseJ4 {builder(url, DEFAULT_CONNECTION_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT).withResponseParser(rp);try (HttpSolrClientBase client = b.build()) {- QueryRequest query = new QueryRequest(new MapSolrParams(Collections.singletonMap("id", "1")));+ QueryRequest query = new QueryRequest(new MapSolrParams(Map.of("id", "1")));CompletableFuture<NamedList<Object>> future = client.requestAsync(query, DEFAULT_COLLECTION);ExecutionException ee = null;try {diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/LBAsyncSolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/LBAsyncSolrClientTest.javaindex 9388b9aa86c..1bc6b662ed1 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/LBAsyncSolrClientTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/LBAsyncSolrClientTest.java@@ -18,7 +18,6 @@ package org.apache.solr.client.solrj.impl;import java.io.IOException;import java.util.ArrayList;-import java.util.Collections;import java.util.List;import java.util.Map;import java.util.concurrent.CompletableFuture;@@ -320,7 +319,7 @@ public class LBAsyncSolrClientTest extends SolrTestCase {private NamedList<Object> generateResponse(SolrRequest<?> solrRequest) {String id = solrRequest.getParams().get("q");- return new NamedList<>(Collections.singletonMap("response", id));+ return new NamedList<>(Map.of("response", id));}}}diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/SendUpdatesToLeadersOverrideTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/SendUpdatesToLeadersOverrideTest.javaindex 8c9f8a60245..5d31f782379 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/SendUpdatesToLeadersOverrideTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/SendUpdatesToLeadersOverrideTest.java@@ -24,7 +24,6 @@ import static org.hamcrest.Matchers.not;import java.lang.invoke.MethodHandles;import java.util.Collection;-import java.util.Collections;import java.util.HashSet;import java.util.List;import java.util.Map;@@ -210,13 +209,12 @@ public class SendUpdatesToLeadersOverrideTest extends SolrCloudTestCase {public void testBuilderImplicitBehavior() throws Exception {try (CloudSolrClient client =new CloudLegacySolrClient.Builder(- Collections.singletonList(cluster.getZkServer().getZkAddress()), Optional.empty())+ List.of(cluster.getZkServer().getZkAddress()), Optional.empty()).build()) {assertTrue(client.isUpdatesToLeaders());}try (CloudSolrClient client =- new CloudSolrClient.Builder(- Collections.singletonList(cluster.getZkServer().getZkAddress()), Optional.empty())+ new CloudSolrClient.Builder(List.of(cluster.getZkServer().getZkAddress()), Optional.empty()).build()) {assertTrue(client.isUpdatesToLeaders());}@@ -225,7 +223,7 @@ public class SendUpdatesToLeadersOverrideTest extends SolrCloudTestCase {public void testLegacyClientThatDefaultsToLeaders() throws Exception {try (CloudSolrClient client =new CloudLegacySolrClient.Builder(- Collections.singletonList(cluster.getZkServer().getZkAddress()), Optional.empty())+ List.of(cluster.getZkServer().getZkAddress()), Optional.empty()).sendUpdatesOnlyToShardLeaders().build()) {checkUpdatesDefaultToLeaders(client);@@ -236,7 +234,7 @@ public class SendUpdatesToLeadersOverrideTest extends SolrCloudTestCase {public void testLegacyClientThatDoesNotDefaultToLeaders() throws Exception {try (CloudSolrClient client =new CloudLegacySolrClient.Builder(- Collections.singletonList(cluster.getZkServer().getZkAddress()), Optional.empty())+ List.of(cluster.getZkServer().getZkAddress()), Optional.empty()).sendUpdatesToAnyReplica().build()) {checkUpdatesWithShardsPrefPull(client);@@ -246,8 +244,7 @@ public class SendUpdatesToLeadersOverrideTest extends SolrCloudTestCase {public void testHttp2ClientThatDefaultsToLeaders() throws Exception {try (CloudSolrClient client =- new CloudSolrClient.Builder(- Collections.singletonList(cluster.getZkServer().getZkAddress()), Optional.empty())+ new CloudSolrClient.Builder(List.of(cluster.getZkServer().getZkAddress()), Optional.empty()).sendUpdatesOnlyToShardLeaders().build()) {checkUpdatesDefaultToLeaders(client);@@ -257,8 +254,7 @@ public class SendUpdatesToLeadersOverrideTest extends SolrCloudTestCase {public void testHttp2ClientThatDoesNotDefaultToLeaders() throws Exception {try (CloudSolrClient client =- new CloudSolrClient.Builder(- Collections.singletonList(cluster.getZkServer().getZkAddress()), Optional.empty())+ new CloudSolrClient.Builder(List.of(cluster.getZkServer().getZkAddress()), Optional.empty()).sendUpdatesToAnyReplica().build()) {checkUpdatesWithShardsPrefPull(client);diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/request/SchemaTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/request/SchemaTest.javaindex 72f6640a3a2..6d5cb25ad48 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/request/SchemaTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/request/SchemaTest.java@@ -24,7 +24,6 @@ import static org.hamcrest.CoreMatchers.is;import java.nio.file.Path;import java.util.ArrayList;import java.util.Arrays;-import java.util.Collections;import java.util.LinkedHashMap;import java.util.List;import java.util.Locale;@@ -520,14 +519,14 @@ public class SchemaTest extends RestTestBase {charFilterAttributes.put("class", "solr.PatternReplaceCharFilterFactory");charFilterAttributes.put("replacement", "$1$1");charFilterAttributes.put("pattern", "([a-zA-Z])\\\\1+");- analyzerDefinition.setCharFilters(Collections.singletonList(charFilterAttributes));+ analyzerDefinition.setCharFilters(List.of(charFilterAttributes));Map<String, Object> tokenizerAttributes = new LinkedHashMap<>();tokenizerAttributes.put("class", "solr.WhitespaceTokenizerFactory");analyzerDefinition.setTokenizer(tokenizerAttributes);Map<String, Object> filterAttributes = new LinkedHashMap<>();filterAttributes.put("class", "solr.WordDelimiterGraphFilterFactory");filterAttributes.put("preserveOriginal", "0");- analyzerDefinition.setFilters(Collections.singletonList(filterAttributes));+ analyzerDefinition.setFilters(List.of(filterAttributes));fieldTypeDefinition.setAnalyzer(analyzerDefinition);SchemaRequest.AddFieldType addFieldTypeRequest =@@ -587,7 +586,7 @@ public class SchemaTest extends RestTestBase {charFilterAttributes.put("class", "solr.PatternReplaceCharFilterFactory");charFilterAttributes.put("replacement", "$1$1");charFilterAttributes.put("pattern", "([a-zA-Z])\\\\1+");- analyzerDefinition.setCharFilters(Collections.singletonList(charFilterAttributes));+ analyzerDefinition.setCharFilters(List.of(charFilterAttributes));Map<String, Object> tokenizerAttributes = new LinkedHashMap<>();tokenizerAttributes.put("class", "solr.WhitespaceTokenizerFactory");analyzerDefinition.setTokenizer(tokenizerAttributes);diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/response/NestableJsonFacetTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/response/NestableJsonFacetTest.javaindex 9a3d32d3186..e9230c358e0 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/response/NestableJsonFacetTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/response/NestableJsonFacetTest.java@@ -17,7 +17,7 @@package org.apache.solr.client.solrj.response;-import java.util.Collections;+import java.util.List;import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.client.solrj.response.json.NestableJsonFacet;import org.apache.solr.common.util.NamedList;@@ -69,7 +69,7 @@ public class NestableJsonFacetTest extends SolrTestCaseJ4 {});}};- vals.add("buckets", Collections.singletonList(buckets));+ vals.add("buckets", List.of(buckets));list.add("test", vals);NestableJsonFacet facet = new NestableJsonFacet(list);@@ -118,7 +118,7 @@ public class NestableJsonFacetTest extends SolrTestCaseJ4 {});}};- vals.add("buckets", Collections.singletonList(buckets));+ vals.add("buckets", List.of(buckets));list.add("test", vals);facet = new NestableJsonFacet(list);assertEquals(12L, facet.getCount());diff --git a/solr/solrj/src/test/org/apache/solr/common/cloud/PerReplicaStatesIntegrationTest.java b/solr/solrj/src/test/org/apache/solr/common/cloud/PerReplicaStatesIntegrationTest.javaindex 595b2025f3b..e996c111a46 100644--- a/solr/solrj/src/test/org/apache/solr/common/cloud/PerReplicaStatesIntegrationTest.java+++ b/solr/solrj/src/test/org/apache/solr/common/cloud/PerReplicaStatesIntegrationTest.java@@ -21,7 +21,7 @@ import static org.apache.solr.client.solrj.SolrRequest.METHOD.POST;import static org.apache.solr.common.params.CollectionAdminParams.PER_REPLICA_STATE;import java.lang.invoke.MethodHandles;-import java.util.Collections;+import java.util.Map;import java.util.concurrent.TimeUnit;import java.util.concurrent.atomic.AtomicBoolean;import org.apache.solr.client.solrj.SolrClient;@@ -245,8 +245,7 @@ public class PerReplicaStatesIntegrationTest extends SolrCloudTestCase {DocCollection.getCollectionPath(COLL), cluster.getZkClient(), null);log.info("prs1 : {}", prs1);- CollectionAdminRequest.modifyCollection(- COLL, Collections.singletonMap(PER_REPLICA_STATE, "false"))+ CollectionAdminRequest.modifyCollection(COLL, Map.of(PER_REPLICA_STATE, "false")).process(cluster.getSolrClient());waitForState("Waiting for PRS property",@@ -255,8 +254,7 @@ public class PerReplicaStatesIntegrationTest extends SolrCloudTestCase {TimeUnit.SECONDS,collectionState ->"false".equals(collectionState.getProperties().get(PER_REPLICA_STATE)));- CollectionAdminRequest.modifyCollection(- COLL, Collections.singletonMap(PER_REPLICA_STATE, "true"))+ CollectionAdminRequest.modifyCollection(COLL, Map.of(PER_REPLICA_STATE, "true")).process(cluster.getSolrClient());waitForState("Waiting for PRS property",diff --git a/solr/solrj/src/test/org/apache/solr/common/util/TestJsonRecordReader.java b/solr/solrj/src/test/org/apache/solr/common/util/TestJsonRecordReader.javaindex 6c2280c273c..026c7e6b5ce 100644--- a/solr/solrj/src/test/org/apache/solr/common/util/TestJsonRecordReader.java+++ b/solr/solrj/src/test/org/apache/solr/common/util/TestJsonRecordReader.java@@ -20,7 +20,6 @@ import java.io.IOException;import java.io.StringReader;import java.lang.ref.WeakReference;import java.util.Arrays;-import java.util.Collections;import java.util.List;import java.util.Map;import java.util.concurrent.atomic.AtomicReference;@@ -178,7 +177,7 @@ public class TestJsonRecordReader extends SolrTestCaseJ4 {JsonRecordReader streamer;List<Map<String, Object>> records;- streamer = JsonRecordReader.getInst("/b", Collections.singletonList("/b/**"));+ streamer = JsonRecordReader.getInst("/b", List.of("/b/**"));records = streamer.getAllRecords(new StringReader(json));assertEquals(3, records.size());assertEquals("records " + records, 3l, ((Map) records.get(0)).get("t"));@@ -190,7 +189,7 @@ public class TestJsonRecordReader extends SolrTestCaseJ4 {assertNotNull("records " + records, record.get("d"));}- streamer = JsonRecordReader.getInst("/", Collections.singletonList("/**"));+ streamer = JsonRecordReader.getInst("/", List.of("/**"));records = streamer.getAllRecords(new StringReader(json));assertEquals(1, records.size());assertEquals(3, ((List) ((Map) records.get(0)).get("c")).size());@@ -222,7 +221,7 @@ public class TestJsonRecordReader extends SolrTestCaseJ4 {JsonRecordReader streamer;List<Map<String, Object>> records;- streamer = JsonRecordReader.getInst("/exams", Collections.singletonList("/**"));+ streamer = JsonRecordReader.getInst("/exams", List.of("/**"));records = streamer.getAllRecords(new StringReader(json));assertEquals(2, records.size());for (Map<String, Object> record : records) {@@ -232,7 +231,7 @@ public class TestJsonRecordReader extends SolrTestCaseJ4 {assertTrue(record.containsKey("marks"));}- streamer = JsonRecordReader.getInst("/exams", Collections.singletonList("$FQN:/**"));+ streamer = JsonRecordReader.getInst("/exams", List.of("$FQN:/**"));records = streamer.getAllRecords(new StringReader(json));assertEquals(2, records.size());for (Map<String, Object> record : records) {@@ -242,7 +241,7 @@ public class TestJsonRecordReader extends SolrTestCaseJ4 {assertTrue(record.containsKey("exams.marks"));}- streamer = JsonRecordReader.getInst("/", Collections.singletonList("txt:/**"));+ streamer = JsonRecordReader.getInst("/", List.of("txt:/**"));records = streamer.getAllRecords(new StringReader(json));assertEquals(1, records.size());assertEquals(9, ((List) records.get(0).get("txt")).size());@@ -307,7 +306,7 @@ public class TestJsonRecordReader extends SolrTestCaseJ4 {JsonRecordReader streamer;List<Map<String, Object>> records;- streamer = JsonRecordReader.getInst("/a/b", Collections.singletonList("title_s:/a/b/title"));+ streamer = JsonRecordReader.getInst("/a/b", List.of("title_s:/a/b/title"));records = streamer.getAllRecords(new StringReader(json));assertEquals(2, records.size());}@@ -335,7 +334,7 @@ public class TestJsonRecordReader extends SolrTestCaseJ4 {JsonRecordReader streamer;List<Map<String, Object>> records;- streamer = JsonRecordReader.getInst("/exams", Collections.singletonList("/**"));+ streamer = JsonRecordReader.getInst("/exams", List.of("/**"));records = streamer.getAllRecords(new StringReader(json));assertEquals(4, records.size());@@ -352,7 +351,7 @@ public class TestJsonRecordReader extends SolrTestCaseJ4 {List<Map<String, Object>> records;final AtomicReference<WeakReference<String>> ref = new AtomicReference<>();- streamer = JsonRecordReader.getInst("/", Collections.singletonList("$FQN:/**"));+ streamer = JsonRecordReader.getInst("/", List.of("$FQN:/**"));streamer.streamRecords(new StringReader(json),(record, path) -> {@@ -706,7 +705,7 @@ public class TestJsonRecordReader extends SolrTestCaseJ4 {+ " }}]}}]";RecordingJSONParser parser = new RecordingJSONParser(new StringReader(json));- JsonRecordReader recordReader = JsonRecordReader.getInst("/", Collections.singletonList("/**"));+ JsonRecordReader recordReader = JsonRecordReader.getInst("/", List.of("/**"));try {recordReader.streamRecords(parser, (record, path) -> {}); /*don't care*/} catch (RuntimeException e) {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.javaindex 1fbe1bcad14..08b77833ce6 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@@ -17,7 +17,6 @@package org.apache.solr.common.util;-import static java.util.Collections.singletonMap;import static org.apache.solr.api.ApiBag.HANDLER_NAME;import java.util.HashMap;@@ -33,7 +32,7 @@ public class TestPathTrie extends SolrTestCaseJ4 {pathTrie.insert("/", Map.of(), "R");pathTrie.insert("/aa", Map.of(), "d");pathTrie.insert("/aa/bb/{cc}/dd", Map.of(), "a");- pathTrie.insert("/$handlerName/{cc}/dd", singletonMap(HANDLER_NAME, "test"), "test");+ pathTrie.insert("/$handlerName/{cc}/dd", Map.of(HANDLER_NAME, "test"), "test");pathTrie.insert("/aa/bb/{cc}/{xx}", Map.of(), "b");pathTrie.insert("/aa/bb", Map.of(), "c");diff --git a/solr/test-framework/src/java/org/apache/solr/client/solrj/apache/HttpSolrClient.java b/solr/test-framework/src/java/org/apache/solr/client/solrj/apache/HttpSolrClient.javaindex e2a849cd4cf..04f58e00a61 100644--- a/solr/test-framework/src/java/org/apache/solr/client/solrj/apache/HttpSolrClient.java+++ b/solr/test-framework/src/java/org/apache/solr/client/solrj/apache/HttpSolrClient.java@@ -33,7 +33,6 @@ import java.util.ArrayList;import java.util.Arrays;import java.util.Base64;import java.util.Collection;-import java.util.Collections;import java.util.Iterator;import java.util.List;import java.util.Locale;@@ -105,7 +104,7 @@ public class HttpSolrClient extends SolrClient {private static final Charset FALLBACK_CHARSET = StandardCharsets.UTF_8;private static final long serialVersionUID = -946812319974801896L;- protected static final Set<Integer> UNMATCHED_ACCEPTED_ERROR_CODES = Collections.singleton(429);+ protected static final Set<Integer> UNMATCHED_ACCEPTED_ERROR_CODES = Set.of(429);static final String USER_AGENT ="Solr[" + MethodHandles.lookup().lookupClass().getName() + "] " + SolrVersion.LATEST_STRING;diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.javaindex 7f452aa4e61..d4b81d99ea6 100644--- a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java+++ b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java@@ -295,7 +295,7 @@ public abstract class AbstractFullDistribZkTestBase extends BaseDistributedSearc.getZkClient().create(ZkStateReader.CLUSTER_PROPS,- Utils.toJSON(Collections.singletonMap(URL_SCHEME, HTTPS)),+ Utils.toJSON(Map.of(URL_SCHEME, HTTPS)),CreateMode.PERSISTENT);} catch (KeeperException.NodeExistsException e) {ZkNodeProps props =@@ -2440,7 +2440,7 @@ public abstract class AbstractFullDistribZkTestBase extends BaseDistributedSearcint connectionTimeoutMillis,int socketTimeoutMillis) {RandomizingCloudSolrClientBuilder builder =- new RandomizingCloudSolrClientBuilder(Collections.singletonList(zkHost), Optional.empty());+ new RandomizingCloudSolrClientBuilder(List.of(zkHost), Optional.empty());if (shardLeadersOnly) {builder.sendUpdatesOnlyToShardLeaders();} else {diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.javaindex f2bbfb87f9b..62470e6913d 100644--- a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java+++ b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java@@ -699,8 +699,7 @@ public class MiniSolrCloudCluster implements SolrBackend {collectionName,k -> {CloudSolrClient solrClient =- new CloudLegacySolrClient.Builder(- Collections.singletonList(zkServer.getZkAddress()), Optional.empty())+ new CloudLegacySolrClient.Builder(List.of(zkServer.getZkAddress()), Optional.empty()).withDefaultCollection(collectionName).withSocketTimeout(90000).withConnectionTimeout(15000)@@ -721,7 +720,7 @@ public class MiniSolrCloudCluster implements SolrBackend {@Override // SolrBackendpublic CloudSolrClient newSolrClient(String collection) {return new CloudLegacySolrClient.Builder(- Collections.singletonList(getZkServer().getZkAddress()), Optional.empty())+ List.of(getZkServer().getZkAddress()), Optional.empty()).withSocketTimeout(90000, TimeUnit.MILLISECONDS).withConnectionTimeout(15000, TimeUnit.MILLISECONDS).withDefaultCollection(collection)diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudAuthTestCase.java b/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudAuthTestCase.javaindex afbe6becb8c..8ee2e5032c1 100644--- a/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudAuthTestCase.java+++ b/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudAuthTestCase.java@@ -28,7 +28,6 @@ import java.lang.invoke.MethodHandles;import java.util.ArrayList;import java.util.Arrays;import java.util.Base64;-import java.util.Collections;import java.util.HashMap;import java.util.List;import java.util.Map;@@ -66,7 +65,7 @@ public class SolrCloudAuthTestCase extends SolrCloudTestCase {private static final List<String> AUTH_METRICS_METER_KEYS =Arrays.asList("solr_authentication_errors", "count");private static final List<String> AUTH_METRICS_TIMER_KEYS =- Collections.singletonList("solr_authentication_request_times_nanoseconds");+ List.of("solr_authentication_request_times_nanoseconds");@SuppressWarnings({"rawtypes"})public static final Predicate NOT_NULL_PREDICATE = o -> o != null;diff --git a/solr/test-framework/src/java/org/apache/solr/handler/component/DummyCustomParamSpellChecker.java b/solr/test-framework/src/java/org/apache/solr/handler/component/DummyCustomParamSpellChecker.javaindex aa647814aa5..4c36106fd42 100644--- a/solr/test-framework/src/java/org/apache/solr/handler/component/DummyCustomParamSpellChecker.java+++ b/solr/test-framework/src/java/org/apache/solr/handler/component/DummyCustomParamSpellChecker.java@@ -54,7 +54,7 @@ public class DummyCustomParamSpellChecker extends SolrSpellChecker {int i = 0;for (String name : lst) {String value = options.customParams.get(name);- result.add(new Token(name, i, i + 1), Collections.singletonList(value));+ result.add(new Token(name, i, i + 1), List.of(value));i += 2;}return result;diff --git a/solr/test-framework/src/java/org/apache/solr/schema/SortableBinaryField.java b/solr/test-framework/src/java/org/apache/solr/schema/SortableBinaryField.javaindex 28edf725d14..430fa658aa9 100644--- a/solr/test-framework/src/java/org/apache/solr/schema/SortableBinaryField.java+++ b/solr/test-framework/src/java/org/apache/solr/schema/SortableBinaryField.java@@ -18,7 +18,6 @@ package org.apache.solr.schema;import java.nio.ByteBuffer;import java.util.ArrayList;-import java.util.Collections;import java.util.List;import org.apache.lucene.document.SortedDocValuesField;import org.apache.lucene.document.SortedSetDocValuesField;@@ -60,7 +59,7 @@ public class SortableBinaryField extends BinaryField {}return fields;} else {- return Collections.singletonList(createField(field, value));+ return List.of(createField(field, value));}}diff --git a/solr/test-framework/src/java/org/apache/solr/util/SecurityJson.java b/solr/test-framework/src/java/org/apache/solr/util/SecurityJson.javaindex 2b73b8fde19..3ee0e1b6662 100644--- a/solr/test-framework/src/java/org/apache/solr/util/SecurityJson.java+++ b/solr/test-framework/src/java/org/apache/solr/util/SecurityJson.java@@ -16,10 +16,9 @@*/package org.apache.solr.util;-import static java.util.Collections.singletonList;-import static java.util.Collections.singletonMap;import static org.apache.solr.security.Sha256AuthenticationProvider.getSaltedHashedValue;+import java.util.List;import java.util.Map;import org.apache.solr.common.util.Utils;import org.apache.solr.security.BasicAuthPlugin;@@ -48,9 +47,9 @@ public final class SecurityJson {"class",RuleBasedAuthorizationPlugin.class.getName(),"user-role",- singletonMap(USER, "admin"),+ Map.of(USER, "admin"),"permissions",- singletonList(Map.of("name", "all", "role", "admin"))),+ List.of(Map.of("name", "all", "role", "admin"))),"authentication",Map.of("class",@@ -58,5 +57,5 @@ public final class SecurityJson {"blockUnknown",true,"credentials",- singletonMap(USER, getSaltedHashedValue(PASS)))));+ Map.of(USER, getSaltedHashedValue(PASS)))));}