You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ep...@apache.org on 2026/03/17 11:33:22 UTC
(solr) branch main updated: SOLR-18139: Migrate away from Collections.empty*() methods. (#4168)
This is an automated email from the ASF dual-hosted git repository.
epugh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new 601f7411d47 SOLR-18139: Migrate away from Collections.empty*() methods. (#4168)
601f7411d47 is described below
commit 601f7411d47fe9ae75a90c4b61b0468a3c843031
Author: Eric Pugh <ep...@opensourceconnections.com>
AuthorDate: Tue Mar 17 07:33:16 2026 -0400
SOLR-18139: Migrate away from Collections.empty*() methods. (#4168)
Co-authored-by: Copilot <17...@users.noreply.github.com>
---
.../apache/lucene/missingdoclet/MissingDoclet.java | 7 ++---
gradle/validation/forbidden-apis/defaults.all.txt | 11 ++++++-
.../solr/bench/generators/RandomDataHistogram.java | 3 +-
solr/core/src/java/org/apache/solr/api/ApiBag.java | 4 +--
.../src/java/org/apache/solr/api/ApiSupport.java | 4 +--
.../apache/solr/api/ContainerPluginsRegistry.java | 3 +-
.../src/java/org/apache/solr/api/V2HttpCall.java | 3 +-
.../src/java/org/apache/solr/cloud/CloudUtil.java | 3 +-
.../solr/cloud/DistributedClusterStateUpdater.java | 7 +++--
.../org/apache/solr/cloud/ZkConfigSetService.java | 4 +--
.../org/apache/solr/cloud/ZkDistributedQueue.java | 3 +-
.../apache/solr/cloud/api/collections/Assign.java | 2 +-
.../solr/cloud/api/collections/BackupCmd.java | 10 +++----
.../cloud/api/collections/BalanceReplicasCmd.java | 3 +-
.../cloud/api/collections/CategoryRoutedAlias.java | 3 +-
.../solr/cloud/api/collections/CollApiCmds.java | 10 ++-----
.../api/collections/CollectionHandlingUtils.java | 6 ++--
.../cloud/api/collections/CreateCollectionCmd.java | 4 +--
.../cloud/api/collections/MigrateReplicasCmd.java | 2 +-
.../solr/cloud/api/collections/RestoreCmd.java | 3 +-
.../cloud/api/collections/TimeRoutedAlias.java | 4 +--
.../solr/cloud/overseer/CollectionMutator.java | 3 +-
.../cluster/events/ClusterEventProducerBase.java | 3 +-
.../placement/impl/AttributeFetcherImpl.java | 3 +-
.../placement/plugins/AffinityPlacementConfig.java | 7 +----
.../plugins/AffinityPlacementFactory.java | 2 +-
.../plugins/OrderedNodePlacementPlugin.java | 9 +++---
.../java/org/apache/solr/core/ConfigOverlay.java | 8 ++---
.../java/org/apache/solr/core/CoreContainer.java | 2 +-
.../src/java/org/apache/solr/core/CoreSorter.java | 13 ++++-----
.../solr/core/FileSystemConfigSetService.java | 2 +-
.../src/java/org/apache/solr/core/NodeConfig.java | 11 ++++---
.../src/java/org/apache/solr/core/PluginBag.java | 2 +-
.../src/java/org/apache/solr/core/PluginInfo.java | 9 +++---
.../java/org/apache/solr/core/RequestHandlers.java | 3 +-
.../java/org/apache/solr/core/RequestParams.java | 6 ++--
.../src/java/org/apache/solr/core/SolrConfig.java | 8 ++---
.../src/java/org/apache/solr/core/SolrCore.java | 6 ++--
.../src/java/org/apache/solr/core/SolrPaths.java | 2 +-
.../java/org/apache/solr/core/SolrXmlConfig.java | 4 +--
.../org/apache/solr/core/backup/BackupManager.java | 4 +--
.../core/snapshots/CollectionSnapshotMetaData.java | 4 +--
.../solr/handler/AnalysisRequestHandlerBase.java | 3 +-
.../java/org/apache/solr/handler/ClusterAPI.java | 4 +--
.../java/org/apache/solr/handler/IndexFetcher.java | 17 +++++------
.../apache/solr/handler/MoreLikeThisHandler.java | 3 +-
.../solr/handler/admin/BaseHandlerApiSupport.java | 3 +-
.../apache/solr/handler/admin/ClusterStatus.java | 12 ++++----
.../solr/handler/admin/CollectionsHandler.java | 4 +--
.../solr/handler/admin/SecurityConfHandler.java | 3 +-
.../solr/handler/admin/api/AliasProperty.java | 7 ++---
.../solr/handler/admin/api/ReplicationAPIBase.java | 3 +-
.../solr/handler/component/CloudReplicaSource.java | 2 +-
.../handler/component/CombinedQueryComponent.java | 3 +-
.../solr/handler/component/DebugComponent.java | 4 +--
.../solr/handler/component/FacetComponent.java | 20 ++++++-------
.../solr/handler/component/FieldFacetStats.java | 3 +-
.../component/PhrasesIdentificationComponent.java | 2 +-
.../apache/solr/handler/component/PivotFacet.java | 8 ++---
.../component/PivotFacetFieldValueCollection.java | 2 +-
.../handler/component/PivotFacetProcessor.java | 13 ++++-----
.../solr/handler/component/QueryComponent.java | 3 +-
.../handler/component/QueryElevationComponent.java | 20 +++++--------
.../handler/component/RangeFacetProcessor.java | 3 +-
.../handler/component/RealTimeGetComponent.java | 4 +--
.../solr/handler/component/SearchHandler.java | 3 +-
.../apache/solr/handler/component/ShardDoc.java | 3 +-
.../handler/component/ShardHandlerFactory.java | 5 ++--
.../handler/component/StandaloneReplicaSource.java | 3 +-
.../apache/solr/handler/component/StatsField.java | 8 ++---
.../apache/solr/handler/component/StatsInfo.java | 2 +-
.../handler/component/TermVectorComponent.java | 3 +-
.../solr/handler/configsets/UploadConfigSet.java | 4 +--
.../solr/handler/designer/ManagedSchemaDiff.java | 3 +-
.../solr/handler/designer/SchemaDesignerAPI.java | 7 ++---
.../designer/SchemaDesignerConfigSetHelper.java | 4 +--
.../handler/designer/SchemaDesignerSettings.java | 6 ++--
.../designer/SchemaDesignerSettingsDAO.java | 9 ++----
.../apache/solr/handler/loader/JavabinLoader.java | 3 +-
.../solr/highlight/DefaultSolrHighlighter.java | 2 +-
.../solr/highlight/UnifiedSolrHighlighter.java | 3 +-
.../org/apache/solr/metrics/SolrMetricManager.java | 4 +--
.../apache/solr/packagemanager/PackageManager.java | 23 ++++++---------
.../org/apache/solr/pkg/SolrPackageLoader.java | 2 +-
.../org/apache/solr/request/NumericFacets.java | 7 ++---
.../java/org/apache/solr/request/SimpleFacets.java | 4 +--
.../org/apache/solr/request/SolrQueryRequest.java | 5 ++--
.../apache/solr/request/SolrQueryRequestBase.java | 3 +-
.../solr/response/transform/DocTransformer.java | 7 ++---
.../response/transform/GeoTransformerFactory.java | 3 +-
.../solr/schema/AbstractSpatialFieldType.java | 4 +--
.../src/java/org/apache/solr/schema/FieldType.java | 2 +-
.../java/org/apache/solr/schema/IndexSchema.java | 8 ++---
.../org/apache/solr/schema/ManagedIndexSchema.java | 5 ++--
.../java/org/apache/solr/schema/PointField.java | 3 +-
.../java/org/apache/solr/schema/SchemaField.java | 2 +-
.../java/org/apache/solr/schema/SchemaManager.java | 6 ++--
.../src/java/org/apache/solr/search/BitDocSet.java | 4 +--
.../java/org/apache/solr/search/CaffeineCache.java | 6 ++--
.../src/java/org/apache/solr/search/DocSlice.java | 4 +--
.../solr/search/NumericHidingLeafReader.java | 3 +-
.../java/org/apache/solr/search/QueryUtils.java | 4 +--
.../org/apache/solr/search/SolrIndexSearcher.java | 3 +-
.../org/apache/solr/search/SolrReturnFields.java | 2 +-
.../org/apache/solr/search/SortSpecParsing.java | 3 +-
.../org/apache/solr/search/SortedIntDocSet.java | 3 +-
.../solr/search/facet/FacetFieldProcessor.java | 3 +-
.../org/apache/solr/search/facet/FacetMerger.java | 10 +++----
.../java/org/apache/solr/search/facet/SlotAcc.java | 3 +-
.../distance/GeoDistValueSourceParser.java | 3 +-
.../command/SearchGroupsFieldCommand.java | 3 +-
.../distributed/command/TopGroupsFieldCommand.java | 3 +-
.../apache/solr/search/join/FiltersQParser.java | 3 +-
.../apache/solr/search/stats/ExactStatsCache.java | 16 +++++-----
.../search/vector/AbstractVectorQParserBase.java | 5 ++--
.../apache/solr/security/AllowListUrlChecker.java | 4 +--
.../ExternalRoleRuleBasedAuthorizationPlugin.java | 3 +-
.../cert/PathBasedCertPrincipalResolver.java | 4 +--
.../security/cert/PathBasedCertResolverBase.java | 7 ++---
.../java/org/apache/solr/servlet/HttpSolrCall.java | 10 +++----
.../solr/spelling/AbstractLuceneSpellChecker.java | 7 ++---
.../solr/spelling/ConjunctionSolrSpellChecker.java | 3 +-
.../solr/spelling/DirectSolrSpellChecker.java | 5 ++--
.../solr/spelling/SpellingQueryConverter.java | 4 +--
.../solr/spelling/SuggestQueryConverter.java | 4 +--
.../solr/spelling/WordBreakSolrSpellChecker.java | 5 ++--
.../solr/spelling/suggest/SolrSuggester.java | 4 +--
.../org/apache/solr/update/SolrIndexConfig.java | 3 +-
.../AddSchemaFieldsUpdateProcessorFactory.java | 7 ++---
.../processor/AtomicUpdateDocumentMerger.java | 21 +++++++------
...DocBasedVersionConstraintsProcessorFactory.java | 3 +-
.../FieldMutatingUpdateProcessorFactory.java | 9 +++---
.../SkipExistingDocumentsProcessorFactory.java | 14 ++++-----
.../processor/TemplateUpdateProcessorFactory.java | 3 +-
.../processor/UpdateRequestProcessorChain.java | 3 +-
.../org/apache/solr/util/ConcurrentLRUCache.java | 4 +--
.../src/java/org/apache/solr/util/ModuleUtils.java | 6 ++--
.../apache/solr/analysis/TokenizerChainTest.java | 8 ++---
.../src/test/org/apache/solr/cli/PostToolTest.java | 4 +--
.../org/apache/solr/cloud/CollectionPropsTest.java | 3 +-
.../solr/cloud/FullSolrCloudDistribCmdsTest.java | 4 +--
.../org/apache/solr/cloud/MigrateReplicasTest.java | 5 ++--
.../test/org/apache/solr/cloud/NodeRolesTest.java | 8 ++---
.../OverseerCollectionConfigSetProcessorTest.java | 2 +-
.../test/org/apache/solr/cloud/OverseerTest.java | 4 +--
.../org/apache/solr/cloud/TestConfigSetsAPI.java | 3 +-
.../apache/solr/cloud/TestRandomFlRTGCloud.java | 2 +-
.../solr/cloud/TriLevelCompositeIdRoutingTest.java | 3 +-
.../apache/solr/cloud/UnloadDistributedZkTest.java | 4 +--
.../VMParamsZkACLAndCredentialsProvidersTest.java | 5 ++--
.../org/apache/solr/cloud/ZkControllerTest.java | 4 +--
.../SimpleCollectionCreateDeleteTest.java | 3 +-
.../cloud/overseer/TestClusterStateMutator.java | 9 ++----
.../plugins/AffinityPlacementFactoryTest.java | 2 +-
.../test/org/apache/solr/core/CoreSorterTest.java | 2 +-
.../org/apache/solr/core/TestConfLoadPerf.java | 6 +---
.../src/test/org/apache/solr/core/TestConfig.java | 8 ++---
.../org/apache/solr/core/TestConfigOverlay.java | 3 +-
.../apache/solr/core/TestConfigSetProperties.java | 3 +-
.../solr/core/snapshots/TestSolrCoreSnapshots.java | 3 +-
.../handler/FieldAnalysisRequestHandlerTest.java | 5 ++--
.../TestReplicationHandlerDiskOverFlow.java | 6 +---
.../solr/handler/V2ClusterAPIMappingTest.java | 3 +-
.../solr/handler/V2UpdateAPIMappingTest.java | 3 +-
.../solr/handler/admin/TestApiFramework.java | 6 ++--
.../solr/handler/admin/TestCollectionAPIs.java | 5 ++--
.../solr/handler/admin/V2ApiMappingTest.java | 3 +-
.../handler/admin/ZookeeperStatusHandlerTest.java | 2 +-
.../handler/admin/api/MigrateReplicasAPITest.java | 6 ++--
.../handler/admin/api/V2NodeAPIMappingTest.java | 3 +-
.../component/ParallelHttpShardHandlerTest.java | 2 +-
.../PhrasesIdentificationComponentTest.java | 3 +-
.../handler/designer/ManagedSchemaDiffTest.java | 4 +--
.../handler/designer/TestSchemaDesignerAPI.java | 6 ++--
.../TestSchemaDesignerConfigSetHelper.java | 6 ++--
.../designer/TestSchemaDesignerSettingsDAO.java | 5 ++--
.../apache/solr/legacy/TestLegacyNumericUtils.java | 7 ++---
.../solr/packagemanager/TestPackageManager.java | 4 +--
.../solr/response/TestRetrieveFieldsOptimizer.java | 2 +-
.../test/org/apache/solr/schema/DateFieldTest.java | 4 +--
.../org/apache/solr/schema/TestManagedSchema.java | 3 +-
.../org/apache/solr/schema/TestPointFields.java | 10 +++----
.../org/apache/solr/search/LargeFieldTest.java | 3 +-
.../search/SignificantTermsQParserPluginTest.java | 7 ++---
.../solr/search/TestAddFieldRealTimeGet.java | 4 +--
.../solr/search/TestFiltersQueryCaching.java | 3 +-
.../org/apache/solr/search/TestSearcherReuse.java | 5 ++--
.../apache/solr/search/TestSolrQueryParser.java | 3 +-
.../src/test/org/apache/solr/search/ThinCache.java | 3 +-
.../search/facet/TestCloudJSONFacetJoinDomain.java | 3 +-
.../solr/search/facet/TestCloudJSONFacetSKG.java | 3 +-
.../search/facet/TestCloudJSONFacetSKGEquiv.java | 12 ++++----
.../solr/search/join/ShardToShardJoinAbstract.java | 4 +--
.../solr/security/AllowListUrlCheckerTest.java | 6 ++--
.../BaseTestRuleBasedAuthorizationPlugin.java | 12 ++++----
.../apache/solr/security/CertAuthPluginTest.java | 4 +--
.../PathBasedCertPrincipalResolverTest.java | 13 ++++-----
.../solr/update/DeleteByIdWithRouterFieldTest.java | 3 +-
.../test/org/apache/solr/update/PeerSyncTest.java | 2 +-
.../solr/update/TestInPlaceUpdatesDistrib.java | 2 +-
.../solr/update/TestNestedUpdateProcessor.java | 7 ++---
.../TimeRoutedAliasUpdateProcessorTest.java | 4 +--
.../test/org/apache/solr/util/ModuleUtilsTest.java | 6 ++--
.../manager/consumer/KafkaCrossDcConsumerTest.java | 2 +-
.../clustering/EchoClusteringAlgorithm.java | 3 +-
.../clustering/MockClusteringAlgorithm.java | 3 +-
.../extraction/ExtractingDocumentLoader.java | 4 +--
.../handler/extraction/ExtractionMetadata.java | 3 +-
.../handler/extraction/SolrContentHandler.java | 3 +-
.../extraction/fromtika/ToXMLContentHandler.java | 3 +-
.../TikaServerExtractionBackendTest.java | 3 +-
.../apache/solr/security/jwt/JWTAuthPlugin.java | 4 +--
...angDetectLanguageIdentifierUpdateProcessor.java | 5 ++--
.../java/org/apache/solr/ltr/LTRScoringQuery.java | 3 +-
.../LTRFeatureLoggerTransformerFactory.java | 9 +-----
.../apache/solr/ltr/model/TestWrapperModel.java | 34 ++++++----------------
.../org/apache/solr/handler/sql/SolrTable.java | 12 +-------
.../client/solrj/io/eval/ListCacheEvaluator.java | 4 +--
.../io/stream/eval/MovingAverageEvaluatorTest.java | 4 +--
.../solrj/impl/ZkClientClusterStateProvider.java | 5 ++--
.../client/solrj/impl/ZkDistribStateManager.java | 5 ++--
.../solr/common/cloud/ClusterProperties.java | 3 +-
.../solr/common/cloud/CollectionProperties.java | 3 +-
.../cloud/CollectionPropertiesZkStateReader.java | 4 +--
.../common/cloud/DefaultZkCredentialsInjector.java | 3 +-
.../solr/common/cloud/PerReplicaStatesOps.java | 6 ++--
.../solr/common/cloud/SecurityNodeWatcher.java | 6 ++--
.../apache/solr/common/cloud/ZkStateReader.java | 19 ++++++------
.../solrj/impl/BaseHttpClusterStateProvider.java | 6 ++--
.../solr/client/solrj/impl/CloudSolrClient.java | 4 +--
.../solrj/impl/DelegatingClusterStateProvider.java | 6 ++--
.../solr/client/solrj/request/ApiMapping.java | 4 +--
.../solr/client/solrj/request/SolrQuery.java | 2 +-
.../apache/solr/client/solrj/response/Cluster.java | 9 +++---
.../client/solrj/response/ClusteringResponse.java | 5 ++--
.../solrj/response/CollectionAdminResponse.java | 5 ++--
.../solr/client/solrj/response/FacetField.java | 3 +-
.../solr/client/solrj/response/LukeResponse.java | 3 +-
.../src/java/org/apache/solr/common/MapWriter.java | 3 +-
.../java/org/apache/solr/common/cloud/Aliases.java | 11 ++++---
.../org/apache/solr/common/cloud/ClusterState.java | 4 +--
.../solr/common/cloud/CompositeIdRouter.java | 2 +-
.../org/apache/solr/common/cloud/DocRouter.java | 3 +-
.../apache/solr/common/cloud/HashBasedRouter.java | 3 +-
.../apache/solr/common/cloud/PerReplicaStates.java | 3 +-
.../java/org/apache/solr/common/cloud/Slice.java | 2 +-
.../apache/solr/common/util/CommandOperation.java | 9 +++---
.../java/org/apache/solr/common/util/PathTrie.java | 6 ++--
.../java/org/apache/solr/common/util/StrUtils.java | 3 +-
.../java/org/apache/solr/common/util/Utils.java | 4 +--
.../apache/solr/common/util/ValidatingJsonMap.java | 2 +-
.../solrj/impl/CloudSolrClientCacheTest.java | 4 +--
.../org/apache/solr/common/SolrDocumentTest.java | 2 +-
.../solr/common/util/TestFastJavabinDecoder.java | 4 +--
.../org/apache/solr/common/util/TestPathTrie.java | 16 +++++-----
.../component/TrackingShardHandlerFactory.java | 3 +-
256 files changed, 543 insertions(+), 772 deletions(-)
diff --git a/build-tools/missing-doclet/src/main/java/org/apache/lucene/missingdoclet/MissingDoclet.java b/build-tools/missing-doclet/src/main/java/org/apache/lucene/missingdoclet/MissingDoclet.java
index 14487731f6f..823e86d21b8 100644
--- a/build-tools/missing-doclet/src/main/java/org/apache/lucene/missingdoclet/MissingDoclet.java
+++ b/build-tools/missing-doclet/src/main/java/org/apache/lucene/missingdoclet/MissingDoclet.java
@@ -25,7 +25,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
-import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
@@ -65,8 +64,8 @@ public class MissingDoclet extends StandardDoclet {
DocletEnvironment docEnv;
DocTrees docTrees;
Elements elementUtils;
- Set<String> ignored = Collections.emptySet();
- Set<String> methodPackages = Collections.emptySet();
+ Set<String> ignored = Set.of();
+ Set<String> methodPackages = Set.of();
@Override
public Set<Doclet.Option> getSupportedOptions() {
@@ -373,7 +372,7 @@ public class MissingDoclet extends StandardDoclet {
clazz.getInterfaces().stream()
.filter(tm -> tm.getKind() == TypeKind.DECLARED)
.map(tm -> ((DeclaredType) tm).asElement())
- .collect(Collectors.toList());
+ .toList();
Stream<Element> result = interfaces.stream();
result = Stream.concat(result, interfaces.stream().flatMap(this::superTypeForInheritDoc));
diff --git a/gradle/validation/forbidden-apis/defaults.all.txt b/gradle/validation/forbidden-apis/defaults.all.txt
index f5ca3ae746f..eeab02a0dca 100644
--- a/gradle/validation/forbidden-apis/defaults.all.txt
+++ b/gradle/validation/forbidden-apis/defaults.all.txt
@@ -54,6 +54,15 @@ java.io.File#delete() @ use Files.delete for real exception, IOUtils.deleteFiles
java.util.Collections#shuffle(java.util.List) @ Use shuffle(List, Random) instead so that it can be reproduced
+@defaultMessage Use List.of()
+java.util.Collections#emptyList()
+
+@defaultMessage Use Set.of()
+java.util.Collections#emptySet()
+
+@defaultMessage Use Map.of()
+java.util.Collections#emptyMap()
+
java.util.Locale#forLanguageTag(java.lang.String) @ use new Locale.Builder().setLanguageTag(...).build() which has error handling
java.util.Locale#toString() @ use Locale#toLanguageTag() for a standardized BCP47 locale name
@@ -102,4 +111,4 @@ java.nio.file.Paths#get(**)
java.nio.file.Path#startsWith(java.lang.String)
@defaultMessage Use NIO Path instead of File
-java.io.File
\ No newline at end of file
+java.io.File
diff --git a/solr/benchmark/src/java/org/apache/solr/bench/generators/RandomDataHistogram.java b/solr/benchmark/src/java/org/apache/solr/bench/generators/RandomDataHistogram.java
index 8cd55a7964a..41a7e8a439b 100644
--- a/solr/benchmark/src/java/org/apache/solr/bench/generators/RandomDataHistogram.java
+++ b/solr/benchmark/src/java/org/apache/solr/bench/generators/RandomDataHistogram.java
@@ -23,7 +23,6 @@ import java.math.MathContext;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;
@@ -509,7 +508,7 @@ public class RandomDataHistogram {
}
return Integer.compare(e2.getValue().get(), e1.getValue().get());
})
- .filter(entry -> !entry.getKey().equals(Collections.emptyList()))
+ .filter(entry -> !entry.getKey().equals(List.of()))
.map(
entry -> {
double percentage = entry.getValue().get() * 100.0 / sum;
diff --git a/solr/core/src/java/org/apache/solr/api/ApiBag.java b/solr/core/src/java/org/apache/solr/api/ApiBag.java
index 26688037c21..89cf2796084 100644
--- a/solr/core/src/java/org/apache/solr/api/ApiBag.java
+++ b/solr/core/src/java/org/apache/solr/api/ApiBag.java
@@ -75,13 +75,13 @@ public class ApiBag {
public synchronized List<Api> registerObject(Object o) {
List<Api> l = AnnotatedApi.getApis(o);
for (Api api : l) {
- register(api, Collections.emptyMap());
+ register(api, Map.of());
}
return l;
}
public synchronized void register(Api api) {
- register(api, Collections.emptyMap());
+ register(api, Map.of());
}
public synchronized void register(Api api, Map<String, String> nameSubstitutes) {
diff --git a/solr/core/src/java/org/apache/solr/api/ApiSupport.java b/solr/core/src/java/org/apache/solr/api/ApiSupport.java
index efeffcad773..f77ed256932 100644
--- a/solr/core/src/java/org/apache/solr/api/ApiSupport.java
+++ b/solr/core/src/java/org/apache/solr/api/ApiSupport.java
@@ -18,7 +18,7 @@
package org.apache.solr.api;
import java.util.Collection;
-import java.util.Collections;
+import java.util.Set;
/** The interface that is implemented by a request handler to support the V2 end point */
public interface ApiSupport {
@@ -36,7 +36,7 @@ public interface ApiSupport {
* @see #getApis()
*/
default Collection<Class<? extends JerseyResource>> getJerseyResources() {
- return Collections.emptySet();
+ return Set.of();
}
/** Whether this should be made available at the regular legacy path */
diff --git a/solr/core/src/java/org/apache/solr/api/ContainerPluginsRegistry.java b/solr/core/src/java/org/apache/solr/api/ContainerPluginsRegistry.java
index 20cd2440bbe..5f6a2e5a088 100644
--- a/solr/core/src/java/org/apache/solr/api/ContainerPluginsRegistry.java
+++ b/solr/core/src/java/org/apache/solr/api/ContainerPluginsRegistry.java
@@ -31,7 +31,6 @@ import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -424,7 +423,7 @@ public class ContainerPluginsRegistry implements ClusterPropertiesListener, MapW
throw new RuntimeException("Must have a no-arg constructor or CoreContainer constructor ");
}
Map<String, Object> config =
- (Map<String, Object>) holder.original.getOrDefault("config", Collections.emptyMap());
+ (Map<String, Object>) holder.original.getOrDefault("config", Map.of());
configure(instance, config, holder.meta);
if (instance instanceof ResourceLoaderAware) {
try {
diff --git a/solr/core/src/java/org/apache/solr/api/V2HttpCall.java b/solr/core/src/java/org/apache/solr/api/V2HttpCall.java
index f8a9daa2389..04ea7c6ee9e 100644
--- a/solr/core/src/java/org/apache/solr/api/V2HttpCall.java
+++ b/solr/core/src/java/org/apache/solr/api/V2HttpCall.java
@@ -29,7 +29,6 @@ import jakarta.servlet.http.HttpServletResponse;
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.LinkedHashMap;
@@ -488,7 +487,7 @@ public class V2HttpCall extends HttpSolrCall {
// myColName -> collection
final Map<String, String> pathTemplateValKey;
if (pathTemplateKeyVal.isEmpty()) { // typical
- pathTemplateValKey = Collections.emptyMap();
+ pathTemplateValKey = Map.of();
} else if (pathTemplateKeyVal.size() == 1) { // typical
Map.Entry<String, String> entry = pathTemplateKeyVal.entrySet().iterator().next();
pathTemplateValKey = Map.of(entry.getValue(), entry.getKey());
diff --git a/solr/core/src/java/org/apache/solr/cloud/CloudUtil.java b/solr/core/src/java/org/apache/solr/cloud/CloudUtil.java
index 7b3300379e9..91ffff8d4ba 100644
--- a/solr/core/src/java/org/apache/solr/cloud/CloudUtil.java
+++ b/solr/core/src/java/org/apache/solr/cloud/CloudUtil.java
@@ -18,7 +18,6 @@ package org.apache.solr.cloud;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -136,7 +135,7 @@ public class CloudUtil {
}
} catch (KeeperException.NoNodeException e) {
log.info("Error fetching key names");
- return Collections.emptyMap();
+ return Map.of();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new SolrException(ErrorCode.SERVER_ERROR, "Unable to read crypto keys", e);
diff --git a/solr/core/src/java/org/apache/solr/cloud/DistributedClusterStateUpdater.java b/solr/core/src/java/org/apache/solr/cloud/DistributedClusterStateUpdater.java
index f64b71dba04..6d686e13d79 100644
--- a/solr/core/src/java/org/apache/solr/cloud/DistributedClusterStateUpdater.java
+++ b/solr/core/src/java/org/apache/solr/cloud/DistributedClusterStateUpdater.java
@@ -26,6 +26,7 @@ import java.time.Instant;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import java.util.Optional;
import java.util.Set;
import org.apache.solr.client.solrj.cloud.SolrCloudManager;
@@ -387,7 +388,7 @@ public class DistributedClusterStateUpdater {
// For now trying to diverge as little as possible from existing data structures and code
// given the need to support both the old way (Overseer) and new way (distributed) of handling
// cluster state update.
- final Set<String> liveNodes = Collections.emptySet();
+ final Set<String> liveNodes = Set.of();
// Per Replica States updates are done before all other updates and not subject to the number
// of attempts of CAS made here, given they have their own CAS strategy and implementation
@@ -412,7 +413,7 @@ public class DistributedClusterStateUpdater {
// state. Knowing about all collections in the cluster might not be needed.
ClusterState initialClusterState;
if (updater.isCollectionCreation()) {
- initialClusterState = new ClusterState(liveNodes, Collections.emptyMap());
+ initialClusterState = new ClusterState(liveNodes, Map.of());
} else {
// Get the state for existing data in ZK (and if no data exists we should fail)
initialClusterState = fetchStateForCollection();
@@ -586,7 +587,7 @@ public class DistributedClusterStateUpdater {
ZkClientClusterStateProvider.createFromJsonSupportingLegacyConfigName(
stat.getVersion(),
data,
- Collections.emptySet(),
+ Set.of(),
updater.getCollectionName(),
zkStateReader.getZkClient(),
Instant.ofEpochMilli(stat.getCtime()));
diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkConfigSetService.java b/solr/core/src/java/org/apache/solr/cloud/ZkConfigSetService.java
index 12cfbc48617..99b4fb2d675 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ZkConfigSetService.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ZkConfigSetService.java
@@ -234,7 +234,7 @@ public class ZkConfigSetService extends ConfigSetService {
Utils.fromJSON(zkClient.getData(CONFIGS_ZKNODE + "/" + configName, null, null));
return data;
} catch (KeeperException.NoNodeException e) {
- return Collections.emptyMap();
+ return Map.of();
} catch (KeeperException | InterruptedException e) {
throw new IOException("Error getting config metadata", SolrZkClient.checkInterrupted(e));
}
@@ -261,7 +261,7 @@ public class ZkConfigSetService extends ConfigSetService {
try {
return zkClient.getChildren(CONFIGS_ZKNODE, null);
} catch (KeeperException.NoNodeException e) {
- return Collections.emptyList();
+ return List.of();
} catch (KeeperException | InterruptedException e) {
throw new IOException("Error listing configs", SolrZkClient.checkInterrupted(e));
}
diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkDistributedQueue.java b/solr/core/src/java/org/apache/solr/cloud/ZkDistributedQueue.java
index ca27ab37bd8..ec312447d44 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ZkDistributedQueue.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ZkDistributedQueue.java
@@ -21,7 +21,6 @@ import com.google.common.annotations.VisibleForTesting;
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.Map;
@@ -345,7 +344,7 @@ public class ZkDistributedQueue implements DistributedQueue {
@Override
public Map<String, Object> getStats() {
if (stats == null) {
- return Collections.emptyMap();
+ return Map.of();
}
Map<String, Object> res = new HashMap<>();
res.put("queueLength", stats.getQueueLength());
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.java
index 13caeea36ec..4c260c9ab9e 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
@@ -398,7 +398,7 @@ public class Assign {
default Map<Replica, String> computeReplicaBalancing(
SolrCloudManager solrCloudManager, Set<String> nodes, int maxBalanceSkew)
throws AssignmentException, IOException, InterruptedException {
- return Collections.emptyMap();
+ return Map.of();
}
/**
diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/BackupCmd.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/BackupCmd.java
index 04b2a1417bb..f1ee97f58db 100644
--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/BackupCmd.java
+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/BackupCmd.java
@@ -26,10 +26,10 @@ import java.lang.invoke.MethodHandles;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+import java.util.Set;
import org.apache.solr.cloud.api.collections.CollectionHandlingUtils.ShardRequestTracker;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
@@ -168,7 +168,7 @@ public class BackupCmd implements CollApiCmds.CollectionApiCommand {
backupMgr.downloadConfigDir(configName, cc.getConfigSetService());
}
- // Save the collection's state. Can be part of the monolithic clusterstate.json or a
+ // Save the collection's state. Can be part of the monolithic clusterstate.json or an
// individual state.json. Since we don't want to distinguish we extract the state and back it
// up as a separate json
DocCollection collectionState =
@@ -285,7 +285,7 @@ public class BackupCmd implements CollApiCmds.CollectionApiCommand {
x.getState() != State.DOWN && snapshotMeta.isSnapshotExists(slice.getName(), x))
.findFirst();
- if (!r.isPresent()) {
+ if (r.isEmpty()) {
throw new SolrException(
ErrorCode.SERVER_ERROR,
"Unable to find any live replica with a snapshot named "
@@ -462,7 +462,7 @@ public class BackupCmd implements CollApiCmds.CollectionApiCommand {
SolrZkClient zkClient = ccc.getZkStateReader().getZkClient();
snapshotMeta =
SolrSnapshotManager.getCollectionLevelSnapshot(zkClient, collectionName, commitName);
- if (!snapshotMeta.isPresent()) {
+ if (snapshotMeta.isEmpty()) {
throw new SolrException(
ErrorCode.BAD_REQUEST,
"Snapshot with name "
@@ -488,7 +488,7 @@ public class BackupCmd implements CollApiCmds.CollectionApiCommand {
backupName,
backupPath);
- Collection<String> shardsToConsider = Collections.emptySet();
+ Collection<String> shardsToConsider = Set.of();
if (snapshotMeta.isPresent()) {
shardsToConsider = snapshotMeta.get().getShards();
}
diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/BalanceReplicasCmd.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/BalanceReplicasCmd.java
index 9d1acfb27b5..743d9f5847f 100644
--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/BalanceReplicasCmd.java
+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/BalanceReplicasCmd.java
@@ -18,7 +18,6 @@
package org.apache.solr.cloud.api.collections;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -43,7 +42,7 @@ public class BalanceReplicasCmd implements CollApiCmds.CollectionApiCommand {
Set<String> nodes;
Object nodesRaw = message.get(CollectionParams.NODES);
if (nodesRaw == null) {
- nodes = Collections.emptySet();
+ nodes = Set.of();
} else if (nodesRaw instanceof Set) {
nodes = (Set<String>) nodesRaw;
} else if (nodesRaw instanceof Collection) {
diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/CategoryRoutedAlias.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/CategoryRoutedAlias.java
index b9b7f1afca7..c787fdc80ce 100644
--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/CategoryRoutedAlias.java
+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/CategoryRoutedAlias.java
@@ -21,7 +21,6 @@ import static org.apache.solr.common.SolrException.ErrorCode.BAD_REQUEST;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -260,7 +259,7 @@ public class CategoryRoutedAlias extends RoutedAlias {
}
return actionList;
} else {
- return Collections.emptyList();
+ return List.of();
}
}
}
diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/CollApiCmds.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/CollApiCmds.java
index 3840683d6ef..ab8a8c58e4c 100644
--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/CollApiCmds.java
+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/CollApiCmds.java
@@ -70,10 +70,10 @@ import static org.apache.solr.common.params.CommonParams.NAME;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.context.Context;
import java.lang.invoke.MethodHandles;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
+import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.apache.solr.cloud.DistributedClusterStateUpdater;
@@ -275,13 +275,7 @@ public class CollApiCmds {
params.set(CoreAdminParams.ACTION, CoreAdminParams.CoreAdminAction.RELOAD.toString());
CollectionHandlingUtils.collectionCmd(
- adminCmdContext,
- message,
- params,
- results,
- Replica.State.ACTIVE,
- Collections.emptySet(),
- ccc);
+ adminCmdContext, message, params, results, Replica.State.ACTIVE, Set.of(), ccc);
}
}
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.java
index b51562aa5ff..f5e030d81e5 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
@@ -237,7 +237,7 @@ public class CollectionHandlingUtils {
parentShardLeader.getName(),
updateResponse,
slice,
- Collections.emptySet(),
+ Set.of(),
null);
} catch (Exception e) {
CollectionHandlingUtils.processResponse(
@@ -247,7 +247,7 @@ public class CollectionHandlingUtils {
parentShardLeader.getCoreName(),
updateResponse,
slice,
- Collections.emptySet(),
+ Set.of(),
null);
throw new SolrException(
SolrException.ErrorCode.SERVER_ERROR,
@@ -742,7 +742,7 @@ public class CollectionHandlingUtils {
ShardHandler shardHandler,
boolean abortOnError,
String msgOnError) {
- processResponses(results, shardHandler, abortOnError, msgOnError, Collections.emptySet());
+ processResponses(results, shardHandler, abortOnError, msgOnError, Set.of());
}
void processResponses(
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.java
index ff2d92378f3..bc70f3bc955 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
@@ -39,6 +39,7 @@ import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Objects;
+import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
@@ -415,8 +416,7 @@ public class CreateCollectionCmd implements CollApiCmds.CollectionApiCommand {
nodeName, replicas.get(e.getKey()).getCoreName(), params, shardHandler);
}
- shardRequestTracker.processResponses(
- results, shardHandler, false, null, Collections.emptySet());
+ shardRequestTracker.processResponses(results, shardHandler, false, null, Set.of());
boolean failure =
results.get("failure") != null
&& ((SimpleOrderedMap<?>) results.get("failure")).size() > 0;
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.java
index e4381ad888e..a45a64f4697 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
@@ -134,7 +134,7 @@ public class MigrateReplicasCmd implements CollApiCmds.CollectionApiCommand {
protected Set<String> getNodesFromParam(ZkNodeProps message, String paramName) {
Object rawParam = message.get(paramName);
if (rawParam == null) {
- return Collections.emptySet();
+ return Set.of();
} else if (rawParam instanceof Set) {
return (Set<String>) rawParam;
} else if (rawParam instanceof Collection) {
diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/RestoreCmd.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/RestoreCmd.java
index 93df952eb27..c4ef360fa58 100644
--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/RestoreCmd.java
+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/RestoreCmd.java
@@ -34,7 +34,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.List;
import java.util.Locale;
@@ -369,7 +368,7 @@ public class RestoreCmd implements CollApiCmds.CollectionApiCommand {
backupSlice.getName(),
new Slice(
backupSlice.getName(),
- Collections.emptyMap(),
+ Map.of(),
backupSlice.getProperties(),
restoreCollectionName));
}
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.java
index 8d8a85d105e..fd8b1cab552 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
@@ -590,7 +590,7 @@ public class TimeRoutedAlias extends RoutedAlias {
private List<Action> calcDeletes(List<Action> actions) {
final String autoDeleteAgeMathStr = this.getAutoDeleteAgeMath();
if (autoDeleteAgeMathStr == null || actions.size() == 0) {
- return Collections.emptyList();
+ return List.of();
}
if (actions.size() > 1) {
throw new IllegalStateException(
@@ -675,7 +675,7 @@ public class TimeRoutedAlias extends RoutedAlias {
String nextCol = calcNextCollection(parsed);
return Collections.singletonList(new Action(this, ActionType.ENSURE_EXISTS, nextCol));
} else {
- return Collections.emptyList();
+ return List.of();
}
}
diff --git a/solr/core/src/java/org/apache/solr/cloud/overseer/CollectionMutator.java b/solr/core/src/java/org/apache/solr/cloud/overseer/CollectionMutator.java
index 879a440ccf9..1cf36d87f15 100644
--- a/solr/core/src/java/org/apache/solr/cloud/overseer/CollectionMutator.java
+++ b/solr/core/src/java/org/apache/solr/cloud/overseer/CollectionMutator.java
@@ -22,7 +22,6 @@ import static org.apache.solr.common.cloud.ZkStateReader.REPLICATION_FACTOR;
import static org.apache.solr.common.params.CollectionAdminParams.COLL_CONF;
import java.lang.invoke.MethodHandles;
-import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -63,7 +62,7 @@ public class CollectionMutator {
DocCollection collection = clusterState.getCollection(collectionName);
Slice slice = collection.getSlice(shardId);
if (slice == null) {
- Map<String, Replica> replicas = Collections.emptyMap();
+ Map<String, Replica> replicas = Map.of();
Map<String, Object> sliceProps = new HashMap<>();
String shardRange = message.getStr(ZkStateReader.SHARD_RANGE_PROP);
String shardState = message.getStr(ZkStateReader.SHARD_STATE_PROP);
diff --git a/solr/core/src/java/org/apache/solr/cluster/events/ClusterEventProducerBase.java b/solr/core/src/java/org/apache/solr/cluster/events/ClusterEventProducerBase.java
index 6a92ceab140..ee16baf41fe 100644
--- a/solr/core/src/java/org/apache/solr/cluster/events/ClusterEventProducerBase.java
+++ b/solr/core/src/java/org/apache/solr/cluster/events/ClusterEventProducerBase.java
@@ -18,7 +18,6 @@ package org.apache.solr.cluster.events;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
-import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -96,7 +95,7 @@ public abstract class ClusterEventProducerBase implements ClusterEventProducer {
protected void fireEvent(ClusterEvent event) {
synchronized (listeners) {
listeners
- .getOrDefault(event.getType(), Collections.emptySet())
+ .getOrDefault(event.getType(), Set.of())
.forEach(
listener -> {
if (log.isDebugEnabled()) {
diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/impl/AttributeFetcherImpl.java b/solr/core/src/java/org/apache/solr/cluster/placement/impl/AttributeFetcherImpl.java
index a8c918cb32c..2aa4203f91a 100644
--- a/solr/core/src/java/org/apache/solr/cluster/placement/impl/AttributeFetcherImpl.java
+++ b/solr/core/src/java/org/apache/solr/cluster/placement/impl/AttributeFetcherImpl.java
@@ -17,7 +17,6 @@
package org.apache.solr.cluster.placement.impl;
-import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -46,7 +45,7 @@ public class AttributeFetcherImpl implements AttributeFetcher {
Set<NodeMetric<?>> requestedNodeMetricSnitchTags = new HashSet<>();
Map<SolrCollection, Set<ReplicaMetric<?>>> requestedCollectionMetrics = new HashMap<>();
- Set<Node> nodes = Collections.emptySet();
+ Set<Node> nodes = Set.of();
private final SolrCloudManager cloudManager;
diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/plugins/AffinityPlacementConfig.java b/solr/core/src/java/org/apache/solr/cluster/placement/plugins/AffinityPlacementConfig.java
index ae285dcacb2..8faa95f2e78 100644
--- a/solr/core/src/java/org/apache/solr/cluster/placement/plugins/AffinityPlacementConfig.java
+++ b/solr/core/src/java/org/apache/solr/cluster/placement/plugins/AffinityPlacementConfig.java
@@ -187,12 +187,7 @@ public class AffinityPlacementConfig implements PlacementPluginConfig {
long prioritizedFreeDiskGB,
Map<String, String> withCollection,
Map<String, String> collectionNodeType) {
- this(
- minimalFreeDiskGB,
- prioritizedFreeDiskGB,
- withCollection,
- Collections.emptyMap(),
- collectionNodeType);
+ this(minimalFreeDiskGB, prioritizedFreeDiskGB, withCollection, Map.of(), collectionNodeType);
}
public void validate() {
diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/plugins/AffinityPlacementFactory.java b/solr/core/src/java/org/apache/solr/cluster/placement/plugins/AffinityPlacementFactory.java
index 12f86137e5d..61057525802 100644
--- a/solr/core/src/java/org/apache/solr/cluster/placement/plugins/AffinityPlacementFactory.java
+++ b/solr/core/src/java/org/apache/solr/cluster/placement/plugins/AffinityPlacementFactory.java
@@ -337,7 +337,7 @@ public class AffinityPlacementFactory implements PlacementPluginFactory<Affinity
Optional<String> nodePropOpt =
attrValues.getSystemProperty(node, AffinityPlacementConfig.NODE_TYPE_SYSPROP);
if (nodePropOpt.isEmpty()) {
- nodeType = Collections.emptySet();
+ nodeType = Set.of();
} else {
nodeType = new HashSet<>(StrUtils.splitSmart(nodePropOpt.get(), ','));
}
diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/plugins/OrderedNodePlacementPlugin.java b/solr/core/src/java/org/apache/solr/cluster/placement/plugins/OrderedNodePlacementPlugin.java
index 9d2741315fa..8eaaa13089e 100644
--- a/solr/core/src/java/org/apache/solr/cluster/placement/plugins/OrderedNodePlacementPlugin.java
+++ b/solr/core/src/java/org/apache/solr/cluster/placement/plugins/OrderedNodePlacementPlugin.java
@@ -21,7 +21,6 @@ import java.lang.invoke.MethodHandles;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
@@ -439,13 +438,13 @@ public abstract class OrderedNodePlacementPlugin implements PlacementPlugin {
}
public Set<String> getShardsOnNode(String collection) {
- return replicas.getOrDefault(collection, Collections.emptyMap()).keySet();
+ return replicas.getOrDefault(collection, Map.of()).keySet();
}
public Set<Replica> getReplicasForShardOnNode(Shard shard) {
return Optional.ofNullable(replicas.get(shard.getCollection().getName()))
.map(m -> m.get(shard.getShardName()))
- .orElseGet(Collections::emptySet);
+ .orElseGet(Set::of);
}
public abstract int calcWeight();
@@ -499,7 +498,7 @@ public abstract class OrderedNodePlacementPlugin implements PlacementPlugin {
* removed.
*/
public Map<Replica, String> canRemoveReplicas(Collection<Replica> replicas) {
- return Collections.emptyMap();
+ return Map.of();
}
public final void removeReplica(Replica replica) {
@@ -884,7 +883,7 @@ public abstract class OrderedNodePlacementPlugin implements PlacementPlugin {
.map(Map::keySet)
// Use a sorted TreeSet to make sure that tests are repeatable
.<Collection<Replica.ReplicaType>>map(TreeSet::new)
- .orElseGet(Collections::emptyList);
+ .orElseGet(List::of);
}
/**
diff --git a/solr/core/src/java/org/apache/solr/core/ConfigOverlay.java b/solr/core/src/java/org/apache/solr/core/ConfigOverlay.java
index 811ea865cd6..480df900f83 100644
--- a/solr/core/src/java/org/apache/solr/core/ConfigOverlay.java
+++ b/solr/core/src/java/org/apache/solr/core/ConfigOverlay.java
@@ -41,13 +41,13 @@ public class ConfigOverlay implements MapSerializable {
@SuppressWarnings({"unchecked"})
public ConfigOverlay(Map<String, Object> jsonObj, int version) {
- if (jsonObj == null) jsonObj = Collections.emptyMap();
+ if (jsonObj == null) jsonObj = Map.of();
this.version = version;
data = Collections.unmodifiableMap(jsonObj);
props = (Map<String, Object>) data.get("props");
- if (props == null) props = Collections.emptyMap();
+ if (props == null) props = Map.of();
userProps = (Map<String, Object>) data.get("userProps");
- if (userProps == null) userProps = Collections.emptyMap();
+ if (userProps == null) userProps = Map.of();
}
public Object getXPathProperty(String xpath) {
@@ -242,7 +242,7 @@ public class ConfigOverlay implements MapSerializable {
@SuppressWarnings({"unchecked"})
public Map<String, Map<String, Object>> getNamedPlugins(String typ) {
Map<String, Map<String, Object>> reqHandlers = (Map<String, Map<String, Object>>) data.get(typ);
- if (reqHandlers == null) return Collections.emptyMap();
+ if (reqHandlers == null) return Map.of();
return Collections.unmodifiableMap(reqHandlers);
}
diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
index a19f77a2e23..9ca9b377cb2 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -799,7 +799,7 @@ public class CoreContainer {
Map<String, CacheConfig> cachesConfig = cfg.getCachesConfig();
if (cachesConfig.isEmpty()) {
- this.caches = Collections.emptyMap();
+ this.caches = Map.of();
} else {
Map<String, SolrCache<?, ?>> m = CollectionUtil.newHashMap(cachesConfig.size());
for (Map.Entry<String, CacheConfig> e : cachesConfig.entrySet()) {
diff --git a/solr/core/src/java/org/apache/solr/core/CoreSorter.java b/solr/core/src/java/org/apache/solr/core/CoreSorter.java
index a21e64948e9..d717bc4514a 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreSorter.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreSorter.java
@@ -17,7 +17,6 @@
package org.apache.solr.core;
-import static java.util.Collections.emptyList;
import static java.util.stream.Collectors.toList;
import java.util.Collection;
@@ -47,7 +46,7 @@ public class CoreSorter {
if (c1 == null) c1 = zero; // just to avoid NPE
if (c2 == null) c2 = zero;
if (c1.totalReplicasInDownNodes < c2.totalReplicasInDownNodes) {
- // Prioritize replicas with least no:of down nodes waiting.
+ // Prioritize replicas with the least number of down nodes waiting.
// It's better to bring up a node that is a member of a shard
// with 0 down nodes than 1 down node because it will make the shard
// complete earlier and avoid waiting by the other live nodes
@@ -64,9 +63,9 @@ public class CoreSorter {
}
}
- // Prioritize replicas where most no:of other nodes are waiting for
- // For example if 1 other replicas are waiting for this replica, then
- // prioritize that over the replica were zero other nodes are waiting
+ // Prioritize replicas where the greatest number of other nodes are waiting.
+ // For example, if one other replica is waiting for this replica, then
+ // prioritize that over a replica where zero other nodes are waiting
if (c1.totalReplicasInLiveNodes > c2.totalReplicasInLiveNodes) return -1;
if (c2.totalReplicasInLiveNodes > c1.totalReplicasInLiveNodes) return 1;
@@ -176,9 +175,9 @@ public class CoreSorter {
/** Return all replicas for a given collection+slice combo */
private Collection<Replica> getReplicas(ClusterState cs, String coll, String slice) {
DocCollection c = cs.getCollectionOrNull(coll);
- if (c == null) return emptyList();
+ if (c == null) return List.of();
Slice s = c.getSlice(slice);
- if (s == null) return emptyList();
+ if (s == null) return List.of();
return s.getReplicas();
}
}
diff --git a/solr/core/src/java/org/apache/solr/core/FileSystemConfigSetService.java b/solr/core/src/java/org/apache/solr/core/FileSystemConfigSetService.java
index 3d31349c066..811e6d91fee 100644
--- a/solr/core/src/java/org/apache/solr/core/FileSystemConfigSetService.java
+++ b/solr/core/src/java/org/apache/solr/core/FileSystemConfigSetService.java
@@ -206,7 +206,7 @@ public class FileSystemConfigSetService extends ConfigSetService {
try {
data = Files.readAllBytes(metadataPath);
} catch (NoSuchFileException e) {
- return Collections.emptyMap();
+ return Map.of();
}
@SuppressWarnings("unchecked")
Map<String, Object> metadata = (Map<String, Object>) Utils.fromJSON(data);
diff --git a/solr/core/src/java/org/apache/solr/core/NodeConfig.java b/solr/core/src/java/org/apache/solr/core/NodeConfig.java
index ad69e6d90f4..c52cb54e60e 100644
--- a/solr/core/src/java/org/apache/solr/core/NodeConfig.java
+++ b/solr/core/src/java/org/apache/solr/core/NodeConfig.java
@@ -22,7 +22,6 @@ import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
-import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
@@ -187,7 +186,7 @@ public class NodeConfig {
this.solrProperties = solrProperties;
this.backupRepositoryPlugins = backupRepositoryPlugins;
this.metricsConfig = metricsConfig;
- this.cachesConfig = cachesConfig == null ? Collections.emptyMap() : cachesConfig;
+ this.cachesConfig = cachesConfig == null ? Map.of() : cachesConfig;
this.tracerConfig = tracerConfig;
this.clusterPlugins = clusterPlugins;
this.defaultZkHost = defaultZkHost;
@@ -581,7 +580,7 @@ public class NodeConfig {
private UpdateShardHandlerConfig updateShardHandlerConfig = UpdateShardHandlerConfig.DEFAULT;
private String configSetServiceClass;
private String coreAdminHandlerClass = DEFAULT_ADMINHANDLERCLASS;
- private Map<String, String> coreAdminHandlerActions = Collections.emptyMap();
+ private Map<String, String> coreAdminHandlerActions = Map.of();
private String collectionsAdminHandlerClass = DEFAULT_COLLECTIONSHANDLERCLASS;
private String healthCheckHandlerClass = DEFAULT_HEALTHCHECKHANDLERCLASS;
private String infoHandlerClass = DEFAULT_INFOHANDLERCLASS;
@@ -599,8 +598,8 @@ public class NodeConfig {
private PluginInfo tracerConfig;
private PluginInfo[] clusterPlugins;
private String defaultZkHost;
- private Set<Path> allowPaths = Collections.emptySet();
- private List<String> allowUrls = Collections.emptyList();
+ private Set<Path> allowPaths = Set.of();
+ private List<String> allowUrls = List.of();
private boolean hideStackTrace =
!EnvUtils.getPropertyAsBool("solr.responses.stacktrace.enabled", true);
@@ -845,7 +844,7 @@ public class NodeConfig {
hiddenSysProps = fromProps;
}
}
- Set<String> hiddenSysPropSet = Collections.emptySet();
+ Set<String> hiddenSysPropSet = Set.of();
if (hiddenSysProps != null) {
hiddenSysPropSet =
StrUtils.splitSmart(hiddenSysProps, ',').stream()
diff --git a/solr/core/src/java/org/apache/solr/core/PluginBag.java b/solr/core/src/java/org/apache/solr/core/PluginBag.java
index 1af3445e7aa..5583546e22f 100644
--- a/solr/core/src/java/org/apache/solr/core/PluginBag.java
+++ b/solr/core/src/java/org/apache/solr/core/PluginBag.java
@@ -142,7 +142,7 @@ public class PluginBag<T> implements AutoCloseable {
/** Check if any of the mentioned names are missing. If yes, return the Set of missing names */
public Set<String> checkContains(Collection<String> names) {
- if (names == null || names.isEmpty()) return Collections.emptySet();
+ if (names == null || names.isEmpty()) return Set.of();
HashSet<String> result = new HashSet<>();
for (String s : names) if (!this.registry.containsKey(s)) result.add(s);
return result;
diff --git a/solr/core/src/java/org/apache/solr/core/PluginInfo.java b/solr/core/src/java/org/apache/solr/core/PluginInfo.java
index 6ad137b0e09..1cd80713b44 100644
--- a/solr/core/src/java/org/apache/solr/core/PluginInfo.java
+++ b/solr/core/src/java/org/apache/solr/core/PluginInfo.java
@@ -24,7 +24,6 @@ import static org.apache.solr.schema.FieldType.CLASS_NAME;
import com.google.common.annotations.VisibleForTesting;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
@@ -59,7 +58,7 @@ public class PluginInfo implements MapSerializable {
}
}
attributes = unmodifiableMap(attrs);
- this.children = children == null ? Collections.emptyList() : unmodifiableList(children);
+ this.children = children == null ? List.of() : unmodifiableList(children);
isFromSolrConfig = false;
}
@@ -148,7 +147,7 @@ public class PluginInfo implements MapSerializable {
// TODO This is not type-safe and needs to be fixed -
// https://issues.apache.org/jira/browse/SOLR-14696
attributes = unmodifiableMap(m);
- this.children = Collections.emptyList();
+ this.children = List.of();
isFromSolrConfig = true;
}
@@ -162,7 +161,7 @@ public class PluginInfo implements MapSerializable {
if (pluginInfo.isEnabled()) children.add(pluginInfo);
return null;
});
- return children.isEmpty() ? Collections.emptyList() : unmodifiableList(children);
+ return children.isEmpty() ? List.of() : unmodifiableList(children);
}
@Override
@@ -230,7 +229,7 @@ public class PluginInfo implements MapSerializable {
}
public static final PluginInfo EMPTY_INFO =
- new PluginInfo("", Collections.emptyMap(), new NamedList<>(), Collections.emptyList());
+ new PluginInfo("", Map.of(), new NamedList<>(), List.of());
private static final HashSet<String> NL_TAGS =
new HashSet<>(asList("lst", "arr", "bool", "str", "int", "long", "float", "double"));
diff --git a/solr/core/src/java/org/apache/solr/core/RequestHandlers.java b/solr/core/src/java/org/apache/solr/core/RequestHandlers.java
index 39f043d95f9..415d305e49b 100644
--- a/solr/core/src/java/org/apache/solr/core/RequestHandlers.java
+++ b/solr/core/src/java/org/apache/solr/core/RequestHandlers.java
@@ -18,7 +18,6 @@ package org.apache.solr.core;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -116,7 +115,7 @@ public final class RequestHandlers {
for (PluginInfo info : infos) {
modifiedInfos.add(applyInitParams(config, info));
}
- handlers.init(Collections.emptyMap(), core, modifiedInfos);
+ handlers.init(Map.of(), core, modifiedInfos);
if (log.isDebugEnabled()) {
log.debug("Registered paths: {}", StrUtils.join(new ArrayList<>(handlers.keySet()), ','));
diff --git a/solr/core/src/java/org/apache/solr/core/RequestParams.java b/solr/core/src/java/org/apache/solr/core/RequestParams.java
index c5b37d19768..f0b491c84a0 100644
--- a/solr/core/src/java/org/apache/solr/core/RequestParams.java
+++ b/solr/core/src/java/org/apache/solr/core/RequestParams.java
@@ -47,7 +47,7 @@ public class RequestParams implements MapSerializable {
private final int znodeVersion;
public RequestParams(Map<String, Object> data, int znodeVersion) {
- if (data == null) data = Collections.emptyMap();
+ if (data == null) data = Map.of();
this.data = data;
Map<?, ?> paramsets = (Map<?, ?>) data.get(NAME);
if (paramsets != null) {
@@ -151,7 +151,7 @@ public class RequestParams implements MapSerializable {
stat == null ? "" : stat.getVersion());
}
if (stat == null) {
- requestParams = new RequestParams(Collections.emptyMap(), -1);
+ requestParams = new RequestParams(Map.of(), -1);
} else if (requestParams == null || stat.getVersion() > requestParams.getZnodeVersion()) {
Object[] o = getMapAndVersion(loader, RequestParams.RESOURCE);
@SuppressWarnings("unchecked")
@@ -193,7 +193,7 @@ public class RequestParams implements MapSerializable {
} catch (IOException e) {
// no problem no overlay.json file
- return new Object[] {Collections.emptyMap(), -1};
+ return new Object[] {Map.of(), -1};
}
}
diff --git a/solr/core/src/java/org/apache/solr/core/SolrConfig.java b/solr/core/src/java/org/apache/solr/core/SolrConfig.java
index 797276d862a..1bbe7a9f807 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrConfig.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrConfig.java
@@ -517,7 +517,7 @@ public class SolrConfig implements MapSerializable {
this.clazz = clz;
this.tag = tag;
- this.options = opts == null ? Collections.emptySet() : EnumSet.of(NOOP, opts);
+ this.options = opts == null ? Set.of() : EnumSet.of(NOOP, opts);
}
public String getCleanTag() {
@@ -539,7 +539,7 @@ public class SolrConfig implements MapSerializable {
// TODO: we should be explicitly looking for file not found exceptions
// and logging if it's not the expected IOException
// hopefully no problem, assume no overlay.json file
- return new ConfigOverlay(Collections.emptyMap(), -1);
+ return new ConfigOverlay(Map.of(), -1);
}
int version = 0;
@@ -564,7 +564,7 @@ public class SolrConfig implements MapSerializable {
}
}
- private Map<String, InitParams> initParams = Collections.emptyMap();
+ private Map<String, InitParams> initParams = Map.of();
public Map<String, InitParams> getInitParams() {
return initParams;
@@ -901,7 +901,7 @@ public class SolrConfig implements MapSerializable {
result = new ArrayList<>(map.values());
}
}
- return result == null ? Collections.emptyList() : result;
+ return result == null ? List.of() : result;
}
public PluginInfo getPluginInfo(String type) {
diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.java
index c936dda686f..93699357426 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java
@@ -1150,7 +1150,7 @@ public class SolrCore implements SolrInfoBean, Closeable {
valueSourceParsers.init(ValueSourceParser.standardValueSourceParsers, this);
transformerFactories.init(TransformerFactory.defaultFactories, this);
loadSearchComponents();
- updateProcessors.init(Collections.emptyMap(), this);
+ updateProcessors.init(Map.of(), this);
// Processors initialized before the handlers
updateProcessorChains = loadUpdateProcessorChains();
@@ -3231,7 +3231,7 @@ public class SolrCore implements SolrInfoBean, Closeable {
* @return The instances initialized
*/
public <T> List<T> initPlugins(List<PluginInfo> pluginInfos, Class<T> type, String defClassName) {
- if (pluginInfos.isEmpty()) return Collections.emptyList();
+ if (pluginInfos.isEmpty()) return List.of();
List<T> result = new ArrayList<>(pluginInfos.size());
for (PluginInfo info : pluginInfos)
result.add(createInitInstance(info, type, type.getSimpleName(), defClassName));
@@ -3623,7 +3623,7 @@ public class SolrCore implements SolrInfoBean, Closeable {
}
public static List<PluginInfo> getImplicitPlugins(String type) {
- return ALL_IMPLICIT_PLUGINS.getOrDefault(type, Collections.emptyList());
+ return ALL_IMPLICIT_PLUGINS.getOrDefault(type, List.of());
}
}
diff --git a/solr/core/src/java/org/apache/solr/core/SolrPaths.java b/solr/core/src/java/org/apache/solr/core/SolrPaths.java
index 1855b0fe205..8918a321d06 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrPaths.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrPaths.java
@@ -143,7 +143,7 @@ public final class SolrPaths {
}
public Set<Path> build() {
- return paths == null ? Collections.emptySet() : paths;
+ return paths == null ? Set.of() : paths;
}
}
}
diff --git a/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java b/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java
index f58286f172f..14e87a52701 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java
@@ -394,14 +394,14 @@ public class SolrXmlConfig {
private static List<String> separateStrings(String commaSeparatedString) {
if (StrUtils.isNullOrEmpty(commaSeparatedString)) {
- return Collections.emptyList();
+ return List.of();
}
return Arrays.asList(COMMA_SEPARATED_PATTERN.split(commaSeparatedString));
}
private static Set<Path> separatePaths(String commaSeparatedString) {
if (StrUtils.isNullOrEmpty(commaSeparatedString)) {
- return Collections.emptySet();
+ return Set.of();
}
// Parse the list of paths. The special values '*' and '_ALL_' mean all paths.
String[] pathStrings = COMMA_SEPARATED_PATTERN.split(commaSeparatedString);
diff --git a/solr/core/src/java/org/apache/solr/core/backup/BackupManager.java b/solr/core/src/java/org/apache/solr/core/backup/BackupManager.java
index 403dd589b0f..2525bc36ad8 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
@@ -29,6 +29,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Objects;
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.SolrException;
@@ -224,8 +225,7 @@ public class BackupManager {
is.readBytes(arr, 0, (int) is.length());
// set a default created date, we don't aim at reading actual zookeeper state. The restored
// collection will have a new creation date when persisted in zookeeper.
- ClusterState c_state =
- ClusterState.createFromJson(-1, arr, Collections.emptySet(), Instant.EPOCH, null);
+ ClusterState c_state = ClusterState.createFromJson(-1, arr, Set.of(), Instant.EPOCH, null);
return c_state.getCollection(collectionName);
}
}
diff --git a/solr/core/src/java/org/apache/solr/core/snapshots/CollectionSnapshotMetaData.java b/solr/core/src/java/org/apache/solr/core/snapshots/CollectionSnapshotMetaData.java
index 483170db598..b3b3476ac3d 100644
--- a/solr/core/src/java/org/apache/solr/core/snapshots/CollectionSnapshotMetaData.java
+++ b/solr/core/src/java/org/apache/solr/core/snapshots/CollectionSnapshotMetaData.java
@@ -18,7 +18,6 @@ package org.apache.solr.core.snapshots;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.LinkedHashMap;
@@ -125,8 +124,7 @@ public class CollectionSnapshotMetaData implements JSONWriter.Writable {
private final List<CoreSnapshotMetaData> replicaSnapshots;
public CollectionSnapshotMetaData(String name) {
- this(
- name, SnapshotStatus.InProgress, new Date(), Collections.<CoreSnapshotMetaData>emptyList());
+ this(name, SnapshotStatus.InProgress, new Date(), List.of());
}
public CollectionSnapshotMetaData(
diff --git a/solr/core/src/java/org/apache/solr/handler/AnalysisRequestHandlerBase.java b/solr/core/src/java/org/apache/solr/handler/AnalysisRequestHandlerBase.java
index ed3bc83ccd2..5820879c06b 100644
--- a/solr/core/src/java/org/apache/solr/handler/AnalysisRequestHandlerBase.java
+++ b/solr/core/src/java/org/apache/solr/handler/AnalysisRequestHandlerBase.java
@@ -21,7 +21,6 @@ import java.io.Reader;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
@@ -63,7 +62,7 @@ import org.apache.solr.schema.FieldType;
*/
public abstract class AnalysisRequestHandlerBase extends RequestHandlerBase {
- public static final Set<BytesRef> EMPTY_BYTES_SET = Collections.emptySet();
+ public static final Set<BytesRef> EMPTY_BYTES_SET = Set.of();
@Override
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
diff --git a/solr/core/src/java/org/apache/solr/handler/ClusterAPI.java b/solr/core/src/java/org/apache/solr/handler/ClusterAPI.java
index 4807e19aca2..dd7a3a6e383 100644
--- a/solr/core/src/java/org/apache/solr/handler/ClusterAPI.java
+++ b/solr/core/src/java/org/apache/solr/handler/ClusterAPI.java
@@ -95,7 +95,7 @@ public class ClusterAPI {
if (children != null && !children.isEmpty()) {
result = new HashMap<>();
} else {
- return Collections.emptySet();
+ return Set.of();
}
for (String child : children) {
Object c = readRecursive(path + "/" + child, zk, depth - 1);
@@ -190,7 +190,7 @@ public class ClusterAPI {
try {
return zk.listData(ZkStateReader.NODE_ROLES + "/" + role + "/" + mode);
} catch (NoSuchElementException e) {
- return Collections.emptyList();
+ return List.of();
}
}
diff --git a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
index d83c581a2c4..63656b5866b 100644
--- a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
+++ b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
@@ -381,7 +381,7 @@ public class IndexFetcher {
List<Map<String, Object>> files = (List<Map<String, Object>>) response.get(CMD_GET_FILE_LIST);
if (files != null) filesToDownload = Collections.synchronizedList(files);
else {
- filesToDownload = Collections.emptyList();
+ filesToDownload = List.of();
log.error("No files to download for index generation: {}", gen);
}
@@ -1473,7 +1473,7 @@ public class IndexFetcher {
return Files.walk(dir).filter(Files::isRegularFile).collect(Collectors.toList());
} catch (IOException e) {
log.warn("Could not walk file tree", e);
- return Collections.emptyList();
+ return List.of();
}
}
@@ -1532,8 +1532,7 @@ public class IndexFetcher {
*/
private Collection<Map<String, Object>> getModifiedConfFiles(
List<Map<String, Object>> confFilesToDownload) {
- if (confFilesToDownload == null || confFilesToDownload.isEmpty())
- return Collections.emptyList();
+ if (confFilesToDownload == null || confFilesToDownload.isEmpty()) return List.of();
// build a map with alias/name as the key
Map<String, Map<String, Object>> nameVsFile = new HashMap<>();
NamedList<String> names = new NamedList<>();
@@ -1555,7 +1554,7 @@ public class IndexFetcher {
nameVsFile.remove(name); // checksums are same so the file need not be downloaded
}
}
- return nameVsFile.isEmpty() ? Collections.emptyList() : nameVsFile.values();
+ return nameVsFile.isEmpty() ? List.of() : nameVsFile.values();
}
static boolean delTree(Path dir) {
@@ -1600,25 +1599,25 @@ public class IndexFetcher {
// make a copy first because it can be null later
List<Map<String, Object>> tmp = confFilesToDownload;
// create a new instance. or else iterator may fail
- return tmp == null ? Collections.emptyList() : new ArrayList<>(tmp);
+ return tmp == null ? List.of() : new ArrayList<>(tmp);
}
List<Map<String, Object>> getConfFilesDownloaded() {
// make a copy first because it can be null later
List<Map<String, Object>> tmp = confFilesDownloaded;
// NOTE: it's safe to make a copy of a SynchronizedCollection(ArrayList)
- return tmp == null ? Collections.emptyList() : new ArrayList<>(tmp);
+ return tmp == null ? List.of() : new ArrayList<>(tmp);
}
List<Map<String, Object>> getFilesToDownload() {
// make a copy first because it can be null later
List<Map<String, Object>> tmp = filesToDownload;
- return tmp == null ? Collections.emptyList() : new ArrayList<>(tmp);
+ return tmp == null ? List.of() : new ArrayList<>(tmp);
}
List<Map<String, Object>> getFilesDownloaded() {
List<Map<String, Object>> tmp = filesDownloaded;
- return tmp == null ? Collections.emptyList() : new ArrayList<>(tmp);
+ return tmp == null ? List.of() : new ArrayList<>(tmp);
}
// TODO: currently does not reflect conf files
diff --git a/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java b/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java
index 10931705906..684250e35d5 100644
--- a/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java
@@ -221,8 +221,7 @@ public class MoreLikeThisHandler extends RequestHandlerBase {
if (mltDocs.docSet == null) {
rsp.add("facet_counts", null);
} else {
- final ResponseBuilder responseBuilder =
- new ResponseBuilder(req, rsp, Collections.emptyList());
+ final ResponseBuilder responseBuilder = new ResponseBuilder(req, rsp, List.of());
responseBuilder.setQuery(mlt.getRealMLTQuery());
SimpleFacets f = new SimpleFacets(req, mltDocs.docSet, params, responseBuilder);
FacetComponent.FacetContext.initContext(responseBuilder);
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/BaseHandlerApiSupport.java b/solr/core/src/java/org/apache/solr/handler/admin/BaseHandlerApiSupport.java
index 459f0486441..ed1fdbebfeb 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
@@ -108,8 +108,7 @@ public abstract class BaseHandlerApiSupport implements ApiSupport {
}
}
}
- wrapParams(
- req, new CommandOperation("", Collections.emptyMap()), commands.get(0), true);
+ wrapParams(req, new CommandOperation("", Map.of()), commands.get(0), true);
commands.get(0).invoke(req, rsp, apiHandler);
}
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/ClusterStatus.java b/solr/core/src/java/org/apache/solr/handler/admin/ClusterStatus.java
index 3bda1f7ddc4..cbc45803d80 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/ClusterStatus.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/ClusterStatus.java
@@ -18,7 +18,6 @@ package org.apache.solr.handler.admin;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -137,14 +136,14 @@ public class ClusterStatus {
if (withClusterProperties) {
Map<String, Object> clusterProps = zkStateReader.getClusterProperties();
if (clusterProps == null) {
- clusterProps = Collections.emptyMap();
+ clusterProps = Map.of();
}
clusterStatus.add("properties", clusterProps);
}
// add the roles map
if (withRoles) {
- Map<?, ?> roles = Collections.emptyMap();
+ Map<?, ?> roles = Map.of();
if (zkStateReader.getZkClient().exists(ZkStateReader.ROLES)) {
roles =
(Map<?, ?>)
@@ -314,14 +313,13 @@ public class ClusterStatus {
public static Map<String, Object> postProcessCollectionJSON(Map<String, Object> collection) {
final Map<String, Map<String, Object>> shards =
collection != null
- ? (Map<String, Map<String, Object>>)
- collection.getOrDefault("shards", Collections.emptyMap())
- : Collections.emptyMap();
+ ? (Map<String, Map<String, Object>>) collection.getOrDefault("shards", Map.of())
+ : Map.of();
final List<Health> healthStates = new ArrayList<>(shards.size());
shards.forEach(
(shardName, s) -> {
final Map<String, Map<String, Object>> replicas =
- (Map<String, Map<String, Object>>) s.getOrDefault("replicas", Collections.emptyMap());
+ (Map<String, Map<String, Object>>) s.getOrDefault("replicas", Map.of());
int[] totalVsActive = new int[2];
boolean hasLeader = false;
for (Map<String, Object> r : replicas.values()) {
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
index 946559e5016..0fa337f6362 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
@@ -106,7 +106,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.Iterator;
import java.util.LinkedHashMap;
@@ -1410,7 +1409,6 @@ public class CollectionsHandler extends RequestHandlerBase implements Permission
/** Copy all params to the given map or if the given map is null create a new one */
static Map<String, Object> copy(
SolrParams source, Map<String, Object> sink, String... paramNames) {
- return copy(
- source, sink, paramNames == null ? Collections.emptyList() : Arrays.asList(paramNames));
+ return copy(source, sink, paramNames == null ? List.of() : Arrays.asList(paramNames));
}
}
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandler.java
index 0f3cc35d062..315397f3e4e 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandler.java
@@ -23,7 +23,6 @@ import java.io.InputStream;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -214,7 +213,7 @@ public abstract class SecurityConfHandler extends RequestHandlerBase
* object defaults to EMPTY_MAP if not set
*/
public static class SecurityConfig {
- private Map<String, Object> data = Collections.emptyMap();
+ private Map<String, Object> data = Map.of();
private int version = -1;
public SecurityConfig() {}
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/api/AliasProperty.java b/solr/core/src/java/org/apache/solr/handler/admin/api/AliasProperty.java
index 077c7ee4217..923df2196c7 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/api/AliasProperty.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/api/AliasProperty.java
@@ -21,7 +21,6 @@ import static org.apache.solr.security.PermissionNameProvider.Name.COLL_EDIT_PER
import static org.apache.solr.security.PermissionNameProvider.Name.COLL_READ_PERM;
import jakarta.inject.Inject;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.apache.solr.client.api.endpoint.AliasPropertyApis;
@@ -144,11 +143,11 @@ public class AliasProperty extends AdminAPIBase implements AliasPropertyApis {
private static final String PROPERTIES = "property";
private void modifyAliasProperty(
- SolrJerseyResponse response, String alias, String proertyName, Object value)
+ SolrJerseyResponse response, String alias, String propertyName, Object value)
throws Exception {
Map<String, Object> props = new HashMap<>();
// value can be null
- props.put(proertyName, value);
+ props.put(propertyName, value);
fetchAndValidateZooKeeperAwareCoreContainer();
submitRemoteMessageAndHandleException(
@@ -168,7 +167,7 @@ public class AliasProperty extends AdminAPIBase implements AliasPropertyApis {
// Note: success/no-op in the event of no properties supplied is intentional. Keeps code
// simple and one less case for api-callers to check for.
if (properties == null) {
- properties = Collections.emptyMap();
+ properties = Map.of();
}
fetchAndValidateZooKeeperAwareCoreContainer();
submitRemoteMessageAndHandleAsync(
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/api/ReplicationAPIBase.java b/solr/core/src/java/org/apache/solr/handler/admin/api/ReplicationAPIBase.java
index 10f0e1bd785..88bf15ca471 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/api/ReplicationAPIBase.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/api/ReplicationAPIBase.java
@@ -28,7 +28,6 @@ import java.nio.channels.SeekableByteChannel;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.regex.Pattern;
@@ -140,7 +139,7 @@ public abstract class ReplicationAPIBase extends JerseyResource {
if (generation == -1) {
commit = delPol.getAndSaveLatestCommit();
if (null == commit) {
- filesResponse.fileList = Collections.emptyList();
+ filesResponse.fileList = List.of();
return filesResponse;
}
} else {
diff --git a/solr/core/src/java/org/apache/solr/handler/component/CloudReplicaSource.java b/solr/core/src/java/org/apache/solr/handler/component/CloudReplicaSource.java
index 5e333c8e6d3..836d0951f06 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/CloudReplicaSource.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/CloudReplicaSource.java
@@ -160,7 +160,7 @@ class CloudReplicaSource implements ReplicaSource {
if (slice == null) {
// Treat this the same as "all servers down" for a slice, and let things continue
// if partial results are acceptable
- return Collections.emptyList();
+ return List.of();
} else {
final Predicate<Replica> isShardLeader =
new IsLeaderPredicate(
diff --git a/solr/core/src/java/org/apache/solr/handler/component/CombinedQueryComponent.java b/solr/core/src/java/org/apache/solr/handler/component/CombinedQueryComponent.java
index ef51c30e575..9831281d2b2 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/CombinedQueryComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/CombinedQueryComponent.java
@@ -22,7 +22,6 @@ import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
@@ -277,7 +276,7 @@ public class CombinedQueryComponent extends QueryComponent implements SolrCoreAw
.filter(field -> !field.equals(SolrReturnFields.SCORE))
.collect(Collectors.toSet());
} else {
- scoreDependentFields = Collections.emptySet();
+ scoreDependentFields = Set.of();
}
IndexSchema schema = rb.req.getSchema();
diff --git a/solr/core/src/java/org/apache/solr/handler/component/DebugComponent.java b/solr/core/src/java/org/apache/solr/handler/component/DebugComponent.java
index 3fb01bd7da6..70dd1a401f2 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/DebugComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/DebugComponent.java
@@ -357,9 +357,9 @@ public class DebugComponent extends SearchComponent {
}
if (didx == -1) {
- tmp.add(skey, merge(sval, null, Collections.emptySet()));
+ tmp.add(skey, merge(sval, null, Set.of()));
} else {
- dl.setVal(didx, merge(sval, dl.getVal(didx), Collections.emptySet()));
+ dl.setVal(didx, merge(sval, dl.getVal(didx), Set.of()));
}
}
dl.addAll(tmp);
diff --git a/solr/core/src/java/org/apache/solr/handler/component/FacetComponent.java b/solr/core/src/java/org/apache/solr/handler/component/FacetComponent.java
index 5db8fc02a9c..5ac1d177e6b 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/FacetComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/FacetComponent.java
@@ -21,7 +21,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.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -174,8 +173,8 @@ public class FacetComponent extends SearchComponent {
private FacetContext(List<RangeFacetRequest> allRangeFacets, List<FacetBase> allQueryFacets) {
// avoid NPEs, set to empty list if parameters are null
- this.allRangeFacets = allRangeFacets == null ? Collections.emptyList() : allRangeFacets;
- this.allQueryFacets = allQueryFacets == null ? Collections.emptyList() : allQueryFacets;
+ this.allRangeFacets = allRangeFacets == null ? List.of() : allRangeFacets;
+ this.allQueryFacets = allQueryFacets == null ? List.of() : allQueryFacets;
taggedRangeFacets = new HashMap<>();
for (RangeFacetRequest rf : this.allRangeFacets) {
@@ -244,7 +243,7 @@ public class FacetComponent extends SearchComponent {
*/
public List<RangeFacetRequest> getRangeFacetRequestsForTag(String tag) {
List<RangeFacetRequest> list = taggedRangeFacets.get(tag);
- return list == null ? Collections.emptyList() : list;
+ return list == null ? List.of() : list;
}
/**
@@ -254,7 +253,7 @@ public class FacetComponent extends SearchComponent {
*/
public List<FacetBase> getQueryFacetsForTag(String tag) {
List<FacetBase> list = taggedQueryFacets.get(tag);
- return list == null ? Collections.emptyList() : list;
+ return list == null ? List.of() : list;
}
}
@@ -1189,7 +1188,7 @@ public class FacetComponent extends SearchComponent {
PivotFacet pivot = entry.getValue();
List<NamedList<Object>> trimmedPivots = pivot.getTrimmedPivotsAsListOfNamedLists();
if (null == trimmedPivots) {
- trimmedPivots = Collections.<NamedList<Object>>emptyList();
+ trimmedPivots = List.of();
}
combinedPivotFacets.add(key, trimmedPivots);
@@ -1310,8 +1309,8 @@ public class FacetComponent extends SearchComponent {
private String key; // label in the response for the result...
// "foo" for {!key=foo}myfield
SolrParams localParams; // any local params for the facet
- private List<String> tags = Collections.emptyList();
- private List<String> excludeTags = Collections.emptyList();
+ private List<String> tags = List.of();
+ private List<String> excludeTags = List.of();
private int threadCount = -1;
public FacetBase(ResponseBuilder rb, String facetType, String facetStr) {
@@ -1335,15 +1334,14 @@ public class FacetComponent extends SearchComponent {
key = localParams.get(CommonParams.OUTPUT_KEY, key);
String tagStr = localParams.get(CommonParams.TAG);
- this.tags =
- tagStr == null ? Collections.<String>emptyList() : StrUtils.splitSmart(tagStr, ',');
+ this.tags = tagStr == null ? List.of() : StrUtils.splitSmart(tagStr, ',');
String threadStr = localParams.get(CommonParams.THREADS);
this.threadCount = threadStr != null ? Integer.parseInt(threadStr) : -1;
String excludeStr = localParams.get(CommonParams.EXCLUDE);
if (StrUtils.isNullOrEmpty(excludeStr)) {
- this.excludeTags = Collections.emptyList();
+ this.excludeTags = List.of();
} else {
this.excludeTags = StrUtils.splitSmart(excludeStr, ',');
}
diff --git a/solr/core/src/java/org/apache/solr/handler/component/FieldFacetStats.java b/solr/core/src/java/org/apache/solr/handler/component/FieldFacetStats.java
index 2b0926ba2ee..d1310b76604 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/FieldFacetStats.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/FieldFacetStats.java
@@ -18,7 +18,6 @@ package org.apache.solr.handler.component;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -153,7 +152,7 @@ public class FieldFacetStats {
public void setNextReader(LeafReaderContext ctx) throws IOException {
this.context = ctx;
- values = valueSource.getValues(Collections.emptyMap(), ctx);
+ values = valueSource.getValues(Map.of(), ctx);
for (StatsValues stats : facetStatsValues.values()) {
stats.setNextReader(ctx);
}
diff --git a/solr/core/src/java/org/apache/solr/handler/component/PhrasesIdentificationComponent.java b/solr/core/src/java/org/apache/solr/handler/component/PhrasesIdentificationComponent.java
index a1dc6ddd911..ec22d1835f7 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/PhrasesIdentificationComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/PhrasesIdentificationComponent.java
@@ -278,7 +278,7 @@ public class PhrasesIdentificationComponent extends SearchComponent {
if (0 == contextData.allPhrases.size()) {
// w/o any phrases, the summary is just the input again...
output.add("summary", contextData.rawInput);
- output.add("details", Collections.<Object>emptyList());
+ output.add("details", List.of());
return;
}
diff --git a/solr/core/src/java/org/apache/solr/handler/component/PivotFacet.java b/solr/core/src/java/org/apache/solr/handler/component/PivotFacet.java
index 270c839eb5a..ebb164f720e 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/PivotFacet.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/PivotFacet.java
@@ -37,8 +37,8 @@ public class PivotFacet extends FacetBase {
/**
* Local param used to indicate that refinements are required on a pivot. Should also be used as
- * the prefix for concatenating with the value to determine the name of the multi-valued param
- * that will contain all of the values needed for refinement.
+ * the prefix for concatenating with the value to determine the name of the multivalued param that
+ * will contain all the values needed for refinement.
*/
public static final String REFINE_PARAM = "fpt";
@@ -84,7 +84,7 @@ public class PivotFacet extends FacetBase {
public List<PivotFacetValue> getQueuedRefinements(int shardNumber) {
List<PivotFacetValue> raw = queuedRefinements.get(shardNumber);
if (null == raw) {
- raw = Collections.<PivotFacetValue>emptyList();
+ raw = List.of();
}
return Collections.unmodifiableList(raw);
}
@@ -119,7 +119,7 @@ public class PivotFacet extends FacetBase {
public List<NamedList<Object>> getTrimmedPivotsAsListOfNamedLists() {
if (null == pivotFacetField) {
// no values in any shard for the top field of this pivot
- return Collections.<NamedList<Object>>emptyList();
+ return List.of();
}
pivotFacetField.trim();
diff --git a/solr/core/src/java/org/apache/solr/handler/component/PivotFacetFieldValueCollection.java b/solr/core/src/java/org/apache/solr/handler/component/PivotFacetFieldValueCollection.java
index f39c70ae0b5..fc331ca4e5e 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/PivotFacetFieldValueCollection.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/PivotFacetFieldValueCollection.java
@@ -113,7 +113,7 @@ public class PivotFacetFieldValueCollection implements Iterable<PivotFacetValue>
public List<PivotFacetValue> getNextLevelValuesToRefine() {
final int numRefinableValues = getExplicitValuesListSize();
if (numRefinableValues < facetFieldOffset) {
- return Collections.<PivotFacetValue>emptyList();
+ return List.of();
}
final int offsetPlusCount =
diff --git a/solr/core/src/java/org/apache/solr/handler/component/PivotFacetProcessor.java b/solr/core/src/java/org/apache/solr/handler/component/PivotFacetProcessor.java
index 2a3ef5c69d5..cd6baab79f5 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/PivotFacetProcessor.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/PivotFacetProcessor.java
@@ -18,7 +18,6 @@ package org.apache.solr.handler.component;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.Deque;
import java.util.LinkedHashMap;
import java.util.LinkedList;
@@ -99,9 +98,9 @@ public class PivotFacetProcessor extends SimpleFacets {
// start by assuming no local params...
String refineKey = null; // no local => no refinement
- List<StatsField> statsFields = Collections.emptyList(); // no local => no stats
- List<FacetComponent.FacetBase> facetQueries = Collections.emptyList();
- List<RangeFacetRequest> facetRanges = Collections.emptyList();
+ List<StatsField> statsFields = List.of(); // no local => no stats
+ List<FacetComponent.FacetBase> facetQueries = List.of();
+ List<RangeFacetRequest> facetRanges = List.of();
if (null != parsed.localParams) {
// we might be refining..
refineKey = parsed.localParams.get(PivotFacet.REFINE_PARAM);
@@ -122,7 +121,7 @@ public class PivotFacetProcessor extends SimpleFacets {
String taggedQueries = parsed.localParams.get(QUERY);
if (StrUtils.isNullOrEmpty(taggedQueries)) {
- facetQueries = Collections.emptyList();
+ facetQueries = List.of();
} else {
List<String> localParamValue = StrUtils.splitSmart(taggedQueries, ',');
if (localParamValue.size() > 1) {
@@ -141,7 +140,7 @@ public class PivotFacetProcessor extends SimpleFacets {
String taggedRanges = parsed.localParams.get(RANGE);
if (StrUtils.isNullOrEmpty(taggedRanges)) {
- facetRanges = Collections.emptyList();
+ facetRanges = List.of();
} else {
List<String> localParamValue = StrUtils.splitSmart(taggedRanges, ',');
if (localParamValue.size() > 1) {
@@ -273,7 +272,7 @@ public class PivotFacetProcessor extends SimpleFacets {
private static List<StatsField> getTaggedStatsFields(
StatsInfo statsInfo, String statsLocalParam) {
if (null == statsLocalParam || null == statsInfo) {
- return Collections.emptyList();
+ return List.of();
}
List<StatsField> fields = new ArrayList<>(7);
diff --git a/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java b/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
index 72d81d78e46..9bc219e6d53 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
@@ -26,7 +26,6 @@ import java.lang.invoke.MethodHandles;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
@@ -1004,7 +1003,7 @@ public class QueryComponent extends SearchComponent {
.filter(field -> !field.equals(SolrReturnFields.SCORE))
.collect(Collectors.toSet());
} else {
- scoreDependentFields = Collections.emptySet();
+ scoreDependentFields = Set.of();
}
IndexSchema schema = rb.req.getSchema();
diff --git a/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java b/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java
index 16e7906aea7..c23b3891639 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
@@ -518,13 +518,9 @@ public class QueryElevationComponent extends SearchComponent implements SolrCore
String paramExcludedIds = params.get(QueryElevationParams.EXCLUDE);
if (paramElevatedIds != null || paramExcludedIds != null) {
List<String> elevatedIds =
- paramElevatedIds != null
- ? StrUtils.splitSmart(paramElevatedIds, ",", true)
- : Collections.emptyList();
+ paramElevatedIds != null ? StrUtils.splitSmart(paramElevatedIds, ",", true) : List.of();
List<String> excludedIds =
- paramExcludedIds != null
- ? StrUtils.splitSmart(paramExcludedIds, ",", true)
- : Collections.emptyList();
+ paramExcludedIds != null ? StrUtils.splitSmart(paramExcludedIds, ",", true) : List.of();
return new ElevationBuilder().addElevatedIds(elevatedIds).addExcludedIds(excludedIds).build();
} else {
IndexReader reader = rb.req.getSearcher().getIndexReader();
@@ -916,10 +912,8 @@ public class QueryElevationComponent extends SearchComponent implements SolrCore
clearElevationProviderCache();
ElevatingQuery elevatingQuery = new ElevatingQuery(queryString, subsetMatch);
ElevationBuilder elevationBuilder = new ElevationBuilder();
- elevationBuilder.addElevatedIds(
- elevatedIds == null ? Collections.emptyList() : Arrays.asList(elevatedIds));
- elevationBuilder.addExcludedIds(
- excludedIds == null ? Collections.emptyList() : Arrays.asList(excludedIds));
+ elevationBuilder.addElevatedIds(elevatedIds == null ? List.of() : Arrays.asList(elevatedIds));
+ elevationBuilder.addExcludedIds(excludedIds == null ? List.of() : Arrays.asList(excludedIds));
Map<ElevatingQuery, ElevationBuilder> elevationBuilderMap =
Map.of(elevatingQuery, elevationBuilder);
synchronized (LOCK) {
@@ -1221,7 +1215,7 @@ public class QueryElevationComponent extends SearchComponent implements SolrCore
public Elevation(Set<BytesRef> elevatedIds, Set<BytesRef> excludedIds, String queryFieldName) {
if (elevatedIds == null || elevatedIds.isEmpty()) {
includeQuery = EMPTY_QUERY;
- this.elevatedIds = Collections.emptySet();
+ this.elevatedIds = Set.of();
} else {
this.elevatedIds = Collections.unmodifiableSet(new LinkedHashSet<>(elevatedIds));
BooleanQuery.Builder includeQueryBuilder = new BooleanQuery.Builder();
@@ -1233,7 +1227,7 @@ public class QueryElevationComponent extends SearchComponent implements SolrCore
}
if (excludedIds == null || excludedIds.isEmpty()) {
- this.excludedIds = Collections.emptySet();
+ this.excludedIds = Set.of();
excludeQueries = null;
} else {
this.excludedIds = Collections.unmodifiableSet(new LinkedHashSet<>(excludedIds));
@@ -1647,7 +1641,7 @@ public class QueryElevationComponent extends SearchComponent implements SolrCore
/** Gets the match values decorating this node. */
List<M> getMatchValues() {
- return (matchValues == null ? Collections.emptyList() : matchValues);
+ return (matchValues == null ? List.of() : matchValues);
}
/**
diff --git a/solr/core/src/java/org/apache/solr/handler/component/RangeFacetProcessor.java b/solr/core/src/java/org/apache/solr/handler/component/RangeFacetProcessor.java
index a4ddabe5aa4..02beb525e5d 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/RangeFacetProcessor.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/RangeFacetProcessor.java
@@ -18,7 +18,6 @@ package org.apache.solr.handler.component;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.apache.lucene.search.Query;
@@ -55,7 +54,7 @@ public class RangeFacetProcessor extends SimpleFacets {
public NamedList<Object> getFacetRangeCounts() throws IOException, SyntaxError {
final NamedList<Object> resOuter = new SimpleOrderedMap<>();
- List<RangeFacetRequest> rangeFacetRequests = Collections.emptyList();
+ List<RangeFacetRequest> rangeFacetRequests = List.of();
try {
FacetComponent.FacetContext facetContext = FacetComponent.FacetContext.getFacetContext(req);
rangeFacetRequests = facetContext.getAllRangeFacetRequests();
diff --git a/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java b/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java
index 1f78b41d5fd..d1dc15d9a49 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
@@ -1374,7 +1374,7 @@ public class RealTimeGetComponent extends SearchComponent {
private List<Long> resolveVersionRanges(String versionsStr, UpdateLog ulog) {
if (StrUtils.isNullOrEmpty(versionsStr)) {
- return Collections.emptyList();
+ return List.of();
}
List<String> ranges = StrUtils.splitSmart(versionsStr, ",", true);
@@ -1457,7 +1457,7 @@ public class RealTimeGetComponent extends SearchComponent {
final String ids[] = params.getParams("ids");
if (id == null && ids == null) {
- IdsRequested result = new IdsRequested(Collections.<String>emptyList(), true);
+ IdsRequested result = new IdsRequested(List.of(), true);
req.getContext().put(contextKey, result);
return result;
}
diff --git a/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java b/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
index d3bb6216b8a..3ec24f76c93 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
@@ -34,7 +34,6 @@ import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -203,7 +202,7 @@ public class SearchHandler extends RequestHandlerBase
@Override
public Map<String, PackageAPI.PkgVersion> packageDetails() {
- return Collections.emptyMap();
+ return Map.of();
}
@Override
diff --git a/solr/core/src/java/org/apache/solr/handler/component/ShardDoc.java b/solr/core/src/java/org/apache/solr/handler/component/ShardDoc.java
index badf4e337bf..addea96afd6 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/ShardDoc.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/ShardDoc.java
@@ -16,7 +16,6 @@
*/
package org.apache.solr.handler.component;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -50,7 +49,7 @@ public class ShardDoc extends FieldDoc {
public int positionInResponse;
- public Map<String, Object> scoreDependentFields = Collections.emptyMap();
+ public Map<String, Object> scoreDependentFields = Map.of();
// the ordinal position in the merged response arraylist
diff --git a/solr/core/src/java/org/apache/solr/handler/component/ShardHandlerFactory.java b/solr/core/src/java/org/apache/solr/handler/component/ShardHandlerFactory.java
index c135e17d1d8..9a4fdff3d11 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/ShardHandlerFactory.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/ShardHandlerFactory.java
@@ -16,7 +16,7 @@
*/
package org.apache.solr.handler.component;
-import java.util.Collections;
+import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.apache.solr.common.SolrException;
@@ -32,7 +32,6 @@ public abstract class ShardHandlerFactory {
public abstract void close();
public void setSecurityBuilder(HttpClientBuilderPlugin clientBuilderPlugin) {}
- ;
/**
* Create a new ShardHandlerFactory instance
@@ -71,5 +70,5 @@ public abstract class ShardHandlerFactory {
"shardHandlerFactory",
Map.of("class", HttpShardHandlerFactory.class.getName()),
null,
- Collections.<PluginInfo>emptyList());
+ List.of());
}
diff --git a/solr/core/src/java/org/apache/solr/handler/component/StandaloneReplicaSource.java b/solr/core/src/java/org/apache/solr/handler/component/StandaloneReplicaSource.java
index 73fd49e1a55..072c7dd2934 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/StandaloneReplicaSource.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/StandaloneReplicaSource.java
@@ -18,7 +18,6 @@
package org.apache.solr.handler.component;
import java.lang.reflect.Array;
-import java.util.Collections;
import java.util.List;
import org.apache.solr.common.util.StrUtils;
import org.apache.solr.security.AllowListUrlChecker;
@@ -43,7 +42,7 @@ class StandaloneReplicaSource implements ReplicaSource {
@Override
public List<String> getSliceNames() {
// there are no logical slice names in non-cloud
- return Collections.emptyList();
+ return List.of();
}
@Override
diff --git a/solr/core/src/java/org/apache/solr/handler/component/StatsField.java b/solr/core/src/java/org/apache/solr/handler/component/StatsField.java
index 1a679760784..2d01cb4baee 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/StatsField.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/StatsField.java
@@ -322,15 +322,11 @@ public class StatsField {
String[] facets = params.getFieldParams(key, StatsParams.STATS_FACET);
this.facets = (null == facets) ? new String[0] : facets;
String tagStr = localParams.get(CommonParams.TAG);
- this.tagList =
- (null == tagStr) ? Collections.<String>emptyList() : StrUtils.splitSmart(tagStr, ',');
+ this.tagList = (null == tagStr) ? List.of() : StrUtils.splitSmart(tagStr, ',');
// figure out if we need a special base DocSet
String excludeStr = localParams.get(CommonParams.EXCLUDE);
- this.excludeTagList =
- (null == excludeStr)
- ? Collections.<String>emptyList()
- : StrUtils.splitSmart(excludeStr, ',');
+ this.excludeTagList = (null == excludeStr) ? List.of() : StrUtils.splitSmart(excludeStr, ',');
assert ((null == this.valueSource) ^ (null == this.schemaField))
: "exactly one of valueSource & schemaField must be null";
diff --git a/solr/core/src/java/org/apache/solr/handler/component/StatsInfo.java b/solr/core/src/java/org/apache/solr/handler/component/StatsInfo.java
index 3157634716c..ebac8a92146 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/StatsInfo.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/StatsInfo.java
@@ -88,7 +88,7 @@ class StatsInfo {
public List<StatsField> getStatsFieldsByTag(String tag) {
List<StatsField> raw = tagToStatsFields.get(tag);
if (null == raw) {
- return Collections.emptyList();
+ return List.of();
} else {
return Collections.unmodifiableList(raw);
}
diff --git a/solr/core/src/java/org/apache/solr/handler/component/TermVectorComponent.java b/solr/core/src/java/org/apache/solr/handler/component/TermVectorComponent.java
index bd9183fceb0..a4702e1d613 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/TermVectorComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/TermVectorComponent.java
@@ -23,7 +23,6 @@ import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
@@ -113,7 +112,7 @@ public class TermVectorComponent extends SearchComponent {
? fieldNames
:
// return empty set indicating no fields should be used
- Collections.emptySet();
+ Set.of();
}
// otherwise us the raw fldList as is, no special parsing or globs
diff --git a/solr/core/src/java/org/apache/solr/handler/configsets/UploadConfigSet.java b/solr/core/src/java/org/apache/solr/handler/configsets/UploadConfigSet.java
index 555adb1acaa..d87c38154f5 100644
--- a/solr/core/src/java/org/apache/solr/handler/configsets/UploadConfigSet.java
+++ b/solr/core/src/java/org/apache/solr/handler/configsets/UploadConfigSet.java
@@ -23,7 +23,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.lang.invoke.MethodHandles;
import java.nio.charset.StandardCharsets;
-import java.util.Collections;
+import java.util.ArrayList;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@@ -75,7 +75,7 @@ public class UploadConfigSet extends ConfigSetAPIBase implements ConfigsetsApi.U
if (overwritesExisting && cleanup) {
filesToDelete = configSetService.getAllConfigFiles(configSetName);
} else {
- filesToDelete = Collections.emptyList();
+ filesToDelete = new ArrayList<>();
}
try (ZipInputStream zis = new ZipInputStream(requestBody, StandardCharsets.UTF_8)) {
diff --git a/solr/core/src/java/org/apache/solr/handler/designer/ManagedSchemaDiff.java b/solr/core/src/java/org/apache/solr/handler/designer/ManagedSchemaDiff.java
index 17e26923c2e..3d064ce7286 100644
--- a/solr/core/src/java/org/apache/solr/handler/designer/ManagedSchemaDiff.java
+++ b/solr/core/src/java/org/apache/solr/handler/designer/ManagedSchemaDiff.java
@@ -21,7 +21,6 @@ import com.google.common.collect.MapDifference;
import com.google.common.collect.Maps;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -224,7 +223,7 @@ public class ManagedSchemaDiff {
Map<String, MapDifference.ValueDifference<Object>> mapDiff =
Maps.difference(map1, map2).entriesDiffering();
if (mapDiff.isEmpty()) {
- return Collections.emptyList();
+ return List.of();
}
Map<String, Object> leftMapDiff =
mapDiff.entrySet().stream()
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.java
index 426ec449cb4..91f8e7e57d2 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
@@ -168,8 +168,7 @@ public class SchemaDesignerAPI implements SchemaDesignerConstants {
responseMap.put(SCHEMA_VERSION_PARAM, configSetHelper.getCurrentSchemaVersion(mutableId));
responseMap.put(
- "collections",
- exists ? configSetHelper.listCollectionsForConfig(configSet) : Collections.emptyList());
+ "collections", exists ? configSetHelper.listCollectionsForConfig(configSet) : List.of());
// don't fail if loading sample docs fails
try {
@@ -657,7 +656,7 @@ public class SchemaDesignerAPI implements SchemaDesignerConstants {
if (languages != null) {
langs =
languages.length == 0 || (languages.length == 1 && "*".equals(languages[0]))
- ? Collections.emptyList()
+ ? List.of()
: Arrays.asList(languages);
if (!langs.equals(settings.getLanguages())) {
settings.setLanguages(langs);
@@ -866,7 +865,7 @@ public class SchemaDesignerAPI implements SchemaDesignerConstants {
// collect the fields to add ... adding all fields at once is faster than one-at-a-time
List<SchemaField> fieldsToAdd = new ArrayList<>();
for (String field : docs.keySet()) {
- List<Object> sampleValues = docs.getOrDefault(field, Collections.emptyList());
+ List<Object> sampleValues = docs.getOrDefault(field, List.of());
// Collapse all whitespace in fields to a single underscore
String normalizedField = field.trim().replaceAll("\\s+", "_");
diff --git a/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java b/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java
index 90a7763a16e..23729eb21a1 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
@@ -584,9 +584,7 @@ class SchemaDesignerConfigSetHelper implements SchemaDesignerConstants {
schema =
(ManagedIndexSchema)
schema.addField(
- schema.newField(
- NEST_PATH_FIELD_NAME, NEST_PATH_FIELD_NAME, Collections.emptyMap()),
- false);
+ schema.newField(NEST_PATH_FIELD_NAME, NEST_PATH_FIELD_NAME, Map.of()), false);
madeChanges = true;
}
diff --git a/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerSettings.java b/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerSettings.java
index 0216d433ee5..5c4bf01d429 100644
--- a/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerSettings.java
+++ b/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerSettings.java
@@ -17,7 +17,6 @@
package org.apache.solr.handler.designer;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -41,8 +40,7 @@ class SchemaDesignerSettings implements SchemaDesignerConstants {
this.isDisabled = getSettingAsBool(stored, DESIGNER_KEY + DISABLED, false);
this.publishedVersion = null;
this.copyFrom = (String) stored.get(DESIGNER_KEY + COPY_FROM_PARAM);
- this.languages =
- (List<String>) stored.getOrDefault(DESIGNER_KEY + LANGUAGES_PARAM, Collections.emptyList());
+ this.languages = (List<String>) stored.getOrDefault(DESIGNER_KEY + LANGUAGES_PARAM, List.of());
this.dynamicFieldsEnabled =
getSettingAsBool(stored, DESIGNER_KEY + ENABLE_DYNAMIC_FIELDS_PARAM, true);
this.nestedDocsEnabled =
@@ -114,7 +112,7 @@ class SchemaDesignerSettings implements SchemaDesignerConstants {
}
public void setLanguages(List<String> langs) {
- this.languages = langs != null ? langs : Collections.emptyList();
+ this.languages = langs != null ? langs : List.of();
}
public boolean dynamicFieldsEnabled() {
diff --git a/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerSettingsDAO.java b/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerSettingsDAO.java
index a824e70381d..9a09e8e5da9 100644
--- a/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerSettingsDAO.java
+++ b/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerSettingsDAO.java
@@ -22,7 +22,6 @@ import static org.apache.solr.handler.designer.SchemaDesignerAPI.getConfigSetZkP
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.nio.charset.StandardCharsets;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -72,7 +71,7 @@ class SchemaDesignerSettingsDAO implements SchemaDesignerConstants {
}
map.putIfAbsent(AUTO_CREATE_FIELDS, isFieldGuessingEnabled);
- map.putIfAbsent(DESIGNER_KEY + LANGUAGES_PARAM, Collections.emptyList());
+ map.putIfAbsent(DESIGNER_KEY + LANGUAGES_PARAM, List.of());
map.putIfAbsent(DESIGNER_KEY + ENABLE_DYNAMIC_FIELDS_PARAM, true);
map.putIfAbsent(DESIGNER_KEY + ENABLE_NESTED_DOCS_PARAM, false);
@@ -83,8 +82,7 @@ class SchemaDesignerSettingsDAO implements SchemaDesignerConstants {
boolean changed = false;
ConfigOverlay overlay = getConfigOverlay(configSet);
- Map<String, Object> storedUserProps =
- overlay != null ? overlay.getUserProps() : Collections.emptyMap();
+ Map<String, Object> storedUserProps = overlay != null ? overlay.getUserProps() : Map.of();
for (Map.Entry<String, Object> e : settings.toMap().entrySet()) {
String key = e.getKey();
Object propValue = e.getValue();
@@ -118,8 +116,7 @@ class SchemaDesignerSettingsDAO implements SchemaDesignerConstants {
} catch (IOException exc) {
log.error("Failed to get config overlay for {}", configSet, exc);
}
- Map<String, Object> userProps =
- overlay != null ? overlay.getUserProps() : Collections.emptyMap();
+ Map<String, Object> userProps = overlay != null ? overlay.getUserProps() : Map.of();
return SchemaDesignerSettings.getSettingAsBool(userProps, DESIGNER_KEY + DISABLED, false);
}
diff --git a/solr/core/src/java/org/apache/solr/handler/loader/JavabinLoader.java b/solr/core/src/java/org/apache/solr/handler/loader/JavabinLoader.java
index 1269021aa2f..0c8b47003ae 100644
--- a/solr/core/src/java/org/apache/solr/handler/loader/JavabinLoader.java
+++ b/solr/core/src/java/org/apache/solr/handler/loader/JavabinLoader.java
@@ -19,7 +19,6 @@ package org.apache.solr.handler.loader;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -179,7 +178,7 @@ public class JavabinLoader extends ContentStreamLoader {
}
}
}
- return Collections.emptyList();
+ return List.of();
}
}) {
jbc.unmarshal(in);
diff --git a/solr/core/src/java/org/apache/solr/highlight/DefaultSolrHighlighter.java b/solr/core/src/java/org/apache/solr/highlight/DefaultSolrHighlighter.java
index d77d4b35f36..10cd569d99c 100644
--- a/solr/core/src/java/org/apache/solr/highlight/DefaultSolrHighlighter.java
+++ b/solr/core/src/java/org/apache/solr/highlight/DefaultSolrHighlighter.java
@@ -816,7 +816,7 @@ public class DefaultSolrHighlighter extends SolrHighlighter implements PluginInf
// Collect the Fields we will examine (could be more than one if multi-valued)
Collection<Object> fieldValues = doc.getFieldValues(fieldName);
if (fieldValues == null) {
- return Collections.emptyList();
+ return List.of();
}
FieldType fieldType = req.getSchema().getFieldType(fieldName);
List<String> result = new ArrayList<>();
diff --git a/solr/core/src/java/org/apache/solr/highlight/UnifiedSolrHighlighter.java b/solr/core/src/java/org/apache/solr/highlight/UnifiedSolrHighlighter.java
index 5f43904f517..3ae334db8b5 100644
--- a/solr/core/src/java/org/apache/solr/highlight/UnifiedSolrHighlighter.java
+++ b/solr/core/src/java/org/apache/solr/highlight/UnifiedSolrHighlighter.java
@@ -19,7 +19,6 @@ package org.apache.solr.highlight;
import java.io.IOException;
import java.text.BreakIterator;
import java.util.Collection;
-import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Locale;
@@ -162,7 +161,7 @@ public class UnifiedSolrHighlighter extends SolrHighlighter implements PluginInf
UnifiedHighlighter highlighter = getHighlighter(req);
Map<String, String[]> snippets =
fieldNames.length == 0
- ? Collections.emptyMap()
+ ? Map.of()
: highlighter.highlightFields(fieldNames, query, docIDs, maxPassages);
return encodeSnippets(keys, fieldNames, snippets);
}
diff --git a/solr/core/src/java/org/apache/solr/metrics/SolrMetricManager.java b/solr/core/src/java/org/apache/solr/metrics/SolrMetricManager.java
index f6f6c65c34a..4408eca7d45 100644
--- a/solr/core/src/java/org/apache/solr/metrics/SolrMetricManager.java
+++ b/solr/core/src/java/org/apache/solr/metrics/SolrMetricManager.java
@@ -55,7 +55,6 @@ import io.opentelemetry.sdk.metrics.export.MetricExporter;
import io.opentelemetry.sdk.metrics.export.PeriodicMetricReader;
import java.lang.invoke.MethodHandles;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -520,8 +519,7 @@ public class SolrMetricManager {
* to the name.
*/
public static String mkName(String name, String... path) {
- return makeName(
- path == null || path.length == 0 ? Collections.emptyList() : Arrays.asList(path), name);
+ return makeName(path == null || path.length == 0 ? List.of() : Arrays.asList(path), name);
}
public static String makeName(List<String> path, String name) {
diff --git a/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.java b/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.java
index 943c9248a62..0d16ec02b0d 100644
--- a/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.java
+++ b/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.java
@@ -250,15 +250,14 @@ public class PackageManager implements Closeable {
false) /* Making a collection request, but already baked into path */);
packages =
(Map<String, String>)
- Objects.requireNonNullElse(
- result._get("/response/params/PKG_VERSIONS"), Collections.emptyMap());
+ Objects.requireNonNullElse(result._get("/response/params/PKG_VERSIONS"), Map.of());
} catch (PathNotFoundException ex) {
// Don't worry if PKG_VERSION wasn't found. It just means this collection was never touched by
// the package manager.
} catch (SolrServerException | IOException ex) {
throw new SolrException(ErrorCode.SERVER_ERROR, ex);
}
- if (packages == null) return Collections.emptyMap();
+ if (packages == null) return Map.of();
Map<String, SolrPackageInstance> ret = new HashMap<>();
for (String packageName : packages.keySet()) {
if (!StrUtils.isNullOrEmpty(packageName)
@@ -289,7 +288,7 @@ public class PackageManager implements Closeable {
Integer statusCode = (Integer) response._get(List.of("responseHeader", "status"), null);
if (statusCode == null || statusCode == ErrorCode.NOT_FOUND.code) {
// Cluster props doesn't exist, that means there are no cluster level plugins installed.
- result = Collections.emptyMap();
+ result = Map.of();
} else {
result = response.asShallowMap();
}
@@ -298,8 +297,7 @@ public class PackageManager implements Closeable {
}
@SuppressWarnings({"unchecked"})
Map<String, Object> clusterPlugins =
- (Map<String, Object>)
- result.getOrDefault(ContainerPluginsApi.PLUGIN, Collections.emptyMap());
+ (Map<String, Object>) result.getOrDefault(ContainerPluginsApi.PLUGIN, Map.of());
for (Map.Entry<String, Object> entry : clusterPlugins.entrySet()) {
PluginMeta pluginMeta;
try {
@@ -615,7 +613,7 @@ public class PackageManager implements Closeable {
}
if (clusterprops != null) {
Object pkg =
- ((Map<String, Object>) clusterprops.getOrDefault("plugin", Collections.emptyMap()))
+ ((Map<String, Object>) clusterprops.getOrDefault("plugin", Map.of()))
.get(packageInstance.name + ":" + plugin.name);
if (pkg != null) {
printRed(
@@ -737,12 +735,12 @@ public class PackageManager implements Closeable {
false) /* Making a collection-request, but already baked into path */);
return (Map<String, String>)
Objects.requireNonNullElse(
- response._get("/response/params/packages/" + packageName), Collections.emptyMap());
+ response._get("/response/params/packages/" + packageName), Map.of());
} catch (Exception ex) {
// This should be because there are no parameters. Be tolerant here.
log.warn("There are no parameters to return for package: {}", packageName);
- return Collections.emptyMap();
+ return Map.of();
}
}
@@ -997,14 +995,11 @@ public class PackageManager implements Closeable {
PackageUtils.resolve(
getMapper().writeValueAsString(cmd.payload),
deployedPackage.parameterDefaults,
- Collections.emptyMap(),
+ Map.of(),
systemParams);
String path =
PackageUtils.resolve(
- cmd.path,
- deployedPackage.parameterDefaults,
- Collections.emptyMap(),
- systemParams);
+ cmd.path, deployedPackage.parameterDefaults, Map.of(), systemParams);
printGreen("Executing " + payload + " for path:" + path);
SolrCLI.postJsonToSolr(solrClient, path, payload);
} catch (Exception ex) {
diff --git a/solr/core/src/java/org/apache/solr/pkg/SolrPackageLoader.java b/solr/core/src/java/org/apache/solr/pkg/SolrPackageLoader.java
index f3a86dd55d7..fdfb9881964 100644
--- a/solr/core/src/java/org/apache/solr/pkg/SolrPackageLoader.java
+++ b/solr/core/src/java/org/apache/solr/pkg/SolrPackageLoader.java
@@ -78,7 +78,7 @@ public class SolrPackageLoader implements Closeable {
}
public Map<String, SolrPackage> getPackages() {
- return Collections.emptyMap();
+ return Map.of();
}
public void refreshPackageConf() {
diff --git a/solr/core/src/java/org/apache/solr/request/NumericFacets.java b/solr/core/src/java/org/apache/solr/request/NumericFacets.java
index 0584a46e5f8..b6584a7829c 100644
--- a/solr/core/src/java/org/apache/solr/request/NumericFacets.java
+++ b/solr/core/src/java/org/apache/solr/request/NumericFacets.java
@@ -18,7 +18,6 @@ package org.apache.solr.request;
import java.io.IOException;
import java.util.ArrayDeque;
-import java.util.Collections;
import java.util.Date;
import java.util.Deque;
import java.util.HashMap;
@@ -321,7 +320,7 @@ final class NumericFacets {
// Entries from the PQ first, then using the terms dictionary
for (Entry entry : counts) {
final int readerIdx = ReaderUtil.subIndex(entry.docID, leaves);
- final FunctionValues values = vs.getValues(Collections.emptyMap(), leaves.get(readerIdx));
+ final FunctionValues values = vs.getValues(Map.of(), leaves.get(readerIdx));
result.add(values.strVal(entry.docID - leaves.get(readerIdx).docBase), entry.count);
}
@@ -339,7 +338,7 @@ final class NumericFacets {
while (pq.size() > 0) {
Entry entry = pq.pop();
final int readerIdx = ReaderUtil.subIndex(entry.docID, leaves);
- final FunctionValues values = vs.getValues(Collections.emptyMap(), leaves.get(readerIdx));
+ final FunctionValues values = vs.getValues(Map.of(), leaves.get(readerIdx));
alreadySeen.add(values.strVal(entry.docID - leaves.get(readerIdx).docBase));
}
result.forEach((name, __) -> alreadySeen.add(name));
@@ -404,7 +403,7 @@ final class NumericFacets {
while (pq.size() > 0) {
final Entry entry = pq.pop();
final int readerIdx = ReaderUtil.subIndex(entry.docID, leaves);
- final FunctionValues values = vs.getValues(Collections.emptyMap(), leaves.get(readerIdx));
+ final FunctionValues values = vs.getValues(Map.of(), leaves.get(readerIdx));
counts.put(values.strVal(entry.docID - leaves.get(readerIdx).docBase), entry.count);
}
final Terms terms = searcher.getSlowAtomicReader().terms(fieldName);
diff --git a/solr/core/src/java/org/apache/solr/request/SimpleFacets.java b/solr/core/src/java/org/apache/solr/request/SimpleFacets.java
index 04531901f44..92bb0dc2e60 100644
--- a/solr/core/src/java/org/apache/solr/request/SimpleFacets.java
+++ b/solr/core/src/java/org/apache/solr/request/SimpleFacets.java
@@ -179,7 +179,7 @@ public class SimpleFacets {
DocSet docs = docsOrig;
String facetValue = param;
String key = param;
- List<String> tags = Collections.emptyList();
+ List<String> tags = List.of();
int threads = -1;
if (localParams == null) {
@@ -203,7 +203,7 @@ public class SimpleFacets {
key = localParams.get(CommonParams.OUTPUT_KEY, key);
String tagStr = localParams.get(CommonParams.TAG);
- tags = tagStr == null ? Collections.<String>emptyList() : StrUtils.splitSmart(tagStr, ',');
+ tags = tagStr == null ? List.of() : StrUtils.splitSmart(tagStr, ',');
String threadStr = localParams.get(CommonParams.THREADS);
if (threadStr != null) {
diff --git a/solr/core/src/java/org/apache/solr/request/SolrQueryRequest.java b/solr/core/src/java/org/apache/solr/request/SolrQueryRequest.java
index a0ed740b928..61fc413142b 100644
--- a/solr/core/src/java/org/apache/solr/request/SolrQueryRequest.java
+++ b/solr/core/src/java/org/apache/solr/request/SolrQueryRequest.java
@@ -18,7 +18,6 @@ package org.apache.solr.request;
import io.opentelemetry.api.trace.Span;
import java.security.Principal;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.apache.solr.client.solrj.SolrRequest;
@@ -149,7 +148,7 @@ public interface SolrQueryRequest extends AutoCloseable {
* would contain {segment1:x ,segment2:y}
*/
default Map<String, String> getPathTemplateValues() {
- return Collections.emptyMap();
+ return Map.of();
}
/**
@@ -159,7 +158,7 @@ public interface SolrQueryRequest extends AutoCloseable {
* @param validateInput , If true it is validated against the json schema spec
*/
default List<CommandOperation> getCommands(boolean validateInput) {
- return Collections.emptyList();
+ return List.of();
}
default String getHttpMethod() {
diff --git a/solr/core/src/java/org/apache/solr/request/SolrQueryRequestBase.java b/solr/core/src/java/org/apache/solr/request/SolrQueryRequestBase.java
index 975d9a288b3..58c2b09db7b 100644
--- a/solr/core/src/java/org/apache/solr/request/SolrQueryRequestBase.java
+++ b/solr/core/src/java/org/apache/solr/request/SolrQueryRequestBase.java
@@ -18,7 +18,6 @@ package org.apache.solr.request;
import java.io.Closeable;
import java.security.Principal;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -225,7 +224,7 @@ public class SolrQueryRequestBase implements SolrQueryRequest, Closeable {
}
protected Map<String, JsonSchemaValidator> getValidators() {
- return Collections.emptyMap();
+ return Map.of();
}
private record LocalPrincipal(String user) implements Principal {
diff --git a/solr/core/src/java/org/apache/solr/response/transform/DocTransformer.java b/solr/core/src/java/org/apache/solr/response/transform/DocTransformer.java
index 0acd9e95026..109afb979cc 100644
--- a/solr/core/src/java/org/apache/solr/response/transform/DocTransformer.java
+++ b/solr/core/src/java/org/apache/solr/response/transform/DocTransformer.java
@@ -18,7 +18,7 @@ package org.apache.solr.response.transform;
import java.io.IOException;
import java.util.Collection;
-import java.util.Collections;
+import java.util.Set;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.response.QueryResponseWriter;
import org.apache.solr.response.ResultContext;
@@ -68,12 +68,11 @@ public abstract class DocTransformer {
* is acceptable.
*/
public Collection<String> getRawFields() {
- return Collections.emptySet();
+ return Set.of();
}
/**
- * Indicates if this transformer requires access to the underlying index to perform it's
- * functions.
+ * Indicates if this transformer requires access to the underlying index to perform its functions.
*
* <p>In some situations (notably RealTimeGet) this method <i>may</i> be called before {@link
* #setContext} to determine if the transformer must be given a "full" ResultContext and accurate
diff --git a/solr/core/src/java/org/apache/solr/response/transform/GeoTransformerFactory.java b/solr/core/src/java/org/apache/solr/response/transform/GeoTransformerFactory.java
index 2324f890459..65c482ad25e 100644
--- a/solr/core/src/java/org/apache/solr/response/transform/GeoTransformerFactory.java
+++ b/solr/core/src/java/org/apache/solr/response/transform/GeoTransformerFactory.java
@@ -18,7 +18,6 @@ package org.apache.solr.response.transform;
import java.io.IOException;
import java.util.Collection;
-import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@@ -199,7 +198,7 @@ public class GeoTransformerFactory extends TransformerFactory
@Override
public Collection<String> getRawFields() {
- return updater.isJSON ? Collections.singleton(updater.display) : Collections.emptySet();
+ return updater.isJSON ? Set.of(updater.display) : Set.of();
}
}
diff --git a/solr/core/src/java/org/apache/solr/schema/AbstractSpatialFieldType.java b/solr/core/src/java/org/apache/solr/schema/AbstractSpatialFieldType.java
index 7fe850b1bdc..e0e7ff508a3 100644
--- a/solr/core/src/java/org/apache/solr/schema/AbstractSpatialFieldType.java
+++ b/solr/core/src/java/org/apache/solr/schema/AbstractSpatialFieldType.java
@@ -110,7 +110,7 @@ public abstract class AbstractSpatialFieldType<T extends SpatialStrategy> extend
protected final Set<String> supportedScoreModes;
protected AbstractSpatialFieldType() {
- this(Collections.emptySet());
+ this(Set.of());
}
protected AbstractSpatialFieldType(Set<String> moreScoreModes) {
@@ -242,7 +242,7 @@ public abstract class AbstractSpatialFieldType<T extends SpatialStrategy> extend
}
if (shape == null) {
log.debug("Field {}: null shape for input: {}", field, val);
- return Collections.emptyList();
+ return List.of();
}
List<IndexableField> result = new ArrayList<>();
diff --git a/solr/core/src/java/org/apache/solr/schema/FieldType.java b/solr/core/src/java/org/apache/solr/schema/FieldType.java
index 6b1404c5706..0f72e49747a 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 ? Collections.<IndexableField>emptyList() : Collections.singletonList(f);
+ return f == null ? List.of() : Collections.singletonList(f);
}
/**
diff --git a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
index e350b6233b5..3571dd2a07d 100644
--- a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
+++ b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
@@ -1501,7 +1501,7 @@ public class IndexSchema {
public List<String> getCopySources(String destField) {
SchemaField f = getField(destField);
if (!isCopyFieldTarget(f)) {
- return Collections.emptyList();
+ return List.of();
}
List<String> fieldNames = new ArrayList<>();
for (Map.Entry<String, List<CopyField>> cfs : copyFieldsMap.entrySet()) {
@@ -1556,7 +1556,7 @@ public class IndexSchema {
/** Get a map of property name -> value for the whole schema. */
public Map<String, Object> getNamedPropertyValues() {
- return getNamedPropertyValues(null, new MapSolrParams(Collections.emptyMap()));
+ return getNamedPropertyValues(null, new MapSolrParams(Map.of()));
}
public static class SchemaProps implements MapSerializable {
@@ -1801,7 +1801,7 @@ public class IndexSchema {
* @see #newField(String, String, Map)
*/
public IndexSchema addField(SchemaField newField, boolean persist) {
- return addFields(Collections.singletonList(newField), Collections.emptyMap(), persist);
+ return addFields(Collections.singletonList(newField), Map.of(), persist);
}
public IndexSchema addField(SchemaField newField) {
@@ -1832,7 +1832,7 @@ public class IndexSchema {
* @see #newField(String, String, Map)
*/
public IndexSchema addFields(Collection<SchemaField> newFields) {
- return addFields(newFields, Collections.<String, Collection<String>>emptyMap(), true);
+ return addFields(newFields, Map.of(), true);
}
/**
diff --git a/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java b/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java
index e1d8ad5b5ab..e1be86a3d05 100644
--- a/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java
+++ b/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java
@@ -26,7 +26,6 @@ import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -435,7 +434,7 @@ public final class ManagedIndexSchema extends IndexSchema {
if (isMutable) {
boolean success = false;
if (copyFieldNames == null) {
- copyFieldNames = Collections.emptyMap();
+ copyFieldNames = Map.of();
}
newSchema = shallowCopy(true);
@@ -639,7 +638,7 @@ public final class ManagedIndexSchema extends IndexSchema {
if (isMutable) {
boolean success = false;
if (copyFieldNames == null) {
- copyFieldNames = Collections.emptyMap();
+ copyFieldNames = Map.of();
}
newSchema = shallowCopy(true);
diff --git a/solr/core/src/java/org/apache/solr/schema/PointField.java b/solr/core/src/java/org/apache/solr/schema/PointField.java
index 611dcfc43a4..e74e73f1320 100644
--- a/solr/core/src/java/org/apache/solr/schema/PointField.java
+++ b/solr/core/src/java/org/apache/solr/schema/PointField.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.Date;
import java.util.List;
import java.util.Map;
@@ -262,7 +261,7 @@ public abstract class PointField extends NumericFieldType {
@Override
public List<IndexableField> createFields(SchemaField sf, Object value) {
if (!isFieldUsed(sf)) {
- return Collections.emptyList();
+ return List.of();
}
List<IndexableField> fields = new ArrayList<>(3);
IndexableField field = null;
diff --git a/solr/core/src/java/org/apache/solr/schema/SchemaField.java b/solr/core/src/java/org/apache/solr/schema/SchemaField.java
index 2a413bf3729..ef3c5559aff 100644
--- a/solr/core/src/java/org/apache/solr/schema/SchemaField.java
+++ b/solr/core/src/java/org/apache/solr/schema/SchemaField.java
@@ -46,7 +46,7 @@ public final class SchemaField extends FieldProperties implements IndexableField
boolean required = false; // this can't be final since it may be changed dynamically
/** Declared field property overrides */
- Map<String, Object> args = Collections.emptyMap();
+ Map<String, Object> args = Map.of();
/**
* Create a new SchemaField with the given name and type, using all the default properties from
diff --git a/solr/core/src/java/org/apache/solr/schema/SchemaManager.java b/solr/core/src/java/org/apache/solr/schema/SchemaManager.java
index b2ae09fcd22..fc2d4bcb49e 100644
--- a/solr/core/src/java/org/apache/solr/schema/SchemaManager.java
+++ b/solr/core/src/java/org/apache/solr/schema/SchemaManager.java
@@ -34,7 +34,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.List;
import java.util.Map;
@@ -306,7 +305,7 @@ public class SchemaManager {
mgr.managedIndexSchema.newField(
name, type, convertToMapExcluding(addFieldOp, propsToOmit));
mgr.managedIndexSchema =
- mgr.managedIndexSchema.addFields(singletonList(field), Collections.emptyMap(), false);
+ mgr.managedIndexSchema.addFields(singletonList(field), Map.of(), false);
return true;
} catch (Exception e) {
log.error("Could not add field", e);
@@ -342,8 +341,7 @@ public class SchemaManager {
mgr.managedIndexSchema.newDynamicField(
name, type, convertToMapExcluding(addDynFieldOp, propsToOmit));
mgr.managedIndexSchema =
- mgr.managedIndexSchema.addDynamicFields(
- singletonList(field), Collections.emptyMap(), false);
+ mgr.managedIndexSchema.addDynamicFields(singletonList(field), Map.of(), false);
return true;
} catch (Exception e) {
log.error("Could not add dynamic field", e);
diff --git a/solr/core/src/java/org/apache/solr/search/BitDocSet.java b/solr/core/src/java/org/apache/solr/search/BitDocSet.java
index c45cbd5d893..db55581b339 100644
--- a/solr/core/src/java/org/apache/solr/search/BitDocSet.java
+++ b/solr/core/src/java/org/apache/solr/search/BitDocSet.java
@@ -17,7 +17,7 @@
package org.apache.solr.search;
import java.util.Collection;
-import java.util.Collections;
+import java.util.List;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.util.Accountable;
@@ -331,7 +331,7 @@ public class BitDocSet extends DocSet {
@Override
public Collection<Accountable> getChildResources() {
- return Collections.emptyList();
+ return List.of();
}
@Override
diff --git a/solr/core/src/java/org/apache/solr/search/CaffeineCache.java b/solr/core/src/java/org/apache/solr/search/CaffeineCache.java
index 1ccf30145d0..520dd2a4e80 100644
--- a/solr/core/src/java/org/apache/solr/search/CaffeineCache.java
+++ b/solr/core/src/java/org/apache/solr/search/CaffeineCache.java
@@ -29,7 +29,6 @@ import java.io.IOException;
import java.io.UncheckedIOException;
import java.lang.invoke.MethodHandles;
import java.time.Duration;
-import java.util.Collections;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
@@ -399,14 +398,13 @@ public class CaffeineCache<K, V> extends SolrCacheBase
}
long warmingStartTime = System.nanoTime();
- Map<K, V> hottest = Collections.emptyMap();
+ Map<K, V> hottest = Map.of();
CaffeineCache<K, V> other = (CaffeineCache<K, V>) old;
// warm entries
if (isAutowarmingOn()) {
int size = autowarm.getWarmCount(other.cache.asMap().size());
- hottest =
- other.cache.policy().eviction().map(p -> p.hottest(size)).orElse(Collections.emptyMap());
+ hottest = other.cache.policy().eviction().map(p -> p.hottest(size)).orElse(Map.of());
}
for (Entry<K, V> entry : hottest.entrySet()) {
diff --git a/solr/core/src/java/org/apache/solr/search/DocSlice.java b/solr/core/src/java/org/apache/solr/search/DocSlice.java
index 7c01493aac6..f0c63a1b269 100644
--- a/solr/core/src/java/org/apache/solr/search/DocSlice.java
+++ b/solr/core/src/java/org/apache/solr/search/DocSlice.java
@@ -17,7 +17,7 @@
package org.apache.solr.search;
import java.util.Collection;
-import java.util.Collections;
+import java.util.List;
import org.apache.lucene.search.TotalHits;
import org.apache.lucene.util.Accountable;
import org.apache.lucene.util.RamUsageEstimator;
@@ -164,7 +164,7 @@ public class DocSlice implements DocList, Accountable {
@Override
public Collection<Accountable> getChildResources() {
- return Collections.emptyList();
+ return List.of();
}
@Override
diff --git a/solr/core/src/java/org/apache/solr/search/NumericHidingLeafReader.java b/solr/core/src/java/org/apache/solr/search/NumericHidingLeafReader.java
index 0e48c72900c..36a7e6177f4 100644
--- a/solr/core/src/java/org/apache/solr/search/NumericHidingLeafReader.java
+++ b/solr/core/src/java/org/apache/solr/search/NumericHidingLeafReader.java
@@ -19,6 +19,7 @@ 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;
import org.apache.lucene.index.DocValuesType;
@@ -71,7 +72,7 @@ public class NumericHidingLeafReader extends FilterLeafReader {
DocValuesType.NONE,
DocValuesSkipIndexType.NONE,
-1,
- Collections.emptyMap(),
+ Map.of(),
fi.getPointDimensionCount(),
fi.getPointIndexDimensionCount(),
fi.getPointNumBytes(),
diff --git a/solr/core/src/java/org/apache/solr/search/QueryUtils.java b/solr/core/src/java/org/apache/solr/search/QueryUtils.java
index 60538d73a31..321391a9784 100644
--- a/solr/core/src/java/org/apache/solr/search/QueryUtils.java
+++ b/solr/core/src/java/org/apache/solr/search/QueryUtils.java
@@ -290,7 +290,7 @@ public class QueryUtils {
return filters;
}
- return Collections.emptyList();
+ return List.of();
}
/**
@@ -313,7 +313,7 @@ public class QueryUtils {
Map<?, ?> tagMap = (Map<?, ?>) req.getContext().get("tags");
if (tagMap == null || tagMap.isEmpty() || desiredTags == null || desiredTags.isEmpty()) {
- return Collections.emptySet();
+ return Set.of();
}
Set<Query> taggedQueries = Collections.newSetFromMap(new IdentityHashMap<>());
diff --git a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
index 407f478be0a..862b6a22ac4 100644
--- a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
+++ b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
@@ -24,7 +24,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.Comparator;
import java.util.Date;
import java.util.List;
@@ -140,7 +139,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
// These should *only* be used for debugging or monitoring purposes
public static final AtomicLong numOpens = new AtomicLong();
public static final AtomicLong numCloses = new AtomicLong();
- private static final Map<String, SolrCache<?, ?>> NO_GENERIC_CACHES = Collections.emptyMap();
+ private static final Map<String, SolrCache<?, ?>> NO_GENERIC_CACHES = Map.of();
private static final SolrCache<?, ?>[] NO_CACHES = new SolrCache<?, ?>[0];
public static final int EXECUTOR_MAX_CPU_THREADS = Runtime.getRuntime().availableProcessors();
diff --git a/solr/core/src/java/org/apache/solr/search/SolrReturnFields.java b/solr/core/src/java/org/apache/solr/search/SolrReturnFields.java
index 939cf9b778c..bf850f4de8b 100644
--- a/solr/core/src/java/org/apache/solr/search/SolrReturnFields.java
+++ b/solr/core/src/java/org/apache/solr/search/SolrReturnFields.java
@@ -68,7 +68,7 @@ public class SolrReturnFields extends ReturnFields {
protected DocTransformer transformer;
protected boolean _wantsScore = false;
protected boolean _wantsAllFields = false;
- protected Map<String, String> renameFields = Collections.emptyMap();
+ protected Map<String, String> renameFields = Map.of();
private final Map<String, String> scoreDependentFields = new HashMap<>();
diff --git a/solr/core/src/java/org/apache/solr/search/SortSpecParsing.java b/solr/core/src/java/org/apache/solr/search/SortSpecParsing.java
index d4f88168f37..5a454f2f6c9 100644
--- a/solr/core/src/java/org/apache/solr/search/SortSpecParsing.java
+++ b/solr/core/src/java/org/apache/solr/search/SortSpecParsing.java
@@ -17,7 +17,6 @@
package org.apache.solr.search;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.search.Sort;
@@ -219,6 +218,6 @@ public class SortSpecParsing {
}
private static SortSpec newEmptySortSpec() {
- return new SortSpec(null, Collections.<SchemaField>emptyList());
+ return new SortSpec(null, List.of());
}
}
diff --git a/solr/core/src/java/org/apache/solr/search/SortedIntDocSet.java b/solr/core/src/java/org/apache/solr/search/SortedIntDocSet.java
index 53e1f2a2f67..1880d290bef 100644
--- a/solr/core/src/java/org/apache/solr/search/SortedIntDocSet.java
+++ b/solr/core/src/java/org/apache/solr/search/SortedIntDocSet.java
@@ -19,7 +19,6 @@ package org.apache.solr.search;
import com.carrotsearch.hppc.IntHashSet;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.ReaderUtil;
@@ -772,7 +771,7 @@ public class SortedIntDocSet extends DocSet {
@Override
public Collection<Accountable> getChildResources() {
- return Collections.emptyList();
+ return List.of();
}
@Override
diff --git a/solr/core/src/java/org/apache/solr/search/facet/FacetFieldProcessor.java b/solr/core/src/java/org/apache/solr/search/facet/FacetFieldProcessor.java
index 3e8d3020294..2dca4a5a35b 100644
--- a/solr/core/src/java/org/apache/solr/search/facet/FacetFieldProcessor.java
+++ b/solr/core/src/java/org/apache/solr/search/facet/FacetFieldProcessor.java
@@ -22,7 +22,6 @@ import static org.apache.solr.search.facet.FacetContext.SKIP_FACET;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
@@ -1042,7 +1041,7 @@ abstract class FacetFieldProcessor extends FacetProcessor<FacetField> {
@SuppressWarnings({"unchecked"})
static <T> List<T> asList(Object list) {
- return list != null ? (List<T>) list : Collections.emptyList();
+ return list != null ? (List<T>) list : List.of();
}
@SuppressWarnings({"rawtypes", "unchecked"})
diff --git a/solr/core/src/java/org/apache/solr/search/facet/FacetMerger.java b/solr/core/src/java/org/apache/solr/search/facet/FacetMerger.java
index 90b6a76d1c4..b5d190dfa72 100644
--- a/solr/core/src/java/org/apache/solr/search/facet/FacetMerger.java
+++ b/solr/core/src/java/org/apache/solr/search/facet/FacetMerger.java
@@ -21,9 +21,9 @@ import static org.apache.solr.search.facet.FacetRequest.RefineMethod.SIMPLE;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.IdentityHashMap;
+import java.util.List;
import java.util.Map;
public abstract class FacetMerger {
@@ -100,7 +100,7 @@ public abstract class FacetMerger {
new IdentityHashMap<>(4);
public Collection<String> getSubsWithRefinement(FacetRequest freq) {
- if (freq.getSubFacets().isEmpty()) return Collections.emptyList();
+ if (freq.getSubFacets().isEmpty()) return List.of();
Collection<String> subs = refineSubMap.get(freq);
if (subs != null) return subs;
@@ -115,7 +115,7 @@ public abstract class FacetMerger {
}
if (subs == null) {
- subs = Collections.emptyList();
+ subs = List.of();
}
refineSubMap.put(freq, subs);
return subs;
@@ -125,7 +125,7 @@ public abstract class FacetMerger {
new IdentityHashMap<>(4);
public Collection<String> getSubsWithPartial(FacetRequest freq) {
- if (freq.getSubFacets().isEmpty()) return Collections.emptyList();
+ if (freq.getSubFacets().isEmpty()) return List.of();
Collection<String> subs = partialSubsMap.get(freq);
if (subs != null) return subs;
@@ -143,7 +143,7 @@ public abstract class FacetMerger {
}
if (subs == null) {
- subs = Collections.emptyList();
+ subs = List.of();
}
partialSubsMap.put(freq, subs);
return subs;
diff --git a/solr/core/src/java/org/apache/solr/search/facet/SlotAcc.java b/solr/core/src/java/org/apache/solr/search/facet/SlotAcc.java
index 93ea6474965..ceba52b6fcb 100644
--- a/solr/core/src/java/org/apache/solr/search/facet/SlotAcc.java
+++ b/solr/core/src/java/org/apache/solr/search/facet/SlotAcc.java
@@ -21,7 +21,6 @@ import java.io.IOException;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.function.IntFunction;
@@ -827,7 +826,7 @@ public abstract class SlotAcc implements Closeable {
if (processor.countAcc instanceof SweepingCountSlotAcc) {
return ((SweepingCountSlotAcc) processor.countAcc).others;
}
- return Collections.emptyList();
+ return List.of();
}
}
diff --git a/solr/core/src/java/org/apache/solr/search/function/distance/GeoDistValueSourceParser.java b/solr/core/src/java/org/apache/solr/search/function/distance/GeoDistValueSourceParser.java
index 3db627ea7d1..e5694dbd4f4 100644
--- a/solr/core/src/java/org/apache/solr/search/function/distance/GeoDistValueSourceParser.java
+++ b/solr/core/src/java/org/apache/solr/search/function/distance/GeoDistValueSourceParser.java
@@ -22,7 +22,6 @@ import static org.apache.solr.search.FunctionQParser.FLAG_USE_FIELDNAME_SOURCE;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.valuesource.ConstNumberSource;
@@ -245,7 +244,7 @@ public class GeoDistValueSourceParser extends ValueSourceParser {
final DistanceUnits distanceUnits;
public SpatialStrategyMultiValueSource(SpatialStrategy strategy, DistanceUnits distanceUnits) {
- super(Collections.emptyList());
+ super(List.of());
this.strategy = strategy;
this.distanceUnits = distanceUnits;
}
diff --git a/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/SearchGroupsFieldCommand.java b/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/SearchGroupsFieldCommand.java
index 47a16531a29..c4d98a65a21 100644
--- a/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/SearchGroupsFieldCommand.java
+++ b/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/SearchGroupsFieldCommand.java
@@ -19,7 +19,6 @@ package org.apache.solr.search.grouping.distributed.command;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import org.apache.lucene.queries.function.ValueSource;
@@ -136,7 +135,7 @@ public class SearchGroupsFieldCommand implements Command<SearchGroupsFieldComman
topGroups = (Collection<SearchGroup<BytesRef>>) values;
}
} else {
- topGroups = Collections.emptyList();
+ topGroups = List.of();
}
final Integer groupCount;
if (allGroupsCollector != null) {
diff --git a/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/TopGroupsFieldCommand.java b/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/TopGroupsFieldCommand.java
index a86f0ebae43..dc9300c93e5 100644
--- a/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/TopGroupsFieldCommand.java
+++ b/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/TopGroupsFieldCommand.java
@@ -20,7 +20,6 @@ import java.io.IOException;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import org.apache.lucene.queries.function.ValueSource;
@@ -152,7 +151,7 @@ public class TopGroupsFieldCommand implements Command<TopGroups<BytesRef>> {
@Override
public List<Collector> create() throws IOException {
if (firstPhaseGroups.isEmpty()) {
- return Collections.emptyList();
+ return List.of();
}
final List<Collector> collectors = new ArrayList<>(1);
diff --git a/solr/core/src/java/org/apache/solr/search/join/FiltersQParser.java b/solr/core/src/java/org/apache/solr/search/join/FiltersQParser.java
index 05c705aa1ce..b031f136566 100644
--- a/solr/core/src/java/org/apache/solr/search/join/FiltersQParser.java
+++ b/solr/core/src/java/org/apache/solr/search/join/FiltersQParser.java
@@ -18,7 +18,6 @@
package org.apache.solr.search.join;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.Map;
@@ -92,7 +91,7 @@ public class FiltersQParser extends QParser {
if (tagMap != null && !tagMap.isEmpty() && !tagsToExclude.isEmpty()) {
excludeSet = excludeSet(tagMap, tagsToExclude);
} else {
- excludeSet = Collections.emptySet();
+ excludeSet = Set.of();
}
clauses.removeAll(excludeSet);
}
diff --git a/solr/core/src/java/org/apache/solr/search/stats/ExactStatsCache.java b/solr/core/src/java/org/apache/solr/search/stats/ExactStatsCache.java
index 59f0eb4d8e3..795c117a0a7 100644
--- a/solr/core/src/java/org/apache/solr/search/stats/ExactStatsCache.java
+++ b/solr/core/src/java/org/apache/solr/search/stats/ExactStatsCache.java
@@ -19,7 +19,6 @@ package org.apache.solr.search.stats;
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;
@@ -72,11 +71,10 @@ public class ExactStatsCache extends StatsCache {
@SuppressWarnings({"unchecked"})
Map<String, CollectionStats> currentGlobalColStats =
(Map<String, CollectionStats>)
- req.getContext().getOrDefault(CURRENT_GLOBAL_COL_STATS, Collections.emptyMap());
+ req.getContext().getOrDefault(CURRENT_GLOBAL_COL_STATS, Map.of());
@SuppressWarnings({"unchecked"})
Map<String, TermStats> currentGlobalTermStats =
- (Map<String, TermStats>)
- req.getContext().getOrDefault(CURRENT_GLOBAL_TERM_STATS, Collections.emptyMap());
+ (Map<String, TermStats>) req.getContext().getOrDefault(CURRENT_GLOBAL_TERM_STATS, Map.of());
if (log.isDebugEnabled()) {
log.debug(
"Returning StatsSource. Collection stats={}, Term stats size= {}",
@@ -156,11 +154,11 @@ public class ExactStatsCache extends StatsCache {
@SuppressWarnings({"unchecked"})
Map<String, Map<String, TermStats>> perShardTermStats =
(Map<String, Map<String, TermStats>>)
- req.getContext().getOrDefault(PER_SHARD_TERM_STATS, Collections.emptyMap());
+ req.getContext().getOrDefault(PER_SHARD_TERM_STATS, Map.of());
@SuppressWarnings({"unchecked"})
Map<String, Map<String, CollectionStats>> perShardColStats =
(Map<String, Map<String, CollectionStats>>)
- req.getContext().getOrDefault(PER_SHARD_COL_STATS, Collections.emptyMap());
+ req.getContext().getOrDefault(PER_SHARD_COL_STATS, Map.of());
log.debug("perShardColStats={}, perShardTermStats={}", perShardColStats, perShardTermStats);
}
@@ -318,7 +316,7 @@ public class ExactStatsCache extends StatsCache {
@SuppressWarnings({"unchecked"})
Map<String, Map<String, CollectionStats>> perShardColStats =
(Map<String, Map<String, CollectionStats>>)
- rb.req.getContext().getOrDefault(PER_SHARD_COL_STATS, Collections.emptyMap());
+ rb.req.getContext().getOrDefault(PER_SHARD_COL_STATS, Map.of());
return perShardColStats.get(shard);
}
@@ -326,7 +324,7 @@ public class ExactStatsCache extends StatsCache {
@SuppressWarnings({"unchecked"})
Map<String, Map<String, TermStats>> perShardTermStats =
(Map<String, Map<String, TermStats>>)
- req.getContext().getOrDefault(PER_SHARD_TERM_STATS, Collections.emptyMap());
+ req.getContext().getOrDefault(PER_SHARD_TERM_STATS, Map.of());
Map<String, TermStats> cache = perShardTermStats.get(shard);
return (cache != null) ? cache.get(t) : null; // Term doesn't exist in shard
}
@@ -390,7 +388,7 @@ public class ExactStatsCache extends StatsCache {
TermStats termStats = termStatsCache.get(term.toString());
// TermStats == null is also true if term has no docFreq anyway,
// see returnLocalStats, if docFreq == 0, they are not added anyway
- // Not sure we need a warning here
+ // Not sure if we need a warning here
if (termStats == null) {
log.debug("Missing global termStats info for term={}, using local stats", term);
metrics.missingGlobalTermStats.increment();
diff --git a/solr/core/src/java/org/apache/solr/search/vector/AbstractVectorQParserBase.java b/solr/core/src/java/org/apache/solr/search/vector/AbstractVectorQParserBase.java
index ec5426d6d93..3c9a6bc3c9d 100644
--- a/solr/core/src/java/org/apache/solr/search/vector/AbstractVectorQParserBase.java
+++ b/solr/core/src/java/org/apache/solr/search/vector/AbstractVectorQParserBase.java
@@ -18,7 +18,6 @@ package org.apache.solr.search.vector;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import org.apache.lucene.search.Query;
import org.apache.solr.common.SolrException;
@@ -172,7 +171,7 @@ public abstract class AbstractVectorQParserBase extends QParser {
// means we should replace globalFQs (even with a possibly empty list)
globalFQs = new ArrayList<>(QueryUtils.getTaggedQueries(req, includedGlobalFQTags));
}
- if (null != excludedGlobalFQTags) {
+ if (!excludedGlobalFQTags.isEmpty()) {
globalFQs.removeAll(QueryUtils.getTaggedQueries(req, excludedGlobalFQTags));
}
@@ -192,7 +191,7 @@ public abstract class AbstractVectorQParserBase extends QParser {
private List<String> getLocalParamTags(final String param) {
final String[] strVals = localParams.getParams(param);
if (null == strVals) {
- return Collections.emptyList();
+ return List.of();
}
final List<String> tags = new ArrayList<>(strVals.length * 2);
for (String val : strVals) {
diff --git a/solr/core/src/java/org/apache/solr/security/AllowListUrlChecker.java b/solr/core/src/java/org/apache/solr/security/AllowListUrlChecker.java
index 0076cf1f41f..039ce146f4d 100644
--- a/solr/core/src/java/org/apache/solr/security/AllowListUrlChecker.java
+++ b/solr/core/src/java/org/apache/solr/security/AllowListUrlChecker.java
@@ -56,7 +56,7 @@ public class AllowListUrlChecker {
static {
try {
ALLOW_ALL =
- new AllowListUrlChecker(Collections.emptyList()) {
+ new AllowListUrlChecker(List.of()) {
@Override
public void checkAllowList(List<String> urls, ClusterState clusterState) {
// Allow.
@@ -207,7 +207,7 @@ public class AllowListUrlChecker {
@VisibleForTesting
static Set<String> parseHostPorts(List<String> urls) throws MalformedURLException {
if (urls == null || urls.isEmpty()) {
- return Collections.emptySet();
+ return Set.of();
}
Set<String> hostPorts = new HashSet<>();
for (String urlString : urls) {
diff --git a/solr/core/src/java/org/apache/solr/security/ExternalRoleRuleBasedAuthorizationPlugin.java b/solr/core/src/java/org/apache/solr/security/ExternalRoleRuleBasedAuthorizationPlugin.java
index d58b6582806..2172ee8ee41 100644
--- a/solr/core/src/java/org/apache/solr/security/ExternalRoleRuleBasedAuthorizationPlugin.java
+++ b/solr/core/src/java/org/apache/solr/security/ExternalRoleRuleBasedAuthorizationPlugin.java
@@ -17,7 +17,6 @@
package org.apache.solr.security;
import java.security.Principal;
-import java.util.Collections;
import java.util.Map;
import java.util.Set;
import org.apache.solr.common.SolrException;
@@ -48,7 +47,7 @@ public class ExternalRoleRuleBasedAuthorizationPlugin extends RuleBasedAuthoriza
if (principal instanceof VerifiedUserRoles) {
return ((VerifiedUserRoles) principal).getVerifiedRoles();
} else {
- return Collections.emptySet();
+ return Set.of();
}
}
}
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.java
index 4fc1718ae64..bc681685981 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
@@ -103,7 +103,7 @@ public class PathBasedCertPrincipalResolver extends PathBasedCertResolverBase
public PathBasedCertPrincipalResolver(Map<String, Object> params) {
this.pattern = createCertResolverPattern(params, CertUtil.SUBJECT_DN_PREFIX);
Map<String, String> extractConfig =
- (Map<String, String>) params.getOrDefault(PARAM_EXTRACT, Collections.emptyMap());
+ (Map<String, String>) params.getOrDefault(PARAM_EXTRACT, Map.of());
this.startPattern = extractConfig.getOrDefault(PARAM_AFTER, "");
this.endPattern = extractConfig.getOrDefault(PARAM_BEFORE, "");
}
@@ -124,7 +124,7 @@ public class PathBasedCertPrincipalResolver extends PathBasedCertResolverBase
getValuesFromPaths(certificate, Collections.singletonList(pattern));
String basePrincipal = null;
if (matches != null && !matches.isEmpty()) {
- Set<String> fieldValues = matches.getOrDefault(pattern.getName(), Collections.emptySet());
+ Set<String> fieldValues = matches.getOrDefault(pattern.getName(), Set.of());
basePrincipal = fieldValues.stream().findFirst().orElse(null);
}
diff --git a/solr/core/src/java/org/apache/solr/security/cert/PathBasedCertResolverBase.java b/solr/core/src/java/org/apache/solr/security/cert/PathBasedCertResolverBase.java
index 486a1193b8b..8ba17b471e3 100644
--- a/solr/core/src/java/org/apache/solr/security/cert/PathBasedCertResolverBase.java
+++ b/solr/core/src/java/org/apache/solr/security/cert/PathBasedCertResolverBase.java
@@ -24,7 +24,6 @@ import static org.apache.solr.security.cert.CertUtil.SUBJECT_DN_PREFIX;
import java.lang.invoke.MethodHandles;
import java.security.cert.CertificateParsingException;
import java.security.cert.X509Certificate;
-import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
@@ -64,14 +63,12 @@ public abstract class PathBasedCertResolverBase {
Map<String, Object> config, String defaultPath) {
String path = ((String) config.getOrDefault(PARAM_PATH, defaultPath)).toLowerCase(Locale.ROOT);
String name = ((String) config.getOrDefault(PARAM_NAME, path)).toLowerCase(Locale.ROOT);
- Map<String, Object> filter =
- (Map<String, Object>) config.getOrDefault(PARAM_FILTER, Collections.emptyMap());
+ Map<String, Object> filter = (Map<String, Object>) config.getOrDefault(PARAM_FILTER, Map.of());
String checkType =
(String)
filter.getOrDefault(
PARAM_FILTER_CHECK_TYPE, CertResolverPattern.CheckType.WILDCARD.toString());
- List<String> values =
- (List<String>) filter.getOrDefault(PARAM_FILTER_VALUES, Collections.emptyList());
+ List<String> values = (List<String>) filter.getOrDefault(PARAM_FILTER_VALUES, List.of());
Set<String> lowerCaseValues =
values.stream().map(value -> value.toLowerCase(Locale.ROOT)).collect(Collectors.toSet());
return new CertResolverPattern(name, path, checkType, lowerCaseValues);
diff --git a/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java b/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java
index 81d439dd2ec..ae042c7343b 100644
--- a/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java
+++ b/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java
@@ -194,7 +194,7 @@ public class HttpSolrCall {
/** The collection(s) referenced in this request. Populated in {@link #init()}. Not null. */
public List<String> getCollectionsList() {
- return collectionsList != null ? collectionsList : Collections.emptyList();
+ return collectionsList != null ? collectionsList : List.of();
}
@SuppressForbidden(
@@ -350,7 +350,7 @@ public class HttpSolrCall {
*/
protected List<String> resolveCollectionListOrAlias(String collectionStr) {
if (collectionStr == null || collectionStr.trim().isEmpty()) {
- return Collections.emptyList();
+ return List.of();
}
List<String> result = null;
LinkedHashSet<String> uniqueList = null;
@@ -650,7 +650,7 @@ public class HttpSolrCall {
solrParams = SolrRequestParsers.parseQueryString(req.getQueryString());
} else {
// we have no params at all, use empty ones:
- solrParams = new MapSolrParams(Collections.emptyMap());
+ solrParams = new MapSolrParams(Map.of());
}
solrReq = new SolrQueryRequestBase(core, solrParams) {};
}
@@ -1060,7 +1060,7 @@ public class HttpSolrCall {
public List<CommandOperation> getCommands(boolean validateInput) {
if (parsedCommands == null) {
Iterable<ContentStream> contentStreams = solrReq.getContentStreams();
- if (contentStreams == null) parsedCommands = Collections.emptyList();
+ if (contentStreams == null) parsedCommands = List.of();
else {
parsedCommands =
ApiBag.getCommandOperations(
@@ -1075,7 +1075,7 @@ public class HttpSolrCall {
}
protected Map<String, JsonSchemaValidator> getValidators() {
- return Collections.emptyMap();
+ return Map.of();
}
/**
diff --git a/solr/core/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java b/solr/core/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java
index 1e8d280abcb..25cb239b2e0 100644
--- a/solr/core/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java
+++ b/solr/core/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java
@@ -19,7 +19,6 @@ package org.apache.solr.spelling;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Arrays;
-import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.apache.lucene.index.IndexReader;
@@ -142,7 +141,7 @@ public abstract class AbstractLuceneSpellChecker extends SolrSpellChecker {
int count = Math.max(options.count, AbstractLuceneSpellChecker.DEFAULT_SUGGESTION_COUNT);
for (Token token : options.tokens) {
if (token.length() == 0) {
- result.add(token, Collections.emptyList());
+ result.add(token, List.of());
continue;
}
String tokenText = new String(token.buffer(), 0, token.length());
@@ -194,7 +193,7 @@ public abstract class AbstractLuceneSpellChecker extends SolrSpellChecker {
result.add(token, suggestions[i], reader.docFreq(term));
}
} else {
- List<String> suggList = Collections.emptyList();
+ List<String> suggList = List.of();
result.add(token, suggList);
}
} else {
@@ -205,7 +204,7 @@ public abstract class AbstractLuceneSpellChecker extends SolrSpellChecker {
}
result.add(token, suggList);
} else {
- List<String> suggList = Collections.emptyList();
+ List<String> suggList = List.of();
result.add(token, suggList);
}
}
diff --git a/solr/core/src/java/org/apache/solr/spelling/ConjunctionSolrSpellChecker.java b/solr/core/src/java/org/apache/solr/spelling/ConjunctionSolrSpellChecker.java
index 8e72558bfa0..e031ade9938 100644
--- a/solr/core/src/java/org/apache/solr/spelling/ConjunctionSolrSpellChecker.java
+++ b/solr/core/src/java/org/apache/solr/spelling/ConjunctionSolrSpellChecker.java
@@ -18,7 +18,6 @@ package org.apache.solr.spelling;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
@@ -172,7 +171,7 @@ public class ConjunctionSolrSpellChecker extends SolrSpellChecker {
}
if (!anyData) {
if (numberAdded == 0) {
- combinedResult.add(original, Collections.<String>emptyList());
+ combinedResult.add(original, List.of());
Integer tokenFrequency = combinedTokenFrequency.get(original);
combinedResult.addFrequency(original, tokenFrequency == null ? 0 : tokenFrequency);
}
diff --git a/solr/core/src/java/org/apache/solr/spelling/DirectSolrSpellChecker.java b/solr/core/src/java/org/apache/solr/spelling/DirectSolrSpellChecker.java
index 9c157729ad1..7ac64e86a23 100644
--- a/solr/core/src/java/org/apache/solr/spelling/DirectSolrSpellChecker.java
+++ b/solr/core/src/java/org/apache/solr/spelling/DirectSolrSpellChecker.java
@@ -19,7 +19,6 @@ package org.apache.solr.spelling;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.apache.lucene.index.Term;
@@ -192,7 +191,7 @@ public class DirectSolrSpellChecker extends SolrSpellChecker {
for (Token token : options.tokens) {
if (token.length() == 0) {
- result.add(token, Collections.emptyList());
+ result.add(token, List.of());
continue;
}
String tokenText = token.toString();
@@ -227,7 +226,7 @@ public class DirectSolrSpellChecker extends SolrSpellChecker {
}
}
if (suggestions.length == 0 && freq == 0) {
- List<String> empty = Collections.emptyList();
+ List<String> empty = List.of();
result.add(token, empty);
} else {
for (SuggestWord suggestion : suggestions) {
diff --git a/solr/core/src/java/org/apache/solr/spelling/SpellingQueryConverter.java b/solr/core/src/java/org/apache/solr/spelling/SpellingQueryConverter.java
index 95d96da350f..6870459a377 100644
--- a/solr/core/src/java/org/apache/solr/spelling/SpellingQueryConverter.java
+++ b/solr/core/src/java/org/apache/solr/spelling/SpellingQueryConverter.java
@@ -19,7 +19,7 @@ package org.apache.solr.spelling;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
+import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.lucene.analysis.TokenStream;
@@ -103,7 +103,7 @@ public class SpellingQueryConverter extends QueryConverter {
@Override
public Collection<Token> convert(String original) {
if (original == null) { // this can happen with q.alt = and no query
- return Collections.emptyList();
+ return List.of();
}
boolean mightContainRangeQuery =
(original.indexOf('[') != -1 || original.indexOf('{') != -1)
diff --git a/solr/core/src/java/org/apache/solr/spelling/SuggestQueryConverter.java b/solr/core/src/java/org/apache/solr/spelling/SuggestQueryConverter.java
index 4d78f7c68de..da0bcbf3a55 100644
--- a/solr/core/src/java/org/apache/solr/spelling/SuggestQueryConverter.java
+++ b/solr/core/src/java/org/apache/solr/spelling/SuggestQueryConverter.java
@@ -19,7 +19,7 @@ package org.apache.solr.spelling;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
+import java.util.List;
/** Passes the entire query string to the configured analyzer as-is. */
public class SuggestQueryConverter extends SpellingQueryConverter {
@@ -27,7 +27,7 @@ public class SuggestQueryConverter extends SpellingQueryConverter {
@Override
public Collection<Token> convert(String original) {
if (original == null) { // this can happen with q.alt = and no query
- return Collections.emptyList();
+ return List.of();
}
Collection<Token> result = new ArrayList<>();
diff --git a/solr/core/src/java/org/apache/solr/spelling/WordBreakSolrSpellChecker.java b/solr/core/src/java/org/apache/solr/spelling/WordBreakSolrSpellChecker.java
index 5689507c034..1095acc2bd4 100644
--- a/solr/core/src/java/org/apache/solr/spelling/WordBreakSolrSpellChecker.java
+++ b/solr/core/src/java/org/apache/solr/spelling/WordBreakSolrSpellChecker.java
@@ -18,7 +18,6 @@ package org.apache.solr.spelling;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
@@ -219,7 +218,7 @@ public class WordBreakSolrSpellChecker extends SolrSpellChecker {
}
breakSuggestionList.addAll(noBreakSuggestionList);
- List<ResultEntry> combineSuggestionList = Collections.emptyList();
+ List<ResultEntry> combineSuggestionList = List.of();
CombineSuggestion[] combineSuggestions =
wbsp.suggestWordCombinations(
termArr.toArray(new Term[0]), numSuggestions, ir, options.suggestMode);
@@ -322,7 +321,7 @@ public class WordBreakSolrSpellChecker extends SolrSpellChecker {
String suggestion,
int suggestionFrequency) {
if (suggestion == null) {
- result.add(token, Collections.<String>emptyList());
+ result.add(token, List.of());
result.addFrequency(token, tokenFrequency);
} else {
result.add(token, suggestion, suggestionFrequency);
diff --git a/solr/core/src/java/org/apache/solr/spelling/suggest/SolrSuggester.java b/solr/core/src/java/org/apache/solr/spelling/suggest/SolrSuggester.java
index 1498ede4628..34a51f66b3e 100644
--- a/solr/core/src/java/org/apache/solr/spelling/suggest/SolrSuggester.java
+++ b/solr/core/src/java/org/apache/solr/spelling/suggest/SolrSuggester.java
@@ -25,7 +25,7 @@ import java.lang.invoke.MethodHandles;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collection;
-import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.standard.StandardTokenizerFactory;
@@ -108,7 +108,7 @@ public class SolrSuggester implements Accountable {
}
contextFilterQueryAnalyzer =
- new TokenizerChain(new StandardTokenizerFactory(Collections.emptyMap()), null);
+ new TokenizerChain(new StandardTokenizerFactory(new HashMap<>()), null);
// initialize appropriate lookup instance
factory = core.getResourceLoader().newInstance(lookupImpl, LookupFactory.class);
diff --git a/solr/core/src/java/org/apache/solr/update/SolrIndexConfig.java b/solr/core/src/java/org/apache/solr/update/SolrIndexConfig.java
index 19a8e0135b9..30e7687eda2 100644
--- a/solr/core/src/java/org/apache/solr/update/SolrIndexConfig.java
+++ b/solr/core/src/java/org/apache/solr/update/SolrIndexConfig.java
@@ -21,7 +21,6 @@ import static org.apache.solr.core.XmlConfigFile.assertWarnOrFail;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
-import java.util.Collections;
import java.util.Map;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.DelegatingAnalyzerWrapper;
@@ -109,7 +108,7 @@ public class SolrIndexConfig implements MapSerializable {
mergeSchedulerInfo = null;
mergedSegmentWarmerInfo = null;
// enable coarse-grained metrics by default
- metricsInfo = new PluginInfo("metrics", Collections.emptyMap(), null, null);
+ metricsInfo = new PluginInfo("metrics", Map.of(), null, null);
}
private ConfigNode get(String s) {
diff --git a/solr/core/src/java/org/apache/solr/update/processor/AddSchemaFieldsUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/AddSchemaFieldsUpdateProcessorFactory.java
index 50c711458c9..9875961cca4 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/AddSchemaFieldsUpdateProcessorFactory.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/AddSchemaFieldsUpdateProcessorFactory.java
@@ -24,7 +24,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;
@@ -131,7 +130,7 @@ public class AddSchemaFieldsUpdateProcessorFactory extends UpdateRequestProcesso
private static final String MAX_CHARS_PARAM = "maxChars";
private static final String IS_DEFAULT_PARAM = "default";
- private List<TypeMapping> typeMappings = Collections.emptyList();
+ private List<TypeMapping> typeMappings = List.of();
private SelectorParams inclusions = new SelectorParams();
private Collection<SelectorParams> exclusions = new ArrayList<>();
private SolrResourceLoader solrResourceLoader = null;
@@ -450,7 +449,7 @@ public class AddSchemaFieldsUpdateProcessorFactory extends UpdateRequestProcesso
.collect(Collectors.groupingBy(CopyFieldDef::getMaxChars)));
}
}
- newFields.add(oldSchema.newField(fieldName, fieldTypeName, Collections.emptyMap()));
+ newFields.add(oldSchema.newField(fieldName, fieldTypeName, Map.of()));
}
if (newFields.isEmpty() && newCopyFields.isEmpty()) {
// nothing to do - no fields will be added - exit from the retry loop
@@ -494,7 +493,7 @@ public class AddSchemaFieldsUpdateProcessorFactory extends UpdateRequestProcesso
// the schema on the request is the latest
synchronized (oldSchema.getSchemaUpdateLock()) {
try {
- IndexSchema newSchema = oldSchema.addFields(newFields, Collections.emptyMap(), false);
+ IndexSchema newSchema = oldSchema.addFields(newFields, Map.of(), false);
// Add copyFields
for (Map.Entry<String, Map<Integer, List<CopyFieldDef>>> entry :
newCopyFields.entrySet()) {
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.java
index dfee7e1f8f7..f93c729695d 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
@@ -243,7 +243,7 @@ public class AtomicUpdateDocumentMerger {
// if _version_ field is not supported for in-place update, bail out early
SchemaField versionField = schema.getFieldOrNull(CommonParams.VERSION_FIELD);
if (versionField == null || !isSupportedFieldForInPlaceUpdate(versionField)) {
- return Collections.emptySet();
+ return Set.of();
}
String routeFieldOrNull = getRouteField(cmd);
@@ -266,7 +266,7 @@ public class AtomicUpdateDocumentMerger {
}
if (!(fieldValue instanceof Map)) {
// not an in-place update if there are fields that are not maps
- return Collections.emptySet();
+ return Set.of();
}
// else it's an atomic update map...
Map<String, Object> fieldValueMap = (Map<String, Object>) fieldValue;
@@ -275,23 +275,23 @@ public class AtomicUpdateDocumentMerger {
Object obj = entry.getValue();
if (!op.equals("set") && !op.equals("inc")) {
// not a supported in-place update op
- return Collections.emptySet();
+ return Set.of();
} else if (op.equals("set")
&& (obj == null || (obj instanceof Collection && ((Collection) obj).isEmpty()))) {
// when operation is set and value is either null or empty list
// treat the update as atomic instead of inplace
- return Collections.emptySet();
+ return Set.of();
}
// fail fast if child doc
if (isChildDoc(((Map<String, Object>) fieldValue).get(op))) {
- return Collections.emptySet();
+ return Set.of();
}
}
candidateFields.add(fieldName);
}
if (candidateFields.isEmpty()) {
- return Collections.emptySet();
+ return Set.of();
}
// second pass over the candidates for in-place updates
@@ -300,13 +300,12 @@ public class AtomicUpdateDocumentMerger {
SchemaField schemaField = schema.getField(fieldName);
if (!isSupportedFieldForInPlaceUpdate(schemaField)) {
- return Collections.emptySet();
+ return Set.of();
}
// if this field has copy target which is not supported for in place, then empty
for (CopyField copyField : schema.getCopyFieldsList(fieldName)) {
- if (!isSupportedFieldForInPlaceUpdate(copyField.getDestination()))
- return Collections.emptySet();
+ if (!isSupportedFieldForInPlaceUpdate(copyField.getDestination())) return Set.of();
}
}
@@ -323,7 +322,7 @@ public class AtomicUpdateDocumentMerger {
}
for (String fieldName : candidateFields) {
if (segmentSortingFields.contains(fieldName)) {
- return Collections.emptySet(); // if this is used for segment sorting, DV updates can't work
+ return Set.of(); // if this is used for segment sorting, DV updates can't work
}
}
@@ -497,7 +496,7 @@ public class AtomicUpdateDocumentMerger {
.orElseGet(
() -> {
final SolrInputField replacement = new SolrInputField(name);
- replacement.setValue(Collections.emptyList());
+ replacement.setValue(List.of());
return replacement;
});
diff --git a/solr/core/src/java/org/apache/solr/update/processor/DocBasedVersionConstraintsProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/DocBasedVersionConstraintsProcessorFactory.java
index c7fbcc88892..90307f9dc38 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/DocBasedVersionConstraintsProcessorFactory.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/DocBasedVersionConstraintsProcessorFactory.java
@@ -19,7 +19,6 @@ package org.apache.solr.update.processor;
import static org.apache.solr.common.SolrException.ErrorCode.SERVER_ERROR;
import java.lang.invoke.MethodHandles;
-import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@@ -89,7 +88,7 @@ public class DocBasedVersionConstraintsProcessorFactory extends UpdateRequestPro
private boolean ignoreOldUpdates = false;
private List<String> versionFields = null;
- private List<String> deleteVersionParamNames = Collections.emptyList();
+ private List<String> deleteVersionParamNames = List.of();
private boolean useFieldCache;
private boolean supportMissingVersionOnOldDocs = false;
private NamedList<Object> tombstoneConfig;
diff --git a/solr/core/src/java/org/apache/solr/update/processor/FieldMutatingUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/FieldMutatingUpdateProcessorFactory.java
index 97a246278ba..ad937a51ca9 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/FieldMutatingUpdateProcessorFactory.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/FieldMutatingUpdateProcessorFactory.java
@@ -20,7 +20,6 @@ import static org.apache.solr.update.processor.FieldMutatingUpdateProcessor.SELE
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -100,10 +99,10 @@ public abstract class FieldMutatingUpdateProcessorFactory extends UpdateRequestP
implements SolrCoreAware {
public static final class SelectorParams {
- public Set<String> fieldName = Collections.emptySet();
- public Set<String> typeName = Collections.emptySet();
- public Collection<String> typeClass = Collections.emptyList();
- public Collection<Pattern> fieldRegex = Collections.emptyList();
+ public Set<String> fieldName = Set.of();
+ public Set<String> typeName = Set.of();
+ public Collection<String> typeClass = List.of();
+ public Collection<Pattern> fieldRegex = List.of();
public Boolean fieldNameMatchesSchemaField = null; // null => not specified
public boolean noSelectorsSpecified() {
diff --git a/solr/core/src/java/org/apache/solr/update/processor/SkipExistingDocumentsProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/SkipExistingDocumentsProcessorFactory.java
index 4e55fc3e01b..b93d2ef2527 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/SkipExistingDocumentsProcessorFactory.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/SkipExistingDocumentsProcessorFactory.java
@@ -21,7 +21,7 @@ import static org.apache.solr.update.processor.DistributingUpdateProcessorFactor
import java.io.IOException;
import java.lang.invoke.MethodHandles;
-import java.util.Collections;
+import java.util.Set;
import org.apache.lucene.util.BytesRef;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrInputDocument;
@@ -43,9 +43,9 @@ import org.slf4j.LoggerFactory;
* there already exists a document with the same uniqueKey value in the index. It will also skip
* Atomic Updates to a document if that document does not already exist. This behaviour is applied
* to each document in turn, so adding a batch of documents can result in some being added and some
- * ignored, depending on what is already in the index. If all of the documents are skipped, no
- * changes to the index will occur. These two forms of skipping can be switched on or off
- * independently, by using init params:
+ * ignored, depending on what is already in the index. If all the documents are skipped, no changes
+ * to the index will occur. These two forms of skipping can be switched on or off independently, by
+ * using init params:
*
* <ul>
* <li><code>skipInsertIfExists</code> - This boolean parameter defaults to <code>true</code>, but
@@ -197,11 +197,7 @@ public class SkipExistingDocumentsProcessorFactory extends UpdateRequestProcesso
// we don't need any fields populated, we just need to know if the doc is in the tlog...
SolrInputDocument oldDoc =
RealTimeGetComponent.getInputDocumentFromTlog(
- core,
- indexedDocId,
- null,
- Collections.emptySet(),
- RealTimeGetComponent.Resolution.PARTIAL);
+ core, indexedDocId, null, Set.of(), RealTimeGetComponent.Resolution.PARTIAL);
if (oldDoc == RealTimeGetComponent.DELETED) {
return false;
}
diff --git a/solr/core/src/java/org/apache/solr/update/processor/TemplateUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/TemplateUpdateProcessorFactory.java
index bffae948cdc..f37e4a4c419 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/TemplateUpdateProcessorFactory.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/TemplateUpdateProcessorFactory.java
@@ -18,7 +18,6 @@
package org.apache.solr.update.processor;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.function.Function;
import java.util.regex.Matcher;
@@ -100,7 +99,7 @@ public class TemplateUpdateProcessorFactory extends SimpleUpdateProcessorFactory
String template, Cache<String, Resolved> cache, Pattern pattern) {
Resolved r = getResolved(template, cache, pattern);
if (r == null) {
- return Collections.emptyList();
+ return List.of();
}
return new ArrayList<>(r.variables);
}
diff --git a/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessorChain.java b/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessorChain.java
index f7f5cba5852..c842a3c9683 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessorChain.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessorChain.java
@@ -18,7 +18,6 @@ package org.apache.solr.update.processor;
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;
@@ -294,7 +293,7 @@ public final class UpdateRequestProcessorChain implements PluginInfoInitialized
}
static List<UpdateRequestProcessorFactory> getReqProcessors(String processor, SolrCore core) {
- if (processor == null) return Collections.emptyList();
+ if (processor == null) return List.of();
List<UpdateRequestProcessorFactory> result = new ArrayList<>();
List<String> names = StrUtils.splitSmart(processor, ',');
for (String s : names) {
diff --git a/solr/core/src/java/org/apache/solr/util/ConcurrentLRUCache.java b/solr/core/src/java/org/apache/solr/util/ConcurrentLRUCache.java
index 8b3aef7130c..a32b6158000 100644
--- a/solr/core/src/java/org/apache/solr/util/ConcurrentLRUCache.java
+++ b/solr/core/src/java/org/apache/solr/util/ConcurrentLRUCache.java
@@ -817,7 +817,7 @@ public class ConcurrentLRUCache<K, V> implements Cache<K, V>, Accountable {
@Override
public Collection<Accountable> getChildResources() {
- return Collections.emptyList();
+ return List.of();
}
}
@@ -969,6 +969,6 @@ public class ConcurrentLRUCache<K, V> implements Cache<K, V>, Accountable {
@Override
public Collection<Accountable> getChildResources() {
- return Collections.emptyList();
+ return List.of();
}
}
diff --git a/solr/core/src/java/org/apache/solr/util/ModuleUtils.java b/solr/core/src/java/org/apache/solr/util/ModuleUtils.java
index 4ff0836b562..5039d7d65bd 100644
--- a/solr/core/src/java/org/apache/solr/util/ModuleUtils.java
+++ b/solr/core/src/java/org/apache/solr/util/ModuleUtils.java
@@ -21,7 +21,7 @@ import java.lang.invoke.MethodHandles;
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.Set;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -56,7 +56,7 @@ public class ModuleUtils {
* @return set of raw volume names from sysprop and/or env.var
*/
static Set<String> resolveFromSyspropOrEnv() {
- return Set.copyOf(EnvUtils.getPropertyAsList("solr.modules", Collections.emptyList()));
+ return Set.copyOf(EnvUtils.getPropertyAsList("solr.modules", List.of()));
}
/** Returns true if a module name is valid and exists in the system */
@@ -75,7 +75,7 @@ public class ModuleUtils {
.collect(Collectors.toSet());
} catch (IOException e) {
log.warn("Found no modules in {}", getModulesPath(solrInstallDirPath), e);
- return Collections.emptySet();
+ return Set.of();
}
}
diff --git a/solr/core/src/test/org/apache/solr/analysis/TokenizerChainTest.java b/solr/core/src/test/org/apache/solr/analysis/TokenizerChainTest.java
index 5a8cc2bf656..ca3a4bcc7cf 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TokenizerChainTest.java
+++ b/solr/core/src/test/org/apache/solr/analysis/TokenizerChainTest.java
@@ -16,7 +16,7 @@
*/
package org.apache.solr.analysis;
-import java.util.Collections;
+import java.util.HashMap;
import org.apache.lucene.analysis.TokenFilterFactory;
import org.apache.lucene.analysis.core.LowerCaseFilterFactory;
import org.apache.lucene.analysis.miscellaneous.ASCIIFoldingFilterFactory;
@@ -30,10 +30,10 @@ public class TokenizerChainTest extends SolrTestCaseJ4 {
public void testNormalization() {
String fieldName = "f";
TokenFilterFactory[] tff = new TokenFilterFactory[2];
- tff[0] = new LowerCaseFilterFactory(Collections.emptyMap());
- tff[1] = new ASCIIFoldingFilterFactory(Collections.emptyMap());
+ tff[0] = new LowerCaseFilterFactory(new HashMap<>());
+ tff[1] = new ASCIIFoldingFilterFactory(new HashMap<>());
TokenizerChain tokenizerChain =
- new TokenizerChain(new MockTokenizerFactory(Collections.emptyMap()), tff);
+ new TokenizerChain(new MockTokenizerFactory(new HashMap<>()), tff);
assertEquals(new BytesRef("fooba"), tokenizerChain.normalize(fieldName, "FOOB\u00c4"));
tokenizerChain.close();
}
diff --git a/solr/core/src/test/org/apache/solr/cli/PostToolTest.java b/solr/core/src/test/org/apache/solr/cli/PostToolTest.java
index dc9e7226dfb..a238bd62c15 100644
--- a/solr/core/src/test/org/apache/solr/cli/PostToolTest.java
+++ b/solr/core/src/test/org/apache/solr/cli/PostToolTest.java
@@ -28,9 +28,9 @@ import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.solr.SolrTestCaseJ4;
@@ -336,7 +336,7 @@ public class PostToolTest extends SolrCloudTestCase {
assertEquals(3, num);
// Without respecting robots.txt
- postTool.pageFetcher.robotsCache.put("[ff01::114]", Collections.emptyList());
+ postTool.pageFetcher.robotsCache.put("[ff01::114]", List.of());
postTool.recursive = 5;
num = postTool.postWebPages(new String[] {"http://[ff01::114]/#removeme"}, 0, null);
assertEquals(6, num);
diff --git a/solr/core/src/test/org/apache/solr/cloud/CollectionPropsTest.java b/solr/core/src/test/org/apache/solr/cloud/CollectionPropsTest.java
index 87f71cc0570..88e35bb3ef4 100644
--- a/solr/core/src/test/org/apache/solr/cloud/CollectionPropsTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/CollectionPropsTest.java
@@ -20,7 +20,6 @@ package org.apache.solr.cloud;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.nio.charset.StandardCharsets;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
@@ -290,7 +289,7 @@ public class CollectionPropsTest extends SolrCloudTestCase {
private class Watcher implements CollectionPropsWatcher {
private final String name;
private final boolean forceReadPropsFromZk;
- private volatile Map<String, String> props = Collections.emptyMap();
+ private volatile Map<String, String> props = Map.of();
private final AtomicInteger triggered = new AtomicInteger();
public Watcher(final String name, final boolean forceReadPropsFromZk) {
diff --git a/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java b/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java
index c0d11b5c34f..d0d10fda029 100644
--- a/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java
@@ -19,9 +19,9 @@ package org.apache.solr.cloud;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
@@ -877,7 +877,7 @@ public class FullSolrCloudDistribCmdsTest extends SolrCloudTestCase {
}
assertEquals(
"inconsistency w/leader: shard=" + shardName + "core=" + replica.getCoreName(),
- Collections.emptySet(),
+ Set.of(),
CloudInspectUtil.showDiff(
leaderResults,
replicaResults,
diff --git a/solr/core/src/test/org/apache/solr/cloud/MigrateReplicasTest.java b/solr/core/src/test/org/apache/solr/cloud/MigrateReplicasTest.java
index 610ba8aa314..09e81e6107d 100644
--- a/solr/core/src/test/org/apache/solr/cloud/MigrateReplicasTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/MigrateReplicasTest.java
@@ -261,7 +261,7 @@ public class MigrateReplicasTest extends SolrCloudTestCase {
callMigrateReplicas(
cloudClient,
new MigrateReplicasRequestBody(
- new HashSet<>(nodesToBeDecommissioned), Collections.emptySet(), true, null));
+ new HashSet<>(nodesToBeDecommissioned), Set.of(), true, null));
assertEquals(
"MigrateReplicas request was unsuccessful",
0L,
@@ -305,8 +305,7 @@ public class MigrateReplicasTest extends SolrCloudTestCase {
String liveNode = cloudClient.getClusterState().getLiveNodes().iterator().next();
Map<?, ?> response =
callMigrateReplicas(
- cloudClient,
- new MigrateReplicasRequestBody(Set.of(liveNode), Collections.emptySet(), true, null));
+ cloudClient, new MigrateReplicasRequestBody(Set.of(liveNode), Set.of(), true, null));
assertNotNull(
"No error in response, when the request should have failed", response.get("error"));
assertEquals(
diff --git a/solr/core/src/test/org/apache/solr/cloud/NodeRolesTest.java b/solr/core/src/test/org/apache/solr/cloud/NodeRolesTest.java
index 8d1a9858181..c6380525216 100644
--- a/solr/core/src/test/org/apache/solr/cloud/NodeRolesTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/NodeRolesTest.java
@@ -19,7 +19,7 @@ package org.apache.solr.cloud;
import java.io.IOException;
import java.util.Collection;
-import java.util.Collections;
+import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.apache.solr.client.solrj.SolrServerException;
@@ -106,8 +106,7 @@ public class NodeRolesTest extends SolrCloudTestCase {
String path = nodenamePaths[i + 1];
assertTrue(
"Didn't find " + nodename + " at " + path + ". Full response: " + rsp.jsonStr(),
- ((Collection) Objects.requireNonNullElse(rsp._get(path), Collections.emptyList()))
- .contains(nodename));
+ ((Collection) Objects.requireNonNullElse(rsp._get(path), List.of())).contains(nodename));
}
}
@@ -120,8 +119,7 @@ public class NodeRolesTest extends SolrCloudTestCase {
.process(cluster.getSolrClient());
Map<String, Object> l =
- (Map<String, Object>)
- Objects.requireNonNullElse(rsp._get("supported-roles"), Collections.emptyMap());
+ (Map<String, Object>) Objects.requireNonNullElse(rsp._get("supported-roles"), Map.of());
assertTrue(l.containsKey("data"));
assertTrue(l.containsKey("overseer"));
diff --git a/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionConfigSetProcessorTest.java b/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionConfigSetProcessorTest.java
index a64c485a9c7..9b5c8b30252 100644
--- a/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionConfigSetProcessorTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionConfigSetProcessorTest.java
@@ -351,7 +351,7 @@ public class OverseerCollectionConfigSetProcessorTest extends SolrTestCaseJ4 {
Thread.sleep(1000);
retries++;
}
- return Collections.emptyList();
+ return List.of();
});
when(workQueueMock.getTailId())
diff --git a/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java b/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java
index c982e143c20..644d47f96a1 100644
--- a/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java
@@ -1011,7 +1011,7 @@ public class OverseerTest extends SolrTestCaseJ4 {
new UpdateShardHandler(UpdateShardHandlerConfig.DEFAULT);
updateShardHandlers.add(updateShardHandler);
HttpShardHandlerFactory httpShardHandlerFactory = new HttpShardHandlerFactory();
- httpShardHandlerFactory.init(new PluginInfo("shardHandlerFactory", Collections.emptyMap()));
+ httpShardHandlerFactory.init(new PluginInfo("shardHandlerFactory", Map.of()));
httpShardHandlerFactorys.add(httpShardHandlerFactory);
Overseer overseer =
new Overseer(
@@ -1724,7 +1724,7 @@ public class OverseerTest extends SolrTestCaseJ4 {
new UpdateShardHandler(UpdateShardHandlerConfig.DEFAULT);
updateShardHandlers.add(updateShardHandler);
HttpShardHandlerFactory httpShardHandlerFactory = new HttpShardHandlerFactory();
- httpShardHandlerFactory.init(new PluginInfo("shardHandlerFactory", Collections.emptyMap()));
+ httpShardHandlerFactory.init(new PluginInfo("shardHandlerFactory", Map.of()));
httpShardHandlerFactorys.add(httpShardHandlerFactory);
// Set system property to ensure tests use Overseer mode
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPI.java b/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPI.java
index c720012adfd..a09737174ae 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPI.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPI.java
@@ -40,7 +40,6 @@ import java.security.Principal;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.Deque;
import java.util.HashSet;
import java.util.LinkedHashMap;
@@ -1728,7 +1727,7 @@ public class TestConfigSetsAPI extends SolrCloudTestCase {
@Override
public Map<String, String> getPromptHeaders() {
- return Collections.emptyMap();
+ return Map.of();
}
};
}
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestRandomFlRTGCloud.java b/solr/core/src/test/org/apache/solr/cloud/TestRandomFlRTGCloud.java
index a45413f2b46..615c925b1cc 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestRandomFlRTGCloud.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestRandomFlRTGCloud.java
@@ -1416,7 +1416,7 @@ public class TestRandomFlRTGCloud extends SolrCloudTestCase {
final SolrDocument actual,
final String wt) {
assertNull(fl, actual.getFirstValue(fieldName));
- return Collections.emptySet();
+ return Set.of();
}
}
diff --git a/solr/core/src/test/org/apache/solr/cloud/TriLevelCompositeIdRoutingTest.java b/solr/core/src/test/org/apache/solr/cloud/TriLevelCompositeIdRoutingTest.java
index 7e62974bd6f..6318cf52f23 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TriLevelCompositeIdRoutingTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TriLevelCompositeIdRoutingTest.java
@@ -17,7 +17,6 @@
package org.apache.solr.cloud;
import java.lang.invoke.MethodHandles;
-import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -114,7 +113,7 @@ public class TriLevelCompositeIdRoutingTest extends ShardRoutingTest {
uniqueKeysOnDuplicateShards.retainAll(actualUniqueKeys);
assertEquals(
shardId + " contains some uniqueKeys that were already found on a previous shard",
- Collections.emptySet(),
+ Set.of(),
uniqueKeysOnDuplicateShards);
actualUniqueKeys.addAll(uniqueKeysInShard);
}
diff --git a/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java
index 7e66787a4a5..ce003c19fb7 100644
--- a/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java
@@ -20,7 +20,7 @@ import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.nio.file.Path;
import java.util.Collection;
-import java.util.Collections;
+import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.SynchronousQueue;
@@ -103,7 +103,7 @@ public class UnloadDistributedZkTest extends AbstractFullDistribZkTestBase {
45,
TimeUnit.SECONDS,
c -> {
- final Collection<Slice> slices = (c != null) ? c.getSlices() : Collections.emptyList();
+ final Collection<Slice> slices = (c != null) ? c.getSlices() : List.of();
if (expectedSliceCount == slices.size()) {
for (Slice slice : slices) {
for (Replica replica : slice.getReplicas()) {
diff --git a/solr/core/src/test/org/apache/solr/cloud/VMParamsZkACLAndCredentialsProvidersTest.java b/solr/core/src/test/org/apache/solr/cloud/VMParamsZkACLAndCredentialsProvidersTest.java
index 81d36d45723..41fb1dd8071 100644
--- a/solr/core/src/test/org/apache/solr/cloud/VMParamsZkACLAndCredentialsProvidersTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/VMParamsZkACLAndCredentialsProvidersTest.java
@@ -27,7 +27,6 @@ import java.lang.invoke.MethodHandles;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
-import java.util.Collections;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
@@ -486,7 +485,7 @@ public class VMParamsZkACLAndCredentialsProvidersTest extends SolrTestCaseJ4 {
public static class NoCredentialZkCredentialsInjector implements ZkCredentialsInjector {
@Override
public List<ZkCredential> getZkCredentials() {
- return Collections.emptyList();
+ return List.of();
}
}
@@ -529,7 +528,7 @@ public class VMParamsZkACLAndCredentialsProvidersTest extends SolrTestCaseJ4 {
private final List<String> systemPropsValues;
public TestZkCredentialsInjector(Class<?> zkCredentialsInjectorClass) {
- this(zkCredentialsInjectorClass, Collections.emptyList(), Collections.emptyList());
+ this(zkCredentialsInjectorClass, List.of(), List.of());
}
public TestZkCredentialsInjector(
diff --git a/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java b/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java
index ebe2640bcb5..702c077a066 100644
--- a/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java
@@ -250,7 +250,7 @@ public class ZkControllerTest extends SolrCloudTestCase {
new CoreDescriptor(
collectionName,
TEST_PATH(),
- Collections.emptyMap(),
+ Map.of(),
new Properties(),
zkControllerRef.get());
// non-existent coreNodeName, this will cause zkController.publishAndWaitForDownStates
@@ -784,7 +784,7 @@ public class ZkControllerTest extends SolrCloudTestCase {
public MockCoreContainer() {
super(SolrXmlConfig.fromString(TEST_PATH(), "<solr/>"));
HttpShardHandlerFactory httpShardHandlerFactory = new HttpShardHandlerFactory();
- httpShardHandlerFactory.init(new PluginInfo("shardHandlerFactory", Collections.emptyMap()));
+ httpShardHandlerFactory.init(new PluginInfo("shardHandlerFactory", Map.of()));
this.shardHandlerFactory = httpShardHandlerFactory;
this.coreAdminHandler = new CoreAdminHandler();
this.metricManager = mock(SolrMetricManager.class);
diff --git a/solr/core/src/test/org/apache/solr/cloud/api/collections/SimpleCollectionCreateDeleteTest.java b/solr/core/src/test/org/apache/solr/cloud/api/collections/SimpleCollectionCreateDeleteTest.java
index 0b5d097d947..6b09a449e90 100644
--- a/solr/core/src/test/org/apache/solr/cloud/api/collections/SimpleCollectionCreateDeleteTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/api/collections/SimpleCollectionCreateDeleteTest.java
@@ -18,7 +18,6 @@ package org.apache.solr.cloud.api.collections;
import java.time.Instant;
import java.util.Collection;
-import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@@ -125,7 +124,7 @@ public class SimpleCollectionCreateDeleteTest extends AbstractFullDistribZkTestB
ClusterState.createFromCollectionMap(
0,
(Map<String, Object>) Utils.fromJSON(node.data),
- Collections.emptySet(),
+ Set.of(),
Instant.EPOCH,
() ->
PerReplicaStatesOps.fetch(
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.java
index 18090517636..96dd45b58b5 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
@@ -21,6 +21,7 @@ import static org.mockito.Mockito.when;
import java.util.Collections;
import java.util.Map;
+import java.util.Set;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.cloud.DistribStateManager;
import org.apache.solr.client.solrj.cloud.SolrCloudManager;
@@ -39,9 +40,7 @@ public class TestClusterStateMutator extends SolrTestCaseJ4 {
}
public void testCreateCollection() {
- ClusterState clusterState =
- new ClusterState(
- Collections.<String>emptySet(), Collections.<String, DocCollection>emptyMap());
+ ClusterState clusterState = new ClusterState(Set.of(), Map.of());
DistribStateManager mockStateManager = mock(DistribStateManager.class);
SolrCloudManager dataProvider = mock(SolrCloudManager.class);
when(dataProvider.getDistribStateManager()).thenReturn(mockStateManager);
@@ -57,9 +56,7 @@ public class TestClusterStateMutator extends SolrTestCaseJ4 {
assertEquals("xyz", collection.getName());
assertEquals(1, collection.getSlicesMap().size());
- ClusterState state =
- new ClusterState(
- Collections.<String>emptySet(), Collections.singletonMap("xyz", collection));
+ ClusterState state = new ClusterState(Set.of(), Collections.singletonMap("xyz", collection));
message =
new ZkNodeProps(
Map.of(
diff --git a/solr/core/src/test/org/apache/solr/cluster/placement/plugins/AffinityPlacementFactoryTest.java b/solr/core/src/test/org/apache/solr/cluster/placement/plugins/AffinityPlacementFactoryTest.java
index eaa1b0a0976..0dd6c451b17 100644
--- a/solr/core/src/test/org/apache/solr/cluster/placement/plugins/AffinityPlacementFactoryTest.java
+++ b/solr/core/src/test/org/apache/solr/cluster/placement/plugins/AffinityPlacementFactoryTest.java
@@ -779,7 +779,7 @@ public class AffinityPlacementFactoryTest extends AbstractPlacementFactoryTest {
.map(Shard::getShardName)
.findFirst()
.map(Set::of)
- .orElseGet(Collections::emptySet),
+ .orElseGet(Set::of),
cluster.getLiveNodes(),
ReplicaCount.of(0, 1, 1));
diff --git a/solr/core/src/test/org/apache/solr/core/CoreSorterTest.java b/solr/core/src/test/org/apache/solr/core/CoreSorterTest.java
index 48ea5d3b44a..78e8cae727f 100644
--- a/solr/core/src/test/org/apache/solr/core/CoreSorterTest.java
+++ b/solr/core/src/test/org/apache/solr/core/CoreSorterTest.java
@@ -138,7 +138,7 @@ public class CoreSorterTest extends SolrTestCaseJ4 {
}
Map<String, Replica> replicaMap =
replicas.stream().collect(Collectors.toMap(Replica::getName, Function.identity()));
- sliceMap.put(slice, new Slice(slice, replicaMap, Collections.emptyMap(), collection));
+ sliceMap.put(slice, new Slice(slice, replicaMap, Map.of(), collection));
}
@SuppressWarnings({"unchecked"})
DocCollection col =
diff --git a/solr/core/src/test/org/apache/solr/core/TestConfLoadPerf.java b/solr/core/src/test/org/apache/solr/core/TestConfLoadPerf.java
index c3f51417465..589c7e49f7e 100644
--- a/solr/core/src/test/org/apache/solr/core/TestConfLoadPerf.java
+++ b/solr/core/src/test/org/apache/solr/core/TestConfLoadPerf.java
@@ -25,7 +25,6 @@ import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.cloud.ZkSolrResourceLoader;
@@ -55,10 +54,7 @@ public class TestConfLoadPerf extends SolrTestCaseJ4 {
SolrResourceLoader srl =
new SolrResourceLoader(
- "temp",
- Collections.emptyList(),
- container.solrHome,
- container.getResourceLoader().classLoader) {
+ "temp", List.of(), container.solrHome, container.getResourceLoader().classLoader) {
// instance initializer block
{
diff --git a/solr/core/src/test/org/apache/solr/core/TestConfig.java b/solr/core/src/test/org/apache/solr/core/TestConfig.java
index 94bd4c74a30..0ba42bb156d 100644
--- a/solr/core/src/test/org/apache/solr/core/TestConfig.java
+++ b/solr/core/src/test/org/apache/solr/core/TestConfig.java
@@ -16,10 +16,9 @@
*/
package org.apache.solr.core;
-import java.io.IOException;
import java.io.InputStream;
-import java.util.Collections;
import java.util.LinkedHashMap;
+import java.util.Map;
import org.apache.lucene.index.ConcurrentMergeScheduler;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.TieredMergePolicy;
@@ -27,7 +26,6 @@ import org.apache.lucene.util.InfoStream;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.schema.IndexSchemaFactory;
-import org.apache.solr.search.CacheConfig;
import org.apache.solr.update.SolrIndexConfig;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -40,7 +38,7 @@ public class TestConfig extends SolrTestCaseJ4 {
}
@Test
- public void testLib() throws IOException {
+ public void testLib() {
SolrResourceLoader loader = h.getCore().getResourceLoader();
InputStream data = null;
String[] unexpectedFiles = new String[] {"empty-file-c2.txt", "empty-file-d2.txt"};
@@ -70,7 +68,7 @@ public class TestConfig extends SolrTestCaseJ4 {
assertNull(sc.documentCacheConfig);
//
assertNotNull(sc.userCacheConfigs);
- assertEquals(Collections.<String, CacheConfig>emptyMap(), sc.userCacheConfigs);
+ assertEquals(Map.of(), sc.userCacheConfigs);
// enable all the core caches (and one user cache) via system properties and verify
System.setProperty("filterCache.enabled", "true");
diff --git a/solr/core/src/test/org/apache/solr/core/TestConfigOverlay.java b/solr/core/src/test/org/apache/solr/core/TestConfigOverlay.java
index c12b6916e44..75e701df31b 100644
--- a/solr/core/src/test/org/apache/solr/core/TestConfigOverlay.java
+++ b/solr/core/src/test/org/apache/solr/core/TestConfigOverlay.java
@@ -18,7 +18,6 @@ package org.apache.solr.core;
import static org.apache.solr.core.ConfigOverlay.isEditableProp;
-import java.util.Collections;
import java.util.Map;
import org.apache.solr.SolrTestCase;
@@ -56,7 +55,7 @@ public class TestConfigOverlay extends SolrTestCase {
}
public void testSetProperty() {
- ConfigOverlay overlay = new ConfigOverlay(Collections.emptyMap(), 0);
+ ConfigOverlay overlay = new ConfigOverlay(Map.of(), 0);
overlay = overlay.setProperty("query.filterCache.initialSize", 100);
assertEquals(100, overlay.getXPathProperty("query/filterCache/@initialSize"));
Map<String, Object> map = overlay.getEditableSubProperties("query/filterCache");
diff --git a/solr/core/src/test/org/apache/solr/core/TestConfigSetProperties.java b/solr/core/src/test/org/apache/solr/core/TestConfigSetProperties.java
index e3aeea8a55a..7d94bf096ca 100644
--- a/solr/core/src/test/org/apache/solr/core/TestConfigSetProperties.java
+++ b/solr/core/src/test/org/apache/solr/core/TestConfigSetProperties.java
@@ -20,7 +20,6 @@ import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.util.Collections;
import java.util.Map;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException;
@@ -65,7 +64,7 @@ public class TestConfigSetProperties extends SolrTestCaseJ4 {
@Test
public void testEmptyMap() throws Exception {
- NamedList<?> list = createConfigSetProps(Utils.toJSONString(Collections.emptyMap()));
+ NamedList<?> list = createConfigSetProps(Utils.toJSONString(Map.of()));
assertEquals(0, list.size());
}
diff --git a/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCoreSnapshots.java b/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCoreSnapshots.java
index 9e0b3ad5497..431a43a2fb7 100644
--- a/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCoreSnapshots.java
+++ b/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCoreSnapshots.java
@@ -19,7 +19,6 @@ package org.apache.solr.core.snapshots;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -336,7 +335,7 @@ public class TestSolrCoreSnapshots extends SolrCloudTestCase {
} catch (IndexNotFoundException ex) {
// This can happen when the delete snapshot functionality cleans up the index files (when the
// directory storing these files is not the *current* index directory).
- return Collections.emptyList();
+ return List.of();
}
}
}
diff --git a/solr/core/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java
index 9387f71bdb1..b407a2bb128 100644
--- a/solr/core/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java
@@ -19,6 +19,7 @@ package org.apache.solr.handler;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenFilter;
@@ -779,14 +780,14 @@ public class FieldAnalysisRequestHandlerTest extends AnalysisRequestHandlerTestB
FieldType fieldType = new TextField();
Analyzer analyzer =
new TokenizerChain(
- new TokenizerFactory(Collections.emptyMap()) {
+ new TokenizerFactory(new HashMap<String, String>()) {
@Override
public Tokenizer create(AttributeFactory factory) {
return new CustomTokenizer(factory);
}
},
new TokenFilterFactory[] {
- new TokenFilterFactory(Collections.emptyMap()) {
+ new TokenFilterFactory(new HashMap<String, String>()) {
@Override
public TokenStream create(TokenStream input) {
return new CustomTokenFilter(input);
diff --git a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandlerDiskOverFlow.java b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandlerDiskOverFlow.java
index f573f9ae11b..d450325bc33 100644
--- a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandlerDiskOverFlow.java
+++ b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandlerDiskOverFlow.java
@@ -25,7 +25,6 @@ import static org.apache.solr.handler.TestReplicationHandler.createAndStartJetty
import java.io.StringWriter;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CyclicBarrier;
@@ -213,10 +212,7 @@ public class TestReplicationHandlerDiskOverFlow extends SolrTestCaseJ4 {
assertEquals("Replication command status", "OK", response._getStr("status"));
- assertEquals(
- "threads encountered failures (see logs for when)",
- Collections.emptyList(),
- threadFailures);
+ assertEquals("threads encountered failures (see logs for when)", List.of(), threadFailures);
response = followerClient.query(new SolrQuery().setQuery("*:*").setRows(0));
assertEquals("docs in follower", docsInLeader, response.getResults().getNumFound());
diff --git a/solr/core/src/test/org/apache/solr/handler/V2ClusterAPIMappingTest.java b/solr/core/src/test/org/apache/solr/handler/V2ClusterAPIMappingTest.java
index 6dce25d5347..b41640f1534 100644
--- a/solr/core/src/test/org/apache/solr/handler/V2ClusterAPIMappingTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/V2ClusterAPIMappingTest.java
@@ -23,7 +23,6 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -143,7 +142,7 @@ public class V2ClusterAPIMappingTest extends SolrTestCaseJ4 {
new SolrQueryRequestBase(null, new ModifiableSolrParams()) {
@Override
public List<CommandOperation> getCommands(boolean validateInput) {
- if (v2RequestBody == null) return Collections.emptyList();
+ if (v2RequestBody == null) return List.of();
return ApiBag.getCommandOperations(
new ContentStreamBase.StringStream(v2RequestBody), api.getCommandSchema(), true);
}
diff --git a/solr/core/src/test/org/apache/solr/handler/V2UpdateAPIMappingTest.java b/solr/core/src/test/org/apache/solr/handler/V2UpdateAPIMappingTest.java
index c3cce079c77..24dadde2510 100644
--- a/solr/core/src/test/org/apache/solr/handler/V2UpdateAPIMappingTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/V2UpdateAPIMappingTest.java
@@ -20,7 +20,6 @@ package org.apache.solr.handler;
import static org.apache.solr.common.params.CommonParams.PATH;
import static org.mockito.Mockito.mock;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -101,7 +100,7 @@ public class V2UpdateAPIMappingTest extends SolrTestCaseJ4 {
return new SolrQueryRequestBase(null, new ModifiableSolrParams()) {
@Override
public List<CommandOperation> getCommands(boolean validateInput) {
- return Collections.emptyList();
+ return List.of();
}
@Override
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.java
index 20286eca409..69813bf75c9 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
@@ -258,9 +258,7 @@ public class TestApiFramework extends SolrTestCaseJ4 {
@Override
protected Map<String, JsonSchemaValidator> getValidators() {
- return currentApi[0] == null
- ? Collections.emptyMap()
- : currentApi[0].getCommandSchema();
+ return currentApi[0] == null ? Map.of() : currentApi[0].getCommandSchema();
}
@Override
@@ -307,7 +305,7 @@ public class TestApiFramework extends SolrTestCaseJ4 {
new SolrQueryRequestBase(null, SolrParams.of()) {
@Override
public List<CommandOperation> getCommands(boolean validateInput) {
- return Collections.emptyList();
+ return List.of();
}
};
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/TestCollectionAPIs.java b/solr/core/src/test/org/apache/solr/handler/admin/TestCollectionAPIs.java
index 6ffdc55aa09..eaa40be34e8 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/TestCollectionAPIs.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/TestCollectionAPIs.java
@@ -25,7 +25,6 @@ import static org.apache.solr.common.params.CommonParams.NAME;
import static org.apache.solr.common.util.Utils.fromJSONString;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -140,7 +139,7 @@ public class TestCollectionAPIs extends SolrTestCaseJ4 {
public Pair<SolrQueryRequest, SolrQueryResponse> makeCall(
final ApiBag apiBag, String path, final SolrRequest.METHOD method, final String payload) {
- SolrParams queryParams = new MultiMapSolrParams(Collections.emptyMap());
+ SolrParams queryParams = new MultiMapSolrParams(Map.of());
if (path.indexOf('?') > 0) {
String queryStr = path.substring(path.indexOf('?') + 1);
path = path.substring(0, path.indexOf('?'));
@@ -154,7 +153,7 @@ public class TestCollectionAPIs extends SolrTestCaseJ4 {
new SolrQueryRequestBase(null, queryParams) {
@Override
public List<CommandOperation> getCommands(boolean validateInput) {
- if (payload == null) return Collections.emptyList();
+ if (payload == null) return List.of();
return ApiBag.getCommandOperations(
new ContentStreamBase.StringStream(payload), api.getCommandSchema(), true);
}
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/V2ApiMappingTest.java b/solr/core/src/test/org/apache/solr/handler/admin/V2ApiMappingTest.java
index 164e637990b..7c256aae03e 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/V2ApiMappingTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/V2ApiMappingTest.java
@@ -22,7 +22,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -116,7 +115,7 @@ public abstract class V2ApiMappingTest<T extends RequestHandlerBase> extends Sol
new SolrQueryRequestBase(null, new ModifiableSolrParams()) {
@Override
public List<CommandOperation> getCommands(boolean validateInput) {
- if (v2RequestBody == null) return Collections.emptyList();
+ if (v2RequestBody == null) return List.of();
return ApiBag.getCommandOperations(
new ContentStreamBase.StringStream(v2RequestBody), api.getCommandSchema(), true);
}
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.java
index e69626ef5ff..2324b4cce07 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
@@ -181,7 +181,7 @@ public class ZookeeperStatusHandlerTest extends SolrCloudTestCase {
@Test(expected = SolrException.class)
public void validateEmptyResponse() {
try (ZookeeperStatusHandler zsh = new ZookeeperStatusHandler(null)) {
- zsh.validateZkRawResponse(Collections.emptyList(), "zoo1:2181", "mntr");
+ zsh.validateZkRawResponse(List.of(), "zoo1:2181", "mntr");
} catch (IOException e) {
fail("Error closing ZookeeperStatusHandler");
}
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/api/MigrateReplicasAPITest.java b/solr/core/src/test/org/apache/solr/handler/admin/api/MigrateReplicasAPITest.java
index 0b9bbc04526..574d671f595 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/api/MigrateReplicasAPITest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/api/MigrateReplicasAPITest.java
@@ -18,7 +18,6 @@ package org.apache.solr.handler.admin.api;
import static org.mockito.Mockito.when;
-import java.util.Collections;
import java.util.Set;
import org.apache.solr.client.api.model.MigrateReplicasRequestBody;
import org.apache.solr.common.SolrException;
@@ -75,10 +74,9 @@ public class MigrateReplicasAPITest extends MockV2APITest {
}
@Test
- public void testNoSourceNodesThrowsError() throws Exception {
+ public void testNoSourceNodesThrowsError() {
MigrateReplicasRequestBody requestBody1 =
- new MigrateReplicasRequestBody(
- Collections.emptySet(), Set.of("demoTargetNode"), null, null);
+ new MigrateReplicasRequestBody(Set.of(), Set.of("demoTargetNode"), null, null);
assertThrows(SolrException.class, () -> api.migrateReplicas(requestBody1));
MigrateReplicasRequestBody requestBody2 =
new MigrateReplicasRequestBody(null, Set.of("demoTargetNode"), null, null);
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/api/V2NodeAPIMappingTest.java b/solr/core/src/test/org/apache/solr/handler/admin/api/V2NodeAPIMappingTest.java
index 1e7dc2c43e7..18a09fc7568 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/api/V2NodeAPIMappingTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/api/V2NodeAPIMappingTest.java
@@ -23,7 +23,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import org.apache.solr.SolrTestCaseJ4;
@@ -196,7 +195,7 @@ public class V2NodeAPIMappingTest extends SolrTestCaseJ4 {
new SolrQueryRequestBase(null, solrParams) {
@Override
public List<CommandOperation> getCommands(boolean validateInput) {
- if (v2RequestBody == null) return Collections.emptyList();
+ if (v2RequestBody == null) return List.of();
return ApiBag.getCommandOperations(
new ContentStreamBase.StringStream(v2RequestBody), api.getCommandSchema(), true);
}
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.java
index f98aac8e3c3..ebdcbe658fb 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
@@ -40,7 +40,7 @@ public class ParallelHttpShardHandlerTest extends SolrTestCaseJ4 {
@Override
public List<Runnable> shutdownNow() {
shutdown = true;
- return Collections.emptyList();
+ return List.of();
}
@Override
diff --git a/solr/core/src/test/org/apache/solr/handler/component/PhrasesIdentificationComponentTest.java b/solr/core/src/test/org/apache/solr/handler/component/PhrasesIdentificationComponentTest.java
index b21810b20e9..6943af05e1c 100644
--- a/solr/core/src/test/org/apache/solr/handler/component/PhrasesIdentificationComponentTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/component/PhrasesIdentificationComponentTest.java
@@ -20,7 +20,6 @@ import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.lessThan;
import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
@@ -888,6 +887,6 @@ public class PhrasesIdentificationComponentTest extends SolrTestCaseJ4 {
* unexpected stream elements
*/
public <T> void assertEmptyStream(final String msg, final Stream<? extends T> stream) {
- assertEquals(msg, Collections.emptyList(), stream.collect(Collectors.toList()));
+ assertEquals(msg, List.of(), stream.collect(Collectors.toList()));
}
}
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.java
index 90897d7343e..fa0ad697bb2 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
@@ -50,11 +50,11 @@ public class ManagedSchemaDiffTest extends SolrCloudTestCase {
ManagedIndexSchema schema = helper.loadLatestSchema(DEFAULT_CONFIGSET_NAME);
Map<String, SchemaField> schema1FieldMap = new HashMap<>();
- schema1FieldMap.put("strfield", schema.newField("strfield", "string", Collections.emptyMap()));
+ schema1FieldMap.put("strfield", schema.newField("strfield", "string", Map.of()));
schema1FieldMap.put("boolfield", new SchemaField("boolfield", new BoolField()));
Map<String, SchemaField> schema2FieldMap = new HashMap<>();
- schema2FieldMap.put("strfield", schema.newField("strfield", "strings", Collections.emptyMap()));
+ schema2FieldMap.put("strfield", schema.newField("strfield", "strings", Map.of()));
schema2FieldMap.put("intfield", new SchemaField("intfield", new IntPointField()));
Map<String, Object> diff =
diff --git a/solr/core/src/test/org/apache/solr/handler/designer/TestSchemaDesignerAPI.java b/solr/core/src/test/org/apache/solr/handler/designer/TestSchemaDesignerAPI.java
index 0822693db8d..59dac14425a 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
@@ -164,7 +164,7 @@ public class TestSchemaDesignerAPI extends SolrCloudTestCase implements SchemaDe
ENABLE_DYNAMIC_FIELDS_PARAM, true,
ENABLE_FIELD_GUESSING_PARAM, true,
ENABLE_NESTED_DOCS_PARAM, false,
- LANGUAGES_PARAM, Collections.emptyList());
+ LANGUAGES_PARAM, List.of());
assertDesignerSettings(expSettings, rsp.getValues());
SolrParams rspData = rsp.getValues().toSolrParams();
int schemaVersion = rspData.getInt(SCHEMA_VERSION_PARAM);
@@ -348,7 +348,7 @@ public class TestSchemaDesignerAPI extends SolrCloudTestCase implements SchemaDe
ENABLE_DYNAMIC_FIELDS_PARAM, true,
ENABLE_FIELD_GUESSING_PARAM, true,
ENABLE_NESTED_DOCS_PARAM, false,
- LANGUAGES_PARAM, Collections.emptyList(),
+ LANGUAGES_PARAM, List.of(),
COPY_FROM_PARAM, "_default");
assertDesignerSettings(expSettings, rsp.getValues());
@@ -516,7 +516,7 @@ public class TestSchemaDesignerAPI extends SolrCloudTestCase implements SchemaDe
ENABLE_DYNAMIC_FIELDS_PARAM, false,
ENABLE_FIELD_GUESSING_PARAM, false,
ENABLE_NESTED_DOCS_PARAM, false,
- LANGUAGES_PARAM, Collections.emptyList(),
+ LANGUAGES_PARAM, List.of(),
COPY_FROM_PARAM, "_default");
assertDesignerSettings(expSettings, rsp.getValues());
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.java
index d2ed61fc037..4552a8a65bc 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
@@ -110,7 +110,7 @@ public class TestSchemaDesignerConfigSetHelper extends SolrCloudTestCase
schema =
helper.syncLanguageSpecificObjectsAndFiles(
- configSet, schema, Collections.emptyList(), true, DEFAULT_CONFIGSET_NAME);
+ configSet, schema, List.of(), true, DEFAULT_CONFIGSET_NAME);
assertEquals(2, schema.getSchemaZkVersion());
byte[] zipped = helper.downloadAndZipConfigSet(mutableId);
@@ -207,7 +207,7 @@ public class TestSchemaDesignerConfigSetHelper extends SolrCloudTestCase
schema =
helper.syncLanguageSpecificObjectsAndFiles(
- configSet, schema, Collections.emptyList(), true, DEFAULT_CONFIGSET_NAME);
+ configSet, schema, List.of(), true, DEFAULT_CONFIGSET_NAME);
assertNotNull(schema.getFieldTypeByName("text_en"));
assertNotNull(schema.getFieldOrNull("*_txt_en"));
assertNotNull(schema.getFieldTypeByName("text_fr"));
@@ -217,7 +217,7 @@ public class TestSchemaDesignerConfigSetHelper extends SolrCloudTestCase
schema =
helper.syncLanguageSpecificObjectsAndFiles(
- configSet, schema, Collections.emptyList(), false, DEFAULT_CONFIGSET_NAME);
+ configSet, schema, List.of(), false, DEFAULT_CONFIGSET_NAME);
assertNotNull(schema.getFieldTypeByName("text_en"));
assertNull(schema.getFieldOrNull("*_txt_en"));
assertNotNull(schema.getFieldTypeByName("text_fr"));
diff --git a/solr/core/src/test/org/apache/solr/handler/designer/TestSchemaDesignerSettingsDAO.java b/solr/core/src/test/org/apache/solr/handler/designer/TestSchemaDesignerSettingsDAO.java
index e0cc7eea106..3b1989c06a0 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
@@ -20,6 +20,7 @@ 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;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
@@ -84,7 +85,7 @@ public class TestSchemaDesignerSettingsDAO extends SolrCloudTestCase
DESIGNER_KEY + ENABLE_NESTED_DOCS_PARAM,
false,
DESIGNER_KEY + LANGUAGES_PARAM,
- Collections.emptyList());
+ List.of());
assertDesignerSettings(expSettings, settings);
settings.setDisabled(false);
@@ -109,7 +110,7 @@ public class TestSchemaDesignerSettingsDAO extends SolrCloudTestCase
DESIGNER_KEY + ENABLE_NESTED_DOCS_PARAM,
false,
DESIGNER_KEY + LANGUAGES_PARAM,
- Collections.emptyList());
+ List.of());
assertDesignerSettings(expSettings, settings);
assertFalse("should not be disabled", dao.isDesignerDisabled(configSet));
diff --git a/solr/core/src/test/org/apache/solr/legacy/TestLegacyNumericUtils.java b/solr/core/src/test/org/apache/solr/legacy/TestLegacyNumericUtils.java
index 7b7cfd74dc3..8a1aea5bc76 100644
--- a/solr/core/src/test/org/apache/solr/legacy/TestLegacyNumericUtils.java
+++ b/solr/core/src/test/org/apache/solr/legacy/TestLegacyNumericUtils.java
@@ -17,7 +17,6 @@
package org.apache.solr.legacy;
import java.util.Arrays;
-import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
@@ -599,8 +598,7 @@ public class TestLegacyNumericUtils extends SolrTestCase {
Long.MIN_VALUE, Long.MAX_VALUE, 1, false, Arrays.asList(0x0L, 0x1L), Arrays.asList(63));
// the inverse range should produce no sub-ranges
- assertLongRangeSplit(
- 9500L, -5000L, 4, false, Collections.<Long>emptyList(), Collections.<Integer>emptyList());
+ assertLongRangeSplit(9500L, -5000L, 4, false, List.of(), List.of());
// a 0-length range should reproduce the range itself
assertLongRangeSplit(
@@ -717,8 +715,7 @@ public class TestLegacyNumericUtils extends SolrTestCase {
Integer.MIN_VALUE, Integer.MAX_VALUE, 1, false, Arrays.asList(0x0, 0x1), Arrays.asList(31));
// the inverse range should produce no sub-ranges
- assertIntRangeSplit(
- 9500, -5000, 4, false, Collections.<Integer>emptyList(), Collections.<Integer>emptyList());
+ assertIntRangeSplit(9500, -5000, 4, false, List.of(), List.of());
// a 0-length range should reproduce the range itself
assertIntRangeSplit(
diff --git a/solr/core/src/test/org/apache/solr/packagemanager/TestPackageManager.java b/solr/core/src/test/org/apache/solr/packagemanager/TestPackageManager.java
index 58089790229..69f590136ae 100644
--- a/solr/core/src/test/org/apache/solr/packagemanager/TestPackageManager.java
+++ b/solr/core/src/test/org/apache/solr/packagemanager/TestPackageManager.java
@@ -69,7 +69,7 @@ public class TestPackageManager extends SolrCloudTestCase {
"1.0",
new SolrPackage.Manifest(),
Collections.singletonList(plugin),
- Collections.emptyMap()),
+ Map.of()),
Collections.singletonList(COLLECTION_NAME),
plugin.type.equals("cluster"),
new String[0]);
@@ -91,7 +91,7 @@ public class TestPackageManager extends SolrCloudTestCase {
@Override
Map<String, String> getPackageParams(String packageName, String collection) {
- return Collections.emptyMap();
+ return Map.of();
}
}
}
diff --git a/solr/core/src/test/org/apache/solr/response/TestRetrieveFieldsOptimizer.java b/solr/core/src/test/org/apache/solr/response/TestRetrieveFieldsOptimizer.java
index 5de81116cb2..9f413673236 100644
--- a/solr/core/src/test/org/apache/solr/response/TestRetrieveFieldsOptimizer.java
+++ b/solr/core/src/test/org/apache/solr/response/TestRetrieveFieldsOptimizer.java
@@ -479,7 +479,7 @@ class FieldHolder {
storedMvFields.add(field);
}
}
- return schema.addFields(fieldsToAdd, Collections.emptyMap(), false);
+ return schema.addFields(fieldsToAdd, Map.of(), false);
}
RetrieveField getTestField(String field) {
diff --git a/solr/core/src/test/org/apache/solr/schema/DateFieldTest.java b/solr/core/src/test/org/apache/solr/schema/DateFieldTest.java
index fb50c88578f..382fc700058 100644
--- a/solr/core/src/test/org/apache/solr/schema/DateFieldTest.java
+++ b/solr/core/src/test/org/apache/solr/schema/DateFieldTest.java
@@ -17,8 +17,8 @@
package org.apache.solr.schema;
import java.nio.file.Path;
-import java.util.Collections;
import java.util.Date;
+import java.util.HashMap;
import org.apache.lucene.index.IndexableField;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.util.ByteArrayUtf8CharSequence;
@@ -37,7 +37,7 @@ public class DateFieldTest extends SolrTestCaseJ4 {
IndexSchema schema =
IndexSchemaFactory.buildIndexSchema(testConfHome.resolve("schema.xml").toString(), config);
f = Boolean.getBoolean(NUMERIC_POINTS_SYSPROP) ? new DatePointField() : new TrieDateField();
- f.init(schema, Collections.<String, String>emptyMap());
+ f.init(schema, new HashMap<String, String>());
}
// NOTE: Many other tests were moved to DateMathParserTest
diff --git a/solr/core/src/test/org/apache/solr/schema/TestManagedSchema.java b/solr/core/src/test/org/apache/solr/schema/TestManagedSchema.java
index 4351b453dbb..e60f6d23da9 100644
--- a/solr/core/src/test/org/apache/solr/schema/TestManagedSchema.java
+++ b/solr/core/src/test/org/apache/solr/schema/TestManagedSchema.java
@@ -23,7 +23,6 @@ import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
@@ -182,7 +181,7 @@ public class TestManagedSchema extends AbstractBadConfigTestBase {
IndexSchema oldSchema = h.getCore().getLatestSchema();
String fieldName = "new_field";
String fieldType = "string";
- Map<String, ?> options = Collections.emptyMap();
+ Map<String, ?> options = Map.of();
SchemaField newField = oldSchema.newField(fieldName, fieldType, options);
IndexSchema newSchema = oldSchema.addField(newField);
h.getCore().setLatestSchema(newSchema);
diff --git a/solr/core/src/test/org/apache/solr/schema/TestPointFields.java b/solr/core/src/test/org/apache/solr/schema/TestPointFields.java
index cbee971c7cc..4c7010bb0c1 100644
--- a/solr/core/src/test/org/apache/solr/schema/TestPointFields.java
+++ b/solr/core/src/test/org/apache/solr/schema/TestPointFields.java
@@ -261,7 +261,7 @@ public class TestPointFields extends SolrTestCaseJ4 {
field, "multivalued", toStringArray(getRandomInts(numValues, false)));
}
- assertEquals("Missing types in the test", Collections.<String>emptySet(), regexToTest);
+ assertEquals("Missing types in the test", Set.of(), regexToTest);
}
@Test
@@ -880,7 +880,7 @@ public class TestPointFields extends SolrTestCaseJ4 {
doTestPointFieldFunctionQueryError(field, "multivalued", "42.34");
doTestPointFieldFunctionQueryError(field, "multivalued", "42.34", "66.6");
}
- assertEquals("Missing types in the test", Collections.<String>emptySet(), regexToTest);
+ assertEquals("Missing types in the test", Set.of(), regexToTest);
}
@Test
@@ -1496,7 +1496,7 @@ public class TestPointFields extends SolrTestCaseJ4 {
doTestPointFieldFunctionQueryError(field, "multivalued", "42.34");
doTestPointFieldFunctionQueryError(field, "multivalued", "42.34", "66.6");
}
- assertEquals("Missing types in the test", Collections.<String>emptySet(), regexToTest);
+ assertEquals("Missing types in the test", Set.of(), regexToTest);
}
@Test
@@ -2077,7 +2077,7 @@ public class TestPointFields extends SolrTestCaseJ4 {
doTestPointFieldFunctionQueryError(
field, "multivalued", toStringArray(getRandomLongs(numValues, false)));
}
- assertEquals("Missing types in the test", Collections.<String>emptySet(), regexToTest);
+ assertEquals("Missing types in the test", Set.of(), regexToTest);
}
@Test
@@ -2636,7 +2636,7 @@ public class TestPointFields extends SolrTestCaseJ4 {
doTestPointFieldFunctionQueryError(
field, "multivalued", "1995-12-31T23:59:59Z", "2000-12-31T23:59:59Z");
}
- assertEquals("Missing types in the test", Collections.<String>emptySet(), regexToTest);
+ assertEquals("Missing types in the test", Set.of(), regexToTest);
}
@Test
diff --git a/solr/core/src/test/org/apache/solr/search/LargeFieldTest.java b/solr/core/src/test/org/apache/solr/search/LargeFieldTest.java
index 9c14cb2bf46..6d0a6a385be 100644
--- a/solr/core/src/test/org/apache/solr/search/LargeFieldTest.java
+++ b/solr/core/src/test/org/apache/solr/search/LargeFieldTest.java
@@ -20,6 +20,7 @@ package org.apache.solr.search;
import java.io.StringWriter;
import java.util.Arrays;
import java.util.Collections;
+import java.util.Map;
import java.util.Objects;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexableField;
@@ -70,7 +71,7 @@ public class LargeFieldTest extends SolrTestCaseJ4 {
Arrays.asList(
schema.newField(LAZY_FIELD, "textType", map()),
schema.newField(BIG_FIELD, "textType", map("large", true))),
- Collections.emptyMap(),
+ Map.of(),
PERSIST_FALSE);
h.getCore().setLatestSchema(schema);
diff --git a/solr/core/src/test/org/apache/solr/search/SignificantTermsQParserPluginTest.java b/solr/core/src/test/org/apache/solr/search/SignificantTermsQParserPluginTest.java
index b3d70a8d1bd..49203334367 100644
--- a/solr/core/src/test/org/apache/solr/search/SignificantTermsQParserPluginTest.java
+++ b/solr/core/src/test/org/apache/solr/search/SignificantTermsQParserPluginTest.java
@@ -20,9 +20,9 @@ package org.apache.solr.search;
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import org.apache.commons.io.file.PathUtils;
import org.apache.solr.SolrTestCaseJ4;
@@ -76,8 +76,7 @@ public class SignificantTermsQParserPluginTest extends SolrTestCaseJ4 {
RefCounted<SolrIndexSearcher> searcher = emptyCore.getSearcher();
try {
DelegatingCollector analyticsCollector =
- query.getAnalyticsCollector(
- new ResponseBuilder(null, resp, Collections.emptyList()), searcher.get());
+ query.getAnalyticsCollector(new ResponseBuilder(null, resp, List.of()), searcher.get());
assertNotNull(analyticsCollector);
analyticsCollector.complete();
LinkedHashMap<String, Object> expectedValues = new LinkedHashMap<>();
@@ -106,7 +105,7 @@ public class SignificantTermsQParserPluginTest extends SolrTestCaseJ4 {
AnalyticsQuery query = (AnalyticsQuery) parser.parse();
SolrQueryResponse resp = new SolrQueryResponse();
- ResponseBuilder responseBuilder = new ResponseBuilder(null, resp, Collections.emptyList());
+ ResponseBuilder responseBuilder = new ResponseBuilder(null, resp, List.of());
RefCounted<SolrIndexSearcher> searcher = dataCore.getSearcher();
try {
diff --git a/solr/core/src/test/org/apache/solr/search/TestAddFieldRealTimeGet.java b/solr/core/src/test/org/apache/solr/search/TestAddFieldRealTimeGet.java
index f7ac2b40616..91447cf037d 100644
--- a/solr/core/src/test/org/apache/solr/search/TestAddFieldRealTimeGet.java
+++ b/solr/core/src/test/org/apache/solr/search/TestAddFieldRealTimeGet.java
@@ -18,7 +18,7 @@ package org.apache.solr.search;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.util.Collections;
+import java.util.Map;
import org.apache.commons.io.file.PathUtils;
import org.apache.lucene.tests.mockfile.FilterPath;
import org.apache.solr.schema.IndexSchema;
@@ -65,7 +65,7 @@ public class TestAddFieldRealTimeGet extends TestRTGBase {
unIgnoreException("unknown field");
IndexSchema schema = h.getCore().getLatestSchema();
- SchemaField newField = schema.newField(newFieldName, newFieldType, Collections.emptyMap());
+ SchemaField newField = schema.newField(newFieldName, newFieldType, Map.of());
IndexSchema newSchema = schema.addField(newField);
h.getCore().setLatestSchema(newSchema);
diff --git a/solr/core/src/test/org/apache/solr/search/TestFiltersQueryCaching.java b/solr/core/src/test/org/apache/solr/search/TestFiltersQueryCaching.java
index e2f47693ec4..eb6811ea324 100644
--- a/solr/core/src/test/org/apache/solr/search/TestFiltersQueryCaching.java
+++ b/solr/core/src/test/org/apache/solr/search/TestFiltersQueryCaching.java
@@ -20,7 +20,6 @@ import io.prometheus.metrics.model.snapshots.CounterSnapshot;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import java.util.concurrent.Future;
import org.apache.solr.SolrTestCaseJ4;
@@ -203,7 +202,7 @@ public class TestFiltersQueryCaching extends SolrTestCaseJ4 {
@Test
public void testAbsentParams() throws Exception {
// no `fqs` at all
- doTestAbsentParams(Collections.emptyList(), NUM_DOCS);
+ doTestAbsentParams(List.of(), NUM_DOCS);
// simple term query `fqs`
doTestAbsentParams(List.of("fqs", "{!term f=field_s v='d0'}"), 1);
// empty `fqs`
diff --git a/solr/core/src/test/org/apache/solr/search/TestSearcherReuse.java b/solr/core/src/test/org/apache/solr/search/TestSearcherReuse.java
index 0f722037241..11168e816d6 100644
--- a/solr/core/src/test/org/apache/solr/search/TestSearcherReuse.java
+++ b/solr/core/src/test/org/apache/solr/search/TestSearcherReuse.java
@@ -18,7 +18,7 @@ package org.apache.solr.search;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.util.Collections;
+import java.util.Map;
import org.apache.commons.io.file.PathUtils;
import org.apache.lucene.tests.mockfile.FilterPath;
import org.apache.solr.SolrTestCaseJ4;
@@ -176,8 +176,7 @@ public class TestSearcherReuse extends SolrTestCaseJ4 {
// create a new field & add it.
assertTrue("schema not mutable", beforeReq.getSchema().isMutable());
ManagedIndexSchema oldSchema = (ManagedIndexSchema) beforeReq.getSchema();
- SchemaField newField =
- oldSchema.newField("hoss", "string", Collections.<String, Object>emptyMap());
+ SchemaField newField = oldSchema.newField("hoss", "string", Map.of());
IndexSchema newSchema = oldSchema.addField(newField);
h.getCore().setLatestSchema(newSchema);
diff --git a/solr/core/src/test/org/apache/solr/search/TestSolrQueryParser.java b/solr/core/src/test/org/apache/solr/search/TestSolrQueryParser.java
index 6dcf66563e7..6c9cd362e41 100644
--- a/solr/core/src/test/org/apache/solr/search/TestSolrQueryParser.java
+++ b/solr/core/src/test/org/apache/solr/search/TestSolrQueryParser.java
@@ -26,7 +26,6 @@ import static org.hamcrest.core.StringContains.containsString;
import io.prometheus.metrics.model.snapshots.CounterSnapshot;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
@@ -340,7 +339,7 @@ public class TestSolrQueryParser extends SolrTestCaseJ4 {
sowTrueParamsMap.put("sow", "true");
List<MapSolrParams> paramMaps =
Arrays.asList(
- new MapSolrParams(Collections.emptyMap()), // no sow param (i.e. the default sow value)
+ new MapSolrParams(Map.of()), // no sow param (i.e. the default sow value)
new MapSolrParams(sowFalseParamsMap),
new MapSolrParams(sowTrueParamsMap));
diff --git a/solr/core/src/test/org/apache/solr/search/ThinCache.java b/solr/core/src/test/org/apache/solr/search/ThinCache.java
index c8123a899ed..06f58eacf39 100644
--- a/solr/core/src/test/org/apache/solr/search/ThinCache.java
+++ b/solr/core/src/test/org/apache/solr/search/ThinCache.java
@@ -25,7 +25,6 @@ import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -234,7 +233,7 @@ public class ThinCache<S, K, V> extends SolrCacheBase
@SuppressWarnings("unchecked")
ThinCache<S, K, V> other = (ThinCache<S, K, V>) old;
long warmingStartTimeNanos = System.nanoTime();
- List<HitCountEntry<K, V>> orderedEntries = Collections.emptyList();
+ List<HitCountEntry<K, V>> orderedEntries = List.of();
// warm entries
if (isAutowarmingOn()) {
orderedEntries = new ArrayList<>(other.local.size() << 1); // oversize
diff --git a/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetJoinDomain.java b/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetJoinDomain.java
index 0644631e7cb..93e7f07bf4c 100644
--- a/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetJoinDomain.java
+++ b/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetJoinDomain.java
@@ -21,7 +21,6 @@ import java.lang.invoke.MethodHandles;
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.Map;
@@ -636,7 +635,7 @@ public class TestCloudJSONFacetJoinDomain extends SolrCloudTestCase {
((Number) facetResponse.get("count")).longValue());
if (0 == rsp.getResults().getNumFound()) {
// when the query matches nothing, we should expect no top level facets
- expected = Collections.emptyMap();
+ expected = Map.of();
}
assertFacetCountsAreCorrect(maxBucketsToCheck, expected, baseParams, facetResponse);
} catch (AssertionError e) {
diff --git a/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKG.java b/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKG.java
index f1046806863..c6e9dfa0094 100644
--- a/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKG.java
+++ b/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKG.java
@@ -24,7 +24,6 @@ import java.lang.invoke.MethodHandles;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
@@ -442,7 +441,7 @@ public class TestCloudJSONFacetSKG extends SolrCloudTestCase {
// 'skg' key must not exist in th allBuckets bucket
assertEquals(
facetKey + " has skg in allBuckets: " + results.get("allBuckets"),
- Collections.emptyList(),
+ List.of(),
((NamedList<Object>) results.get("allBuckets")).getAll("skg"));
}
final List<NamedList<Object>> buckets = (List<NamedList<Object>>) results.get("buckets");
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.java
index 2ce2bd10563..b295fd4c9a3 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
@@ -363,8 +363,8 @@ public class TestCloudJSONFacetSKGEquiv extends SolrCloudTestCase {
(NamedList<Object>) debug.get(SWEEP_COLLECTION_DEBUG_KEY);
assertNotNull(sweep_debug);
assertEquals("count", sweep_debug.get("base"));
- assertEquals(Collections.emptyList(), sweep_debug.get("accs"));
- assertEquals(Collections.emptyList(), sweep_debug.get("mapped"));
+ assertEquals(List.of(), sweep_debug.get("accs"));
+ assertEquals(List.of(), sweep_debug.get("mapped"));
}
{ // if we override 'dv' with 'hashdv' which doesn't sweep, our sweep debug should be empty,
// even if the skg stat does ask for sweeping explicitly...
@@ -419,8 +419,8 @@ public class TestCloudJSONFacetSKGEquiv extends SolrCloudTestCase {
(NamedList<Object>) debug.get(SWEEP_COLLECTION_DEBUG_KEY);
assertNotNull(sweep_debug);
assertEquals("count", sweep_debug.get("base"));
- assertEquals(Collections.emptyList(), sweep_debug.get("accs"));
- assertEquals(Collections.emptyList(), sweep_debug.get("mapped"));
+ assertEquals(List.of(), sweep_debug.get("accs"));
+ assertEquals(List.of(), sweep_debug.get("mapped"));
}
}
@@ -921,12 +921,12 @@ public class TestCloudJSONFacetSKGEquiv extends SolrCloudTestCase {
/** Assumes null for fore/back queries w/no options */
public RelatednessFacet() {
- this(null, null, Collections.emptyMap());
+ this(null, null, Map.of());
}
/** Assumes no options */
public RelatednessFacet(final String foreQ, final String backQ) {
- this(foreQ, backQ, Collections.emptyMap());
+ this(foreQ, backQ, Map.of());
}
public RelatednessFacet(
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.java
index 5790027afcf..099d070bc61 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
@@ -80,9 +80,7 @@ public abstract class ShardToShardJoinAbstract extends SolrCloudTestCase {
PluginMeta plugin = new PluginMeta();
plugin.name = PlacementPluginFactory.PLUGIN_NAME;
plugin.klass = StubShardAffinityPlacementFactory.class.getName();
- plugin.config =
- new AffinityPlacementConfig(
- 1, 2, Collections.emptyMap(), Map.of(toColl, fromColl), Map.of());
+ plugin.config = new AffinityPlacementConfig(1, 2, Map.of(), Map.of(toColl, fromColl), Map.of());
V2Request req =
new V2Request.Builder("/cluster/plugin")
diff --git a/solr/core/src/test/org/apache/solr/security/AllowListUrlCheckerTest.java b/solr/core/src/test/org/apache/solr/security/AllowListUrlCheckerTest.java
index 0a4f57ba5af..4123d4a7c49 100644
--- a/solr/core/src/test/org/apache/solr/security/AllowListUrlCheckerTest.java
+++ b/solr/core/src/test/org/apache/solr/security/AllowListUrlCheckerTest.java
@@ -23,7 +23,6 @@ import static org.hamcrest.CoreMatchers.is;
import java.net.MalformedURLException;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -50,8 +49,7 @@ public class AllowListUrlCheckerTest extends SolrTestCaseJ4 {
@Test
public void testNoInput() throws Exception {
- assertThat(
- new AllowListUrlChecker(Collections.emptyList()).getHostAllowList().isEmpty(), is(true));
+ assertThat(new AllowListUrlChecker(List.of()).getHostAllowList().isEmpty(), is(true));
}
@Test
@@ -146,7 +144,7 @@ public class AllowListUrlCheckerTest extends SolrTestCaseJ4 {
@Test
public void testHostParsingUnsetEmpty() throws Exception {
- assertThat(AllowListUrlChecker.parseHostPorts(Collections.emptyList()).isEmpty(), is(true));
+ assertThat(AllowListUrlChecker.parseHostPorts(List.of()).isEmpty(), is(true));
}
@Test
diff --git a/solr/core/src/test/org/apache/solr/security/BaseTestRuleBasedAuthorizationPlugin.java b/solr/core/src/test/org/apache/solr/security/BaseTestRuleBasedAuthorizationPlugin.java
index c861dc2458c..ae58ff1d67a 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.emptyMap;
-import static java.util.Collections.emptySet;
import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap;
import static org.apache.solr.common.util.CommandOperation.captureErrors;
@@ -575,7 +573,7 @@ public class BaseTestRuleBasedAuthorizationPlugin extends SolrTestCaseJ4 {
"handler",
handler,
"params",
- new MapSolrParams(emptyMap())),
+ new MapSolrParams(Map.of())),
STATUS_OK);
}
@@ -622,7 +620,7 @@ public class BaseTestRuleBasedAuthorizationPlugin extends SolrTestCaseJ4 {
"handler",
handler,
"params",
- new MapSolrParams(emptyMap())),
+ new MapSolrParams(Map.of())),
STATUS_OK);
}
@@ -669,7 +667,7 @@ public class BaseTestRuleBasedAuthorizationPlugin extends SolrTestCaseJ4 {
"handler",
handler,
"params",
- new MapSolrParams(emptyMap())),
+ new MapSolrParams(Map.of())),
FORBIDDEN);
}
@@ -681,14 +679,14 @@ public class BaseTestRuleBasedAuthorizationPlugin extends SolrTestCaseJ4 {
plugin.init(rules);
assertEquals(
Set.of("mycoll_update", "read"), plugin.getPermissionNamesForRoles(Set.of("dev")));
- assertEquals(emptySet(), plugin.getPermissionNamesForRoles(Set.of("user")));
+ assertEquals(Set.of(), plugin.getPermissionNamesForRoles(Set.of("user")));
assertEquals(
Set.of("schema-edit", "collection-admin-edit", "mycoll_update"),
plugin.getPermissionNamesForRoles(Set.of("admin")));
assertEquals(
Set.of("schema-edit", "collection-admin-edit", "mycoll_update", "read"),
plugin.getPermissionNamesForRoles(Set.of("admin", "dev")));
- assertEquals(emptySet(), plugin.getPermissionNamesForRoles(null));
+ assertEquals(Set.of(), plugin.getPermissionNamesForRoles(null));
assertEquals(
Set.of("collection-admin-read"),
plugin.getPermissionNamesForRoles(Collections.singletonList(null)));
diff --git a/solr/core/src/test/org/apache/solr/security/CertAuthPluginTest.java b/solr/core/src/test/org/apache/solr/security/CertAuthPluginTest.java
index a0574c1327f..f8dd4927bf3 100644
--- a/solr/core/src/test/org/apache/solr/security/CertAuthPluginTest.java
+++ b/solr/core/src/test/org/apache/solr/security/CertAuthPluginTest.java
@@ -30,7 +30,7 @@ import jakarta.servlet.FilterChain;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.security.cert.X509Certificate;
-import java.util.Collections;
+import java.util.Map;
import javax.security.auth.x500.X500Principal;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.core.CoreContainer;
@@ -62,7 +62,7 @@ public class CertAuthPluginTest extends SolrTestCaseJ4 {
SolrMetricsContext solrMetricsContext =
new SolrMetricsContext(coreContainer.getMetricManager(), registryName);
plugin.initializeMetrics(solrMetricsContext, Attributes.empty());
- plugin.init(Collections.emptyMap());
+ plugin.init(Map.of());
}
@Override
diff --git a/solr/core/src/test/org/apache/solr/security/PathBasedCertPrincipalResolverTest.java b/solr/core/src/test/org/apache/solr/security/PathBasedCertPrincipalResolverTest.java
index 1911ff66d6b..9405c0f4f03 100644
--- a/solr/core/src/test/org/apache/solr/security/PathBasedCertPrincipalResolverTest.java
+++ b/solr/core/src/test/org/apache/solr/security/PathBasedCertPrincipalResolverTest.java
@@ -23,7 +23,6 @@ import com.carrotsearch.randomizedtesting.RandomizedRunner;
import java.security.Principal;
import java.security.cert.CertificateParsingException;
import java.security.cert.X509Certificate;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -227,7 +226,7 @@ public class PathBasedCertPrincipalResolverTest extends SolrTestCaseJ4 {
List.of(SANType.EMAIL.getValue(), "user1@example.com"),
List.of(SANType.EMAIL.getValue(), "user2@example.com")),
"san.email",
- Collections.emptyList(),
+ List.of(),
"*",
"user1@example.com");
}
@@ -322,9 +321,9 @@ public class PathBasedCertPrincipalResolverTest extends SolrTestCaseJ4 {
sanData,
null,
path,
- Collections.emptyList(),
+ List.of(),
CertResolverPattern.CheckType.WILDCARD.toString(),
- Collections.emptyMap(),
+ Map.of(),
expectedValue);
}
@@ -336,7 +335,7 @@ public class PathBasedCertPrincipalResolverTest extends SolrTestCaseJ4 {
String expectedValue) {
testCertificateCases(
- sanData, null, path, filterValues, filterCheckType, Collections.emptyMap(), expectedValue);
+ sanData, null, path, filterValues, filterCheckType, Map.of(), expectedValue);
}
private void testCertificateCases(String dn, String path, String expectedValue) {
@@ -345,9 +344,9 @@ public class PathBasedCertPrincipalResolverTest extends SolrTestCaseJ4 {
null,
dn,
path,
- Collections.emptyList(),
+ List.of(),
CertResolverPattern.CheckType.WILDCARD.toString(),
- Collections.emptyMap(),
+ Map.of(),
expectedValue);
}
diff --git a/solr/core/src/test/org/apache/solr/update/DeleteByIdWithRouterFieldTest.java b/solr/core/src/test/org/apache/solr/update/DeleteByIdWithRouterFieldTest.java
index c014c842ef7..a36b7b02cd6 100644
--- a/solr/core/src/test/org/apache/solr/update/DeleteByIdWithRouterFieldTest.java
+++ b/solr/core/src/test/org/apache/solr/update/DeleteByIdWithRouterFieldTest.java
@@ -22,6 +22,7 @@ import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.stream.Collectors;
import org.apache.lucene.tests.util.TestUtil;
import org.apache.lucene.util.IOUtils;
@@ -123,7 +124,7 @@ public class DeleteByIdWithRouterFieldTest extends SolrCloudTestCase {
final SolrDocumentList replicaResults = replicaClient.query(params).getResults();
assertEquals(
"inconsistency w/leader: shard=" + shardName + "core=" + replica.getCoreName(),
- Collections.emptySet(),
+ Set.of(),
CloudInspectUtil.showDiff(
leaderResults,
replicaResults,
diff --git a/solr/core/src/test/org/apache/solr/update/PeerSyncTest.java b/solr/core/src/test/org/apache/solr/update/PeerSyncTest.java
index aa7d02d6c1c..0b7a3f3c2a0 100644
--- a/solr/core/src/test/org/apache/solr/update/PeerSyncTest.java
+++ b/solr/core/src/test/org/apache/solr/update/PeerSyncTest.java
@@ -456,7 +456,7 @@ public class PeerSyncTest extends BaseDistributedSearchTestCase {
private static void testHandleVersionsWithRangesNoOther() {
// no other, solitary us
for (boolean completeList : new boolean[] {false, true}) {
- List<Long> otherVersions = Collections.emptyList();
+ List<Long> otherVersions = List.of();
List<Long> ourUpdates = Collections.singletonList(42L);
assertEquals(1, ourUpdates.size());
long ourLowThreshold = ourUpdates.get(0);
diff --git a/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesDistrib.java b/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesDistrib.java
index ef169bba282..8576af70208 100644
--- a/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesDistrib.java
+++ b/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesDistrib.java
@@ -572,7 +572,7 @@ public class TestInPlaceUpdatesDistrib extends AbstractFullDistribZkTestBase {
// create 10 more segments
for (int i = 0; i < 10; i++) {
- buildRandomIndex(101.0F, Collections.emptyList());
+ buildRandomIndex(101.0F, List.of());
}
index("id", id, "inplace_updatable_float", map("inc", "1"));
diff --git a/solr/core/src/test/org/apache/solr/update/TestNestedUpdateProcessor.java b/solr/core/src/test/org/apache/solr/update/TestNestedUpdateProcessor.java
index c91cdf27257..98c847ec12e 100644
--- a/solr/core/src/test/org/apache/solr/update/TestNestedUpdateProcessor.java
+++ b/solr/core/src/test/org/apache/solr/update/TestNestedUpdateProcessor.java
@@ -22,7 +22,6 @@ import static org.hamcrest.Matchers.containsString;
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.Map;
@@ -306,7 +305,7 @@ public class TestNestedUpdateProcessor extends SolrTestCaseJ4 {
assertTrue( // we expected at least one query for every "real" path,
// but there will be more because we'll try lots of sub-paths that have no docs
docs.numDocsDescendentFromPath.keySet().size()
- < docs.recursiveCheckParentQueryOfAllChildren(Collections.<String>emptyList()));
+ < docs.recursiveCheckParentQueryOfAllChildren(List.of()));
// check: path that is guaranteed not to exist...
assertEquals(1, docs.recursiveCheckParentQueryOfAllChildren(Arrays.asList("xxx", "yyy")));
@@ -315,7 +314,7 @@ public class TestNestedUpdateProcessor extends SolrTestCaseJ4 {
assertTrue( // we expected at least one query for every "real" path,
// but there will be more because we'll try lots of sub-paths that have no docs
docs.numDocsWithPathWithKids.keySet().size()
- < docs.recursiveCheckChildQueryOfAllParents(Collections.<String>emptyList()));
+ < docs.recursiveCheckChildQueryOfAllParents(List.of()));
// check: path that is guaranteed not to exist...
assertEquals(1, docs.recursiveCheckChildQueryOfAllParents(Arrays.asList("xxx", "yyy")));
@@ -334,7 +333,7 @@ public class TestNestedUpdateProcessor extends SolrTestCaseJ4 {
private int idCounter = 0;
public synchronized SolrInputDocument buildRandomDoc() {
- return buildRandomDoc(null, Collections.<String>emptyList(), 15);
+ return buildRandomDoc(null, List.of(), 15);
}
private static String joinPath(List<String> test_path) {
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.java
index c154e868516..d9028e99578 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
@@ -1275,13 +1275,13 @@ public class TimeRoutedAliasUpdateProcessorTest extends RoutedAliasUpdateProcess
// some tidbits for handling zk data here are swiped from Aliases.json
Map<String, Map> aliasMap;
if (data == null || data.length == 0) {
- aliasMap = Collections.emptyMap();
+ aliasMap = Map.of();
} else {
aliasMap = (Map<String, Map>) Utils.fromJSON(data);
}
assertNotEquals(0, aliasMap.size());
- Map colAliases = aliasMap.getOrDefault("collection", Collections.emptyMap());
+ Map colAliases = aliasMap.getOrDefault("collection", Map.of());
assertNotEquals(0, colAliases.size());
String singleInitialCollection = (String) colAliases.get(alias);
diff --git a/solr/core/src/test/org/apache/solr/util/ModuleUtilsTest.java b/solr/core/src/test/org/apache/solr/util/ModuleUtilsTest.java
index b5629222c35..66c94fa8725 100644
--- a/solr/core/src/test/org/apache/solr/util/ModuleUtilsTest.java
+++ b/solr/core/src/test/org/apache/solr/util/ModuleUtilsTest.java
@@ -19,7 +19,6 @@ package org.apache.solr.util;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.util.Collections;
import java.util.Set;
import org.apache.solr.SolrTestCase;
@@ -52,7 +51,7 @@ public class ModuleUtilsTest extends SolrTestCase {
}
public void testResolveFromSyspropOrEnv() {
- assertEquals(Collections.emptySet(), ModuleUtils.resolveFromSyspropOrEnv());
+ assertTrue(ModuleUtils.resolveFromSyspropOrEnv().isEmpty());
System.setProperty("solr.modules", "foo ,bar, baz,mod1");
assertEquals(Set.of("foo", "bar", "baz", "mod1"), ModuleUtils.resolveFromSyspropOrEnv());
System.clearProperty("solr.modules");
@@ -66,8 +65,7 @@ public class ModuleUtilsTest extends SolrTestCase {
assertEquals(
Set.of("foo", "bar", "baz", "mod1"),
Set.copyOf(ModuleUtils.resolveModulesFromStringOrSyspropOrEnv("foo ,bar, baz,mod1")));
- assertEquals(
- Collections.emptySet(), Set.copyOf(ModuleUtils.resolveModulesFromStringOrSyspropOrEnv("")));
+ assertTrue(ModuleUtils.resolveModulesFromStringOrSyspropOrEnv("").isEmpty());
System.setProperty("solr.modules", "foo ,bar, baz,mod1");
assertEquals(
Set.of("foo", "bar", "baz", "mod1"),
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.java
index 89f85f36db2..b576f074b32 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
@@ -227,7 +227,7 @@ public class KafkaCrossDcConsumerTest {
.when(kafkaConsumerMock)
.subscribe(anyList());
- when(kafkaConsumerMock.poll(any())).thenReturn(new ConsumerRecords<>(Collections.emptyMap()));
+ when(kafkaConsumerMock.poll(any())).thenReturn(new ConsumerRecords<>(Map.of()));
ExecutorService consumerThreadExecutor =
ExecutorUtil.newMDCAwareSingleThreadExecutor(new SolrNamedThreadFactory("CrossDCConsumer"));
diff --git a/solr/modules/clustering/src/test/org/apache/solr/handler/clustering/EchoClusteringAlgorithm.java b/solr/modules/clustering/src/test/org/apache/solr/handler/clustering/EchoClusteringAlgorithm.java
index 51448a0aa78..10eba231303 100644
--- a/solr/modules/clustering/src/test/org/apache/solr/handler/clustering/EchoClusteringAlgorithm.java
+++ b/solr/modules/clustering/src/test/org/apache/solr/handler/clustering/EchoClusteringAlgorithm.java
@@ -17,7 +17,6 @@
package org.apache.solr.handler.clustering;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.stream.Stream;
@@ -39,7 +38,7 @@ public class EchoClusteringAlgorithm extends AttrComposite implements Clustering
@Override
public Set<Class<?>> requiredLanguageComponents() {
- return Collections.emptySet();
+ return Set.of();
}
@Override
diff --git a/solr/modules/clustering/src/test/org/apache/solr/handler/clustering/MockClusteringAlgorithm.java b/solr/modules/clustering/src/test/org/apache/solr/handler/clustering/MockClusteringAlgorithm.java
index 864f5f78252..c1ca654e346 100644
--- a/solr/modules/clustering/src/test/org/apache/solr/handler/clustering/MockClusteringAlgorithm.java
+++ b/solr/modules/clustering/src/test/org/apache/solr/handler/clustering/MockClusteringAlgorithm.java
@@ -17,7 +17,6 @@
package org.apache.solr.handler.clustering;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -76,7 +75,7 @@ public class MockClusteringAlgorithm extends AttrComposite implements Clustering
@Override
public Set<Class<?>> requiredLanguageComponents() {
- return Collections.emptySet();
+ return Set.of();
}
@Override
diff --git a/solr/modules/extraction/src/java/org/apache/solr/handler/extraction/ExtractingDocumentLoader.java b/solr/modules/extraction/src/java/org/apache/solr/handler/extraction/ExtractingDocumentLoader.java
index 64a34cdd13f..d4fd1c4cbd1 100644
--- a/solr/modules/extraction/src/java/org/apache/solr/handler/extraction/ExtractingDocumentLoader.java
+++ b/solr/modules/extraction/src/java/org/apache/solr/handler/extraction/ExtractingDocumentLoader.java
@@ -19,8 +19,8 @@ package org.apache.solr.handler.extraction;
import java.io.IOException;
import java.io.InputStream;
import java.lang.invoke.MethodHandles;
-import java.util.Collections;
import java.util.LinkedHashMap;
+import java.util.Map;
import java.util.regex.Pattern;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.SolrParams;
@@ -142,7 +142,7 @@ public class ExtractingDocumentLoader extends ContentStreamLoader {
.extractFormat(extractFormat)
.tikaServerRecursive(tikaserverRecursive)
.tikaServerTimeoutSeconds(tikaTimeoutSecs)
- .tikaServerRequestHeaders(Collections.emptyMap())
+ .tikaServerRequestHeaders(Map.of())
.build();
boolean captureAttr = params.getBool(ExtractingParams.CAPTURE_ATTRIBUTES, false);
diff --git a/solr/modules/extraction/src/java/org/apache/solr/handler/extraction/ExtractionMetadata.java b/solr/modules/extraction/src/java/org/apache/solr/handler/extraction/ExtractionMetadata.java
index 764a0a9d152..1a274e10f3b 100644
--- a/solr/modules/extraction/src/java/org/apache/solr/handler/extraction/ExtractionMetadata.java
+++ b/solr/modules/extraction/src/java/org/apache/solr/handler/extraction/ExtractionMetadata.java
@@ -18,7 +18,6 @@ package org.apache.solr.handler.extraction;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
@@ -42,7 +41,7 @@ public class ExtractionMetadata extends LinkedHashMap<String, List<String>> {
/** Gets all metadata values for the given name. */
public List<String> get(String name) {
List<String> vals = super.get(name);
- return (vals == null) ? Collections.emptyList() : vals;
+ return (vals == null) ? List.of() : vals;
}
/** Gets the first metadata value for the given name or null if not set. */
diff --git a/solr/modules/extraction/src/java/org/apache/solr/handler/extraction/SolrContentHandler.java b/solr/modules/extraction/src/java/org/apache/solr/handler/extraction/SolrContentHandler.java
index f9d84167127..c825605994f 100644
--- a/solr/modules/extraction/src/java/org/apache/solr/handler/extraction/SolrContentHandler.java
+++ b/solr/modules/extraction/src/java/org/apache/solr/handler/extraction/SolrContentHandler.java
@@ -18,7 +18,6 @@ package org.apache.solr.handler.extraction;
import java.lang.invoke.MethodHandles;
import java.util.ArrayDeque;
-import java.util.Collections;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
@@ -92,7 +91,7 @@ public class SolrContentHandler extends DefaultHandler implements ExtractingPara
fieldBuilders.put(captureFields[i], new StringBuilder());
}
} else {
- fieldBuilders = Collections.emptyMap();
+ fieldBuilders = Map.of();
}
bldrStack.add(catchAllBuilder);
}
diff --git a/solr/modules/extraction/src/java/org/apache/solr/handler/extraction/fromtika/ToXMLContentHandler.java b/solr/modules/extraction/src/java/org/apache/solr/handler/extraction/fromtika/ToXMLContentHandler.java
index 5310e234d7b..11929cb05d5 100644
--- a/solr/modules/extraction/src/java/org/apache/solr/handler/extraction/fromtika/ToXMLContentHandler.java
+++ b/solr/modules/extraction/src/java/org/apache/solr/handler/extraction/fromtika/ToXMLContentHandler.java
@@ -23,7 +23,6 @@ package org.apache.solr.handler.extraction.fromtika;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.xml.sax.Attributes;
@@ -47,7 +46,7 @@ public class ToXMLContentHandler extends ToTextContentHandler {
public ElementInfo(ElementInfo parent, Map<String, String> namespaces) {
this.parent = parent;
if (namespaces.isEmpty()) {
- this.namespaces = Collections.emptyMap();
+ this.namespaces = Map.of();
} else {
this.namespaces = new HashMap<String, String>(namespaces);
}
diff --git a/solr/modules/extraction/src/test/org/apache/solr/handler/extraction/TikaServerExtractionBackendTest.java b/solr/modules/extraction/src/test/org/apache/solr/handler/extraction/TikaServerExtractionBackendTest.java
index 5fc5dd2c169..49dca514e24 100644
--- a/solr/modules/extraction/src/test/org/apache/solr/handler/extraction/TikaServerExtractionBackendTest.java
+++ b/solr/modules/extraction/src/test/org/apache/solr/handler/extraction/TikaServerExtractionBackendTest.java
@@ -21,7 +21,6 @@ import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
-import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -175,7 +174,7 @@ public class TikaServerExtractionBackendTest extends SolrTestCaseJ4 {
}
private ExtractionRequest newRequest(String file, String contentType, String content) {
- return newRequest(file, contentType, content, false, Collections.emptyMap());
+ return newRequest(file, contentType, content, false, Map.of());
}
@Test
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.java
index 4c4c35eaabb..8815b73ecec 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
@@ -257,7 +257,7 @@ public class JWTAuthPlugin extends AuthenticationPlugin
}
Object redirectUrisObj = pluginConfig.get(PARAM_REDIRECT_URIS);
- redirectUris = Collections.emptyList();
+ redirectUris = List.of();
if (redirectUrisObj != null) {
if (redirectUrisObj instanceof String) {
redirectUris = Collections.singletonList((String) redirectUrisObj);
@@ -603,7 +603,7 @@ public class JWTAuthPlugin extends AuthenticationPlugin
}
// Find scopes for user
- Set<String> scopes = Collections.emptySet();
+ Set<String> scopes = Set.of();
Object scopesObj = jwtClaims.getClaimValue(CLAIM_SCOPE);
if (scopesObj != null) {
if (scopesObj instanceof String) {
diff --git a/solr/modules/langid/src/java/org/apache/solr/update/processor/LangDetectLanguageIdentifierUpdateProcessor.java b/solr/modules/langid/src/java/org/apache/solr/update/processor/LangDetectLanguageIdentifierUpdateProcessor.java
index d3882348f4b..f5824b8e916 100644
--- a/solr/modules/langid/src/java/org/apache/solr/update/processor/LangDetectLanguageIdentifierUpdateProcessor.java
+++ b/solr/modules/langid/src/java/org/apache/solr/update/processor/LangDetectLanguageIdentifierUpdateProcessor.java
@@ -24,7 +24,6 @@ import java.io.IOException;
import java.io.Reader;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;
@@ -79,10 +78,10 @@ public class LangDetectLanguageIdentifierUpdateProcessor extends LanguageIdentif
return solrLangList;
} catch (LangDetectException e) {
log.debug("Could not determine language, returning empty list: ", e);
- return Collections.emptyList();
+ return List.of();
} catch (IOException e) {
log.warn("Could not determine language.", e);
- return Collections.emptyList();
+ return List.of();
}
}
}
diff --git a/solr/modules/ltr/src/java/org/apache/solr/ltr/LTRScoringQuery.java b/solr/modules/ltr/src/java/org/apache/solr/ltr/LTRScoringQuery.java
index 22a9a8e5dfb..963e706be99 100644
--- a/solr/modules/ltr/src/java/org/apache/solr/ltr/LTRScoringQuery.java
+++ b/solr/modules/ltr/src/java/org/apache/solr/ltr/LTRScoringQuery.java
@@ -21,7 +21,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.List;
import java.util.Map;
import java.util.concurrent.Callable;
@@ -80,7 +79,7 @@ public class LTRScoringQuery extends Query implements Accountable {
private Feature.FeatureWeight[] extractedFeatureWeights;
public LTRScoringQuery(LTRScoringModel ltrScoringModel) {
- this(ltrScoringModel, Collections.<String, String[]>emptyMap(), null);
+ this(ltrScoringModel, Map.of(), null);
}
public LTRScoringQuery(
diff --git a/solr/modules/ltr/src/java/org/apache/solr/ltr/response/transform/LTRFeatureLoggerTransformerFactory.java b/solr/modules/ltr/src/java/org/apache/solr/ltr/response/transform/LTRFeatureLoggerTransformerFactory.java
index a85597bde08..32b55af0436 100644
--- a/solr/modules/ltr/src/java/org/apache/solr/ltr/response/transform/LTRFeatureLoggerTransformerFactory.java
+++ b/solr/modules/ltr/src/java/org/apache/solr/ltr/response/transform/LTRFeatureLoggerTransformerFactory.java
@@ -17,7 +17,6 @@
package org.apache.solr.ltr.response.transform;
import java.io.IOException;
-import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -462,13 +461,7 @@ public class LTRFeatureLoggerTransformerFactory extends TransformerFactory {
private static class LoggingModel extends LTRScoringModel {
public LoggingModel(String name, String featureStoreName, List<Feature> allFeatures) {
- this(
- name,
- Collections.emptyList(),
- Collections.emptyList(),
- featureStoreName,
- allFeatures,
- Collections.emptyMap());
+ this(name, List.of(), List.of(), featureStoreName, allFeatures, Map.of());
}
protected LoggingModel(
diff --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.java
index 119f6ba5e14..80e2b1b3101 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
@@ -37,17 +37,11 @@ public class TestWrapperModel extends TestRerankBase {
private static class StubWrapperModel extends WrapperModel {
private StubWrapperModel(String name) {
- this(name, Collections.emptyList(), Collections.emptyList());
+ this(name, List.of(), List.of());
}
private StubWrapperModel(String name, List<Feature> features, List<Normalizer> norms) {
- super(
- name,
- features,
- norms,
- FeatureStore.DEFAULT_FEATURE_STORE_NAME,
- features,
- Collections.emptyMap());
+ super(name, features, norms, FeatureStore.DEFAULT_FEATURE_STORE_NAME, features, Map.of());
}
@Override
@@ -73,18 +67,14 @@ public class TestWrapperModel extends TestRerankBase {
// wrapper model with features
WrapperModel wrapperModelWithFeatures =
new StubWrapperModel(
- "testModel",
- Collections.singletonList(new ValueFeature("val", Collections.emptyMap())),
- Collections.emptyList());
+ "testModel", Collections.singletonList(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 norms
WrapperModel wrapperModelWithNorms =
new StubWrapperModel(
- "testModel",
- Collections.emptyList(),
- Collections.singletonList(IdentityNormalizer.INSTANCE));
+ "testModel", List.of(), Collections.singletonList(IdentityNormalizer.INSTANCE));
e = expectThrows(ModelException.class, wrapperModelWithNorms::validate);
assertEquals("norms must be empty for the wrapper model testModel", e.getMessage());
@@ -95,9 +85,7 @@ public class TestWrapperModel extends TestRerankBase {
LTRScoringModel wrappedModel =
createMockWrappedModel(
FeatureStore.DEFAULT_FEATURE_STORE_NAME,
- Arrays.asList(
- new ValueFeature("v1", Collections.emptyMap()),
- new ValueFeature("v2", Collections.emptyMap())),
+ Arrays.asList(new ValueFeature("v1", Map.of()), new ValueFeature("v2", Map.of())),
Arrays.asList(IdentityNormalizer.INSTANCE, IdentityNormalizer.INSTANCE));
wrapperModel.updateModel(wrappedModel);
}
@@ -107,9 +95,7 @@ public class TestWrapperModel extends TestRerankBase {
LTRScoringModel wrappedModel =
createMockWrappedModel(
"wrappedFeatureStore",
- Arrays.asList(
- new ValueFeature("v1", Collections.emptyMap()),
- new ValueFeature("v2", Collections.emptyMap())),
+ Arrays.asList(new ValueFeature("v1", Map.of()), new ValueFeature("v2", Map.of())),
Arrays.asList(IdentityNormalizer.INSTANCE, IdentityNormalizer.INSTANCE));
e = expectThrows(ModelException.class, () -> wrapperModel.updateModel(wrappedModel));
assertEquals(
@@ -122,7 +108,7 @@ public class TestWrapperModel extends TestRerankBase {
LTRScoringModel wrappedModel =
createMockWrappedModel(
FeatureStore.DEFAULT_FEATURE_STORE_NAME,
- Collections.emptyList(),
+ List.of(),
Arrays.asList(IdentityNormalizer.INSTANCE, IdentityNormalizer.INSTANCE));
e = expectThrows(ModelException.class, () -> wrapperModel.updateModel(wrappedModel));
assertEquals("no features declared for model testModel", e.getMessage());
@@ -133,10 +119,8 @@ public class TestWrapperModel extends TestRerankBase {
LTRScoringModel wrappedModel =
createMockWrappedModel(
FeatureStore.DEFAULT_FEATURE_STORE_NAME,
- Arrays.asList(
- new ValueFeature("v1", Collections.emptyMap()),
- new ValueFeature("v2", Collections.emptyMap())),
- Collections.emptyList());
+ Arrays.asList(new ValueFeature("v1", Map.of()), new ValueFeature("v2", Map.of())),
+ List.of());
e = expectThrows(ModelException.class, () -> wrapperModel.updateModel(wrappedModel));
assertEquals("counted 2 features and 0 norms in model testModel", e.getMessage());
}
diff --git a/solr/modules/sql/src/java/org/apache/solr/handler/sql/SolrTable.java b/solr/modules/sql/src/java/org/apache/solr/handler/sql/SolrTable.java
index 8bf82037e03..daffb2788ff 100644
--- a/solr/modules/sql/src/java/org/apache/solr/handler/sql/SolrTable.java
+++ b/solr/modules/sql/src/java/org/apache/solr/handler/sql/SolrTable.java
@@ -22,7 +22,6 @@ import static org.apache.solr.common.params.CommonParams.SORT;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -117,16 +116,7 @@ class SolrTable extends AbstractQueryableTable implements TranslatableTable {
private Enumerable<Object> query(final Properties properties) {
return query(
- properties,
- Collections.emptyList(),
- null,
- Collections.emptyList(),
- Collections.emptyList(),
- Collections.emptyList(),
- null,
- null,
- null,
- null);
+ properties, List.of(), null, List.of(), List.of(), List.of(), null, null, null, null);
}
/**
diff --git a/solr/solrj-streaming/src/java/org/apache/solr/client/solrj/io/eval/ListCacheEvaluator.java b/solr/solrj-streaming/src/java/org/apache/solr/client/solrj/io/eval/ListCacheEvaluator.java
index b6026bf05af..052e7e29813 100644
--- a/solr/solrj-streaming/src/java/org/apache/solr/client/solrj/io/eval/ListCacheEvaluator.java
+++ b/solr/solrj-streaming/src/java/org/apache/solr/client/solrj/io/eval/ListCacheEvaluator.java
@@ -18,7 +18,7 @@ package org.apache.solr.client.solrj.io.eval;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Collections;
+import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentMap;
@@ -54,7 +54,7 @@ public class ListCacheEvaluator extends RecursiveObjectEvaluator implements Many
if (spaceCache != null) {
return new ArrayList<>(spaceCache.keySet());
} else {
- return Collections.emptyList();
+ return List.of();
}
} else {
throw new IOException("The listCache function requires two parameters: workspace and key");
diff --git a/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/eval/MovingAverageEvaluatorTest.java b/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/eval/MovingAverageEvaluatorTest.java
index 9c7d45a0e9c..df88bc9db98 100644
--- a/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/eval/MovingAverageEvaluatorTest.java
+++ b/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/eval/MovingAverageEvaluatorTest.java
@@ -17,8 +17,8 @@
package org.apache.solr.client.solrj.io.stream.eval;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import org.apache.solr.SolrTestCase;
import org.apache.solr.client.solrj.io.Tuple;
@@ -47,6 +47,6 @@ public class MovingAverageEvaluatorTest extends SolrTestCase {
values.clear();
values.put("a", new ArrayList<Double>());
result = evaluator.evaluate(new Tuple(values));
- assertEquals(Collections.emptyList(), result);
+ assertEquals(List.of(), result);
}
}
diff --git a/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/ZkClientClusterStateProvider.java b/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/ZkClientClusterStateProvider.java
index b92dab8c362..fd3525b564b 100644
--- a/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/ZkClientClusterStateProvider.java
+++ b/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/ZkClientClusterStateProvider.java
@@ -21,7 +21,6 @@ import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.time.Instant;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -108,7 +107,7 @@ public class ZkClientClusterStateProvider
SolrZkClient zkClient,
Instant createTime) {
if (bytes == null || bytes.length == 0) {
- return new ClusterState(liveNodes, Collections.emptyMap());
+ return new ClusterState(liveNodes, Map.of());
}
Map<String, Object> stateMap = (Map<String, Object>) Utils.fromJSON(bytes);
Map<String, Object> props = (Map<String, Object>) stateMap.get(coll);
@@ -158,7 +157,7 @@ public class ZkClientClusterStateProvider
if (clusterState != null) {
return clusterState.getLiveNodes();
} else {
- return Collections.emptySet();
+ return Set.of();
}
}
diff --git a/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/ZkDistribStateManager.java b/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/ZkDistribStateManager.java
index b361bcd0662..e0631302ae3 100644
--- a/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/ZkDistribStateManager.java
+++ b/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/ZkDistribStateManager.java
@@ -18,7 +18,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.NoSuchElementException;
@@ -55,10 +54,10 @@ public class ZkDistribStateManager implements DistribStateManager {
try {
data = getData(path);
} catch (KeeperException.NoNodeException | NoSuchElementException e) {
- return Collections.emptyMap();
+ return Map.of();
}
if (data == null || data.getData() == null || data.getData().length == 0) {
- return Collections.emptyMap();
+ return Map.of();
}
return (Map<String, Object>) Utils.fromJSON(data.getData());
}
diff --git a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ClusterProperties.java b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ClusterProperties.java
index f70ba68c099..dde902e0806 100644
--- a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ClusterProperties.java
+++ b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ClusterProperties.java
@@ -20,7 +20,6 @@ package org.apache.solr.common.cloud;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.util.Arrays;
-import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -97,7 +96,7 @@ public class ClusterProperties {
Utils.fromJSON(client.getData(ZkStateReader.CLUSTER_PROPS, null, new Stat()));
return properties;
} catch (KeeperException.NoNodeException e) {
- return Collections.emptyMap();
+ return Map.of();
} catch (KeeperException | InterruptedException e) {
throw new IOException("Error reading cluster property", SolrZkClient.checkInterrupted(e));
}
diff --git a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/CollectionProperties.java b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/CollectionProperties.java
index 25b13086267..54ff67e712e 100644
--- a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/CollectionProperties.java
+++ b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/CollectionProperties.java
@@ -18,7 +18,6 @@
package org.apache.solr.common.cloud;
import java.io.IOException;
-import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.solr.common.util.Utils;
@@ -69,7 +68,7 @@ public class CollectionProperties {
Utils.fromJSON(
client.getData(ZkStateReader.getCollectionPropsPath(collection), null, new Stat()));
} catch (KeeperException.NoNodeException e) {
- return Collections.emptyMap();
+ return Map.of();
} catch (KeeperException | InterruptedException e) {
throw new IOException(
"Error reading properties for collection " + collection,
diff --git a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/CollectionPropertiesZkStateReader.java b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/CollectionPropertiesZkStateReader.java
index d23014e5849..31f2369e26f 100644
--- a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/CollectionPropertiesZkStateReader.java
+++ b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/CollectionPropertiesZkStateReader.java
@@ -16,8 +16,6 @@
*/
package org.apache.solr.common.cloud;
-import static java.util.Collections.emptyMap;
-
import java.io.Closeable;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
@@ -335,7 +333,7 @@ public class CollectionPropertiesZkStateReader implements Closeable {
continue;
}
}
- return new VersionedCollectionProps(-1, emptyMap());
+ return new VersionedCollectionProps(-1, Map.of());
}
}
}
diff --git a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/DefaultZkCredentialsInjector.java b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/DefaultZkCredentialsInjector.java
index d78d4da83ef..5f1fe840453 100755
--- a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/DefaultZkCredentialsInjector.java
+++ b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/DefaultZkCredentialsInjector.java
@@ -16,13 +16,12 @@
*/
package org.apache.solr.common.cloud;
-import java.util.Collections;
import java.util.List;
public class DefaultZkCredentialsInjector implements ZkCredentialsInjector {
@Override
public List<ZkCredential> getZkCredentials() {
- return Collections.emptyList();
+ return List.of();
}
}
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.java
index 1995bae34bd..d37a55ca7ec 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
@@ -60,7 +60,7 @@ public class PerReplicaStatesOps {
PerReplicaStatesOps.class.getName() + "/beforePrsFetch");
if (current != null) {
Stat stat = zkClient.exists(current.path, null);
- if (stat == null) return new PerReplicaStates(path, 0, Collections.emptyList());
+ if (stat == null) return new PerReplicaStates(path, 0, List.of());
if (current.cversion == stat.getCversion()) return current; // not modifiedZkStateReaderTest
}
Stat stat = new Stat();
@@ -292,7 +292,7 @@ public class PerReplicaStatesOps {
prs -> {
List<PerReplicaStates.Operation> result;
if (prs == null) {
- result = Collections.emptyList();
+ result = List.of();
} else {
PerReplicaStates.State state = prs.get(replica);
result = addDeleteStaleNodes(new ArrayList<>(), state);
@@ -356,7 +356,7 @@ public class PerReplicaStatesOps {
public List<PerReplicaStates.Operation> get(PerReplicaStates rs) {
ops = refresh(rs);
- if (ops == null) ops = Collections.emptyList();
+ if (ops == null) ops = List.of();
this.rs = rs;
return ops;
}
diff --git a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/SecurityNodeWatcher.java b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/SecurityNodeWatcher.java
index 0a35bad37e5..376a9c140c5 100644
--- a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/SecurityNodeWatcher.java
+++ b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/SecurityNodeWatcher.java
@@ -16,8 +16,6 @@
*/
package org.apache.solr.common.cloud;
-import static java.util.Collections.emptyMap;
-
import java.lang.invoke.MethodHandles;
import java.nio.charset.StandardCharsets;
import java.util.Map;
@@ -47,7 +45,7 @@ class SecurityNodeWatcher implements Watcher {
ZkStateReader.ConfigData cd = new ZkStateReader.ConfigData();
cd.data =
data.data == null || data.data.length == 0
- ? emptyMap()
+ ? Map.of()
: Utils.getDeepCopy((Map) Utils.fromJSON(data.data), 4, false);
cd.version = data.stat == null ? -1 : data.stat.getVersion();
securityData = cd;
@@ -101,7 +99,7 @@ class SecurityNodeWatcher implements Watcher {
@SuppressWarnings("unchecked")
ZkStateReader.ConfigData getSecurityProps(boolean getFresh) {
if (!getFresh) {
- if (securityData == null) return new ZkStateReader.ConfigData(emptyMap(), -1);
+ if (securityData == null) return new ZkStateReader.ConfigData(Map.of(), -1);
return new ZkStateReader.ConfigData(securityData.data, securityData.version);
}
try {
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.java
index 2f60c7aad9b..88033012b9f 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
@@ -16,7 +16,6 @@
*/
package org.apache.solr.common.cloud;
-import static java.util.Collections.emptyMap;
import static java.util.Collections.emptySortedSet;
import java.lang.invoke.MethodHandles;
@@ -181,7 +180,7 @@ public class ZkStateReader implements SolrCloseable {
private volatile SortedSet<String> liveNodes = emptySortedSet();
- private volatile Map<String, Object> clusterProperties = Collections.emptyMap();
+ private volatile Map<String, Object> clusterProperties = Map.of();
/**
* Collections with active watches. The {@link StatefulCollectionWatch} inside for each collection
@@ -718,7 +717,7 @@ public class ZkStateReader implements SolrCloseable {
}
private void notifyNewCloudCollectionsListener(CloudCollectionsListener listener) {
- listener.onChange(Collections.emptySet(), lastFetchedCollectionSet.get());
+ listener.onChange(Set.of(), lastFetchedCollectionSet.get());
}
private void notifyCloudCollectionsListeners() {
@@ -1187,7 +1186,7 @@ public class ZkStateReader implements SolrCloseable {
}
return;
} catch (KeeperException.NoNodeException e) {
- this.clusterProperties = Collections.emptyMap();
+ this.clusterProperties = Map.of();
log.debug("Loaded empty cluster properties");
// set an exists watch, and if the node has been created since the last call,
// read the data again
@@ -1220,7 +1219,7 @@ public class ZkStateReader implements SolrCloseable {
* returns null.
*/
public ConfigData getSecurityProps(boolean getFresh) {
- if (securityNodeWatcher == null) return new ConfigData(emptyMap(), -1);
+ if (securityNodeWatcher == null) return new ConfigData(Map.of(), -1);
return securityNodeWatcher.getSecurityProps(getFresh);
}
@@ -1367,7 +1366,7 @@ public class ZkStateReader implements SolrCloseable {
log.debug("A collections change: [{}], has occurred - updating...", event);
refreshAndWatch();
synchronized (getUpdateLock()) {
- constructState(Collections.emptySet());
+ constructState(Set.of());
}
}
@@ -1454,7 +1453,7 @@ public class ZkStateReader implements SolrCloseable {
ZkClientClusterStateProvider.createFromJsonSupportingLegacyConfigName(
stat.getVersion(),
data,
- Collections.emptySet(),
+ Set.of(),
coll,
zkClient,
Instant.ofEpochMilli(stat.getCtime()));
@@ -1557,7 +1556,7 @@ public class ZkStateReader implements SolrCloseable {
});
if (reconstructState.get()) {
synchronized (getUpdateLock()) {
- constructState(Collections.emptySet());
+ constructState(Set.of());
}
}
}
@@ -1863,7 +1862,7 @@ public class ZkStateReader implements SolrCloseable {
});
if (reconstructState.get()) {
synchronized (getUpdateLock()) {
- constructState(Collections.emptySet());
+ constructState(Set.of());
}
}
}
@@ -1979,7 +1978,7 @@ public class ZkStateReader implements SolrCloseable {
// called by createClusterStateWatchersAndUpdate()
private void refreshAliases(AliasesManager watcher) throws KeeperException, InterruptedException {
synchronized (getUpdateLock()) {
- constructState(Collections.emptySet());
+ constructState(Set.of());
zkClient.exists(ALIASES, watcher);
}
aliasesManager.update();
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpClusterStateProvider.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpClusterStateProvider.java
index c9ae7b1bc7e..e2faf6b58ba 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpClusterStateProvider.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpClusterStateProvider.java
@@ -329,8 +329,8 @@ public abstract class BaseHttpClusterStateProvider implements ClusterStateProvid
"LISTALIASES not found, possibly using older Solr server. Aliases won't work {}",
"unless you upgrade Solr server",
e);
- this.aliases = Collections.emptyMap();
- this.aliasProperties = Collections.emptyMap();
+ this.aliases = Map.of();
+ this.aliasProperties = Map.of();
this.aliasesTimestamp = System.nanoTime();
return aliases;
}
@@ -354,7 +354,7 @@ public abstract class BaseHttpClusterStateProvider implements ClusterStateProvid
@Override
public Map<String, String> getAliasProperties(String alias) {
getAliases(false);
- return Collections.unmodifiableMap(aliasProperties.getOrDefault(alias, Collections.emptyMap()));
+ return Collections.unmodifiableMap(aliasProperties.getOrDefault(alias, Map.of()));
}
@Override
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.java
index df7034acf83..60a80e15634 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
@@ -1123,7 +1123,7 @@ public abstract class CloudSolrClient extends SolrClient {
}
List<String> inputCollections =
- collection == null ? Collections.emptyList() : StrUtils.splitSmart(collection, ",", true);
+ collection == null ? List.of() : StrUtils.splitSmart(collection, ",", true);
return requestWithRetryOnStaleState(
request,
0,
@@ -1577,7 +1577,7 @@ public abstract class CloudSolrClient extends SolrClient {
*/
private Set<String> resolveAliases(List<String> inputCollections) {
if (inputCollections.isEmpty()) {
- return Collections.emptySet();
+ return Set.of();
}
LinkedHashSet<String> uniqueNames = new LinkedHashSet<>(); // consistent ordering
for (String collectionName : inputCollections) {
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.java
index 019ef748f02..48030c79c7c 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
@@ -46,7 +46,7 @@ public class DelegatingClusterStateProvider implements ClusterStateProvider {
if (delegate != null) {
return delegate.getLiveNodes();
} else {
- return Collections.emptySet();
+ return Set.of();
}
}
@@ -64,7 +64,7 @@ public class DelegatingClusterStateProvider implements ClusterStateProvider {
if (delegate != null) {
return delegate.getAliasProperties(alias);
} else {
- return Collections.emptyMap();
+ return Map.of();
}
}
@@ -100,7 +100,7 @@ public class DelegatingClusterStateProvider implements ClusterStateProvider {
if (delegate != null) {
return delegate.getClusterProperties();
} else {
- return Collections.emptyMap();
+ return Map.of();
}
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/request/ApiMapping.java b/solr/solrj/src/java/org/apache/solr/client/solrj/request/ApiMapping.java
index 8c972a343eb..640d4780a5c 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/request/ApiMapping.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/request/ApiMapping.java
@@ -19,10 +19,10 @@ package org.apache.solr.client.solrj.request;
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 org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.common.util.CommandOperation;
@@ -60,7 +60,7 @@ public class ApiMapping {
collectKeyNames(map, result, "");
return result;
} else {
- return Collections.emptySet();
+ return Set.of();
}
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/request/SolrQuery.java b/solr/solrj/src/java/org/apache/solr/client/solrj/request/SolrQuery.java
index 6146dbe0d6e..23a3c459f76 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/request/SolrQuery.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/request/SolrQuery.java
@@ -623,7 +623,7 @@ public class SolrQuery extends ModifiableSolrParams {
* @since 4.2
*/
public List<SortClause> getSorts() {
- if (sortClauses == null) return Collections.emptyList();
+ if (sortClauses == null) return List.of();
else return Collections.unmodifiableList(sortClauses);
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/response/Cluster.java b/solr/solrj/src/java/org/apache/solr/client/solrj/response/Cluster.java
index fad992c1388..59a97f6d757 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/response/Cluster.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/response/Cluster.java
@@ -16,7 +16,6 @@
*/
package org.apache.solr.client.solrj.response;
-import java.util.Collections;
import java.util.List;
import java.util.Objects;
@@ -32,7 +31,7 @@ public class Cluster {
private boolean otherTopics;
public Cluster(List<String> labels, double score, List<String> docIds) {
- this(labels, score, docIds, Collections.emptyList(), false);
+ this(labels, score, docIds, List.of(), false);
}
/**
@@ -46,10 +45,10 @@ public class Cluster {
List<String> docIds,
List<Cluster> subclusters,
boolean otherTopics) {
- this.labels = Objects.requireNonNullElse(labels, Collections.emptyList());
+ this.labels = Objects.requireNonNullElse(labels, List.of());
this.score = score;
- this.docIds = Objects.requireNonNullElse(docIds, Collections.emptyList());
- this.subclusters = Objects.requireNonNullElse(subclusters, Collections.emptyList());
+ this.docIds = Objects.requireNonNullElse(docIds, List.of());
+ this.subclusters = Objects.requireNonNullElse(subclusters, List.of());
this.otherTopics = otherTopics;
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/response/ClusteringResponse.java b/solr/solrj/src/java/org/apache/solr/client/solrj/response/ClusteringResponse.java
index 0700ff8d269..0fe1bc5bf92 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/response/ClusteringResponse.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/response/ClusteringResponse.java
@@ -17,7 +17,6 @@
package org.apache.solr.client.solrj.response;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.apache.solr.common.util.NamedList;
@@ -37,8 +36,8 @@ public class ClusteringResponse {
clusters = new ArrayList<>();
for (NamedList<Object> clusterNode : clusterInfo) {
List<String> labelList, docIdList;
- List<Cluster> subclusters = Collections.emptyList();
- labelList = docIdList = Collections.emptyList();
+ List<Cluster> subclusters = List.of();
+ labelList = docIdList = List.of();
Double score = 0d;
boolean otherTopics = false;
for (Map.Entry<String, ?> e : clusterNode) {
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/response/CollectionAdminResponse.java b/solr/solrj/src/java/org/apache/solr/client/solrj/response/CollectionAdminResponse.java
index 71aeb2c8d6e..1b01029c018 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/response/CollectionAdminResponse.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/response/CollectionAdminResponse.java
@@ -16,7 +16,6 @@
*/
package org.apache.solr.client.solrj.response;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -67,7 +66,7 @@ public class CollectionAdminResponse extends SolrResponseBase {
if (response.get("aliases") != null) {
return ((Map<String, String>) response.get("aliases"));
}
- return Collections.emptyMap();
+ return Map.of();
}
public Map<String, List<String>> getAliasesAsLists() {
@@ -81,7 +80,7 @@ public class CollectionAdminResponse extends SolrResponseBase {
if (response.get("properties") != null) {
return ((Map<String, Map<String, String>>) response.get("properties"));
}
- return Collections.emptyMap();
+ return Map.of();
}
@SuppressWarnings("unchecked")
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/response/FacetField.java b/solr/solrj/src/java/org/apache/solr/client/solrj/response/FacetField.java
index 9e9025d7672..b339ac28471 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/response/FacetField.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/response/FacetField.java
@@ -18,7 +18,6 @@ package org.apache.solr.client.solrj.response;
import java.io.Serializable;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import org.apache.solr.client.solrj.util.ClientUtils;
@@ -102,7 +101,7 @@ public class FacetField implements Serializable {
}
public List<Count> getValues() {
- return _values == null ? Collections.<Count>emptyList() : _values;
+ return _values == null ? List.of() : _values;
}
public int getValueCount() {
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/response/LukeResponse.java b/solr/solrj/src/java/org/apache/solr/client/solrj/response/LukeResponse.java
index c38a2caf830..265a40dfb3e 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/response/LukeResponse.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/response/LukeResponse.java
@@ -18,7 +18,6 @@ package org.apache.solr.client.solrj.response;
import java.io.Serializable;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
@@ -43,7 +42,7 @@ public class LukeResponse extends SolrResponseBase {
public FieldTypeInfo(String name) {
this.name = name;
- fields = Collections.emptyList();
+ fields = List.of();
}
public String getAnalyzer() {
diff --git a/solr/solrj/src/java/org/apache/solr/common/MapWriter.java b/solr/solrj/src/java/org/apache/solr/common/MapWriter.java
index d0e52f6892f..3f1f61e24ba 100644
--- a/solr/solrj/src/java/org/apache/solr/common/MapWriter.java
+++ b/solr/solrj/src/java/org/apache/solr/common/MapWriter.java
@@ -18,7 +18,6 @@
package org.apache.solr.common;
import java.io.IOException;
-import java.util.Collections;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.function.BiPredicate;
@@ -153,5 +152,5 @@ public interface MapWriter extends MapSerializable, NavigableObject, JSONWriter.
}
@Deprecated // use SimpleOrderedMap.of()
- MapWriter EMPTY = new MapWriterMap(Collections.emptyMap());
+ MapWriter EMPTY = new MapWriterMap(Map.of());
}
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/Aliases.java b/solr/solrj/src/java/org/apache/solr/common/cloud/Aliases.java
index c29cdb6f5d8..1e383fd91ae 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
@@ -43,8 +43,7 @@ public class Aliases {
* aliases are removed. The -1 version makes it subordinate to any real version, and furthermore
* we never "set" this EMPTY instance into ZK.
*/
- public static final Aliases EMPTY =
- new Aliases(Collections.emptyMap(), Collections.emptyMap(), -1);
+ public static final Aliases EMPTY = new Aliases(Map.of(), Map.of(), -1);
// These two constants correspond to the top level elements in aliases.json. The first one denotes
// a section containing a list of aliases and their attendant collections, the second contains a
@@ -97,11 +96,11 @@ public class Aliases {
Map<String, Map> aliasMap = (Map<String, Map>) Utils.fromJSON(bytes);
@SuppressWarnings({"rawtypes"})
- Map colAliases = aliasMap.getOrDefault(COLLECTION, Collections.emptyMap());
+ Map colAliases = aliasMap.getOrDefault(COLLECTION, Map.of());
colAliases = convertMapOfCommaDelimitedToMapOfList(colAliases); // also unmodifiable
Map<String, Map<String, String>> colMeta =
- aliasMap.getOrDefault(COLLECTION_METADATA, Collections.emptyMap());
+ new LinkedHashMap<>(aliasMap.getOrDefault(COLLECTION_METADATA, Map.of()));
colMeta.replaceAll((k, metaMap) -> Collections.unmodifiableMap(metaMap));
return new Aliases(colAliases, colMeta, zNodeVersion);
@@ -190,7 +189,7 @@ public class Aliases {
*/
public Map<String, String> getCollectionAliasProperties(String alias) {
// Note: map is already unmodifiable; it can be shared safely
- return collectionAliasProperties.getOrDefault(alias, Collections.emptyMap());
+ return collectionAliasProperties.getOrDefault(alias, Map.of());
}
/**
@@ -460,7 +459,7 @@ public class Aliases {
Map<String, Map<String, String>> newColProperties =
new LinkedHashMap<>(this.collectionAliasProperties); // clone to modify
Map<String, String> newMetaMap =
- new LinkedHashMap<>(newColProperties.getOrDefault(alias, Collections.emptyMap()));
+ new LinkedHashMap<>(newColProperties.getOrDefault(alias, Map.of()));
for (Map.Entry<String, String> metaEntry : properties.entrySet()) {
if (metaEntry.getValue() != null) {
newMetaMap.put(metaEntry.getKey(), metaEntry.getValue());
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java
index 18e93ec7eb6..ba92c3a9011 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java
@@ -217,7 +217,7 @@ public class ClusterState implements MapWriter {
Instant creationTime,
DocCollection.PrsSupplier prsSupplier) {
if (bytes == null || bytes.length == 0) {
- return new ClusterState(liveNodes, Collections.<String, DocCollection>emptyMap());
+ return new ClusterState(liveNodes, Map.of());
}
@SuppressWarnings({"unchecked"})
Map<String, Object> stateMap =
@@ -273,7 +273,7 @@ public class ClusterState implements MapWriter {
// legacy format from 4.0... there was no separate "shards" level to contain the collection
// shards.
slices = Slice.loadAllFromMap(name, objs);
- props = Collections.emptyMap();
+ props = Map.of();
} else {
slices = Slice.loadAllFromMap(name, sliceObjs);
objs.remove(CollectionStateProps.SHARDS);
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.java
index c13cc4fedef..39adeef1a52 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
@@ -276,7 +276,7 @@ public class CompositeIdRouter extends HashBasedRouter {
int max = range.max;
assert max >= min;
- if (partitions == 0) return Collections.emptyList();
+ if (partitions == 0) return List.of();
long rangeSize = (long) max - (long) min;
long rangeStep = Math.max(1, rangeSize / partitions);
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/DocRouter.java b/solr/solrj/src/java/org/apache/solr/common/cloud/DocRouter.java
index d3a533b07d0..e9de9453ad0 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/DocRouter.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/DocRouter.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.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
@@ -191,7 +190,7 @@ public abstract class DocRouter {
} else if (fuzz < 0.0f) {
fuzz = 0.0f;
}
- if (partitions == 0) return Collections.emptyList();
+ if (partitions == 0) return List.of();
long rangeSize = (long) max - (long) min;
long rangeStep = Math.max(1, rangeSize / partitions);
long fuzzStep = Math.round(rangeStep * (double) fuzz / 2.0);
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.java
index 0a02c39d8e5..2dd6fae7d48 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
@@ -20,6 +20,7 @@ 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;
import org.apache.solr.common.params.SolrParams;
@@ -93,6 +94,6 @@ public abstract class HashBasedRouter extends DocRouter {
// use the shardKey as an id for plain hashing
Slice slice = getTargetSlice(shardKey, null, null, params, collection);
- return slice == null ? Collections.<Slice>emptyList() : Collections.singletonList(slice);
+ return slice == null ? List.of() : Collections.singletonList(slice);
}
}
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/PerReplicaStates.java b/solr/solrj/src/java/org/apache/solr/common/cloud/PerReplicaStates.java
index 0eb9d68ee0c..e4ed2e0f0e0 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/PerReplicaStates.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/PerReplicaStates.java
@@ -22,7 +22,6 @@ import static org.apache.solr.common.params.CommonParams.NAME;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
@@ -256,7 +255,7 @@ public class PerReplicaStates implements ReflectMapWriter {
/** fetch duplicates entries for this replica */
List<State> getDuplicates() {
- if (duplicate == null) return Collections.emptyList();
+ if (duplicate == null) return List.of();
List<State> result = new ArrayList<>();
State current = duplicate;
while (current != null) {
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/Slice.java b/solr/solrj/src/java/org/apache/solr/common/cloud/Slice.java
index 99374dcb7af..c307a8f9f1c 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/Slice.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/Slice.java
@@ -63,7 +63,7 @@ public class Slice extends ZkNodeProps implements Iterable<Replica> {
@SuppressWarnings({"unchecked"})
public static Map<String, Slice> loadAllFromMap(
String collection, Map<String, Object> genericSlices) {
- if (genericSlices == null) return Collections.emptyMap();
+ if (genericSlices == null) return Map.of();
Map<String, Slice> result = CollectionUtil.newLinkedHashMap(genericSlices.size());
for (Map.Entry<String, Object> entry : genericSlices.entrySet()) {
String name = entry.getKey();
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.java
index 37498dd4e84..97e45a7e588 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,7 +16,6 @@
*/
package org.apache.solr.common.util;
-import static java.util.Collections.emptyMap;
import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap;
import static org.apache.solr.common.util.StrUtils.formatString;
@@ -78,7 +77,7 @@ public class CommandOperation {
StrUtils.formatString(
"The command ''{0}'' should have the values as a json object '{'key:val'}' format but is ''{1}''",
name, commandData));
- return Collections.emptyMap();
+ return Map.of();
}
private Object getRootPrimitive() {
@@ -182,7 +181,7 @@ public class CommandOperation {
/** Get all the values from the metadata for the command without the specified keys */
public Map<String, Object> getValuesExcluding(String... keys) {
getMapVal(null);
- if (hasError()) return emptyMap(); // just to verify the type is Map
+ if (hasError()) return Map.of(); // just to verify the type is Map
@SuppressWarnings("unchecked")
LinkedHashMap<String, Object> cp = new LinkedHashMap<>((Map<String, Object>) commandData);
if (keys == null) return cp;
@@ -210,7 +209,7 @@ public class CommandOperation {
}
public static List<CommandOperation> parse(Reader rdr) throws IOException {
- return parse(rdr, Collections.emptySet());
+ return parse(rdr, Set.of());
}
/**
@@ -322,7 +321,7 @@ public class CommandOperation {
public static List<CommandOperation> readCommands(
Iterable<ContentStream> streams, @SuppressWarnings({"rawtypes"}) NamedList resp)
throws IOException {
- return readCommands(streams, resp, Collections.emptySet());
+ return readCommands(streams, resp, Set.of());
}
/**
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/PathTrie.java b/solr/solrj/src/java/org/apache/solr/common/util/PathTrie.java
index 21089a9c92a..0fde7c457b2 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/PathTrie.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/PathTrie.java
@@ -17,8 +17,6 @@
package org.apache.solr.common.util;
-import static java.util.Collections.emptyList;
-
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -32,7 +30,7 @@ import java.util.concurrent.ConcurrentHashMap;
*/
public class PathTrie<T> {
private final Set<String> reserved = new HashSet<>();
- Node root = new Node(emptyList(), null, null);
+ Node root = new Node(List.of(), null, null);
public PathTrie() {}
@@ -70,7 +68,7 @@ public class PathTrie<T> {
// /a/b/c will be returned as ["a","b","c"]
public static List<String> getPathSegments(String path) {
- if (path == null || path.isEmpty()) return emptyList();
+ if (path == null || path.isEmpty()) return List.of();
List<String> parts =
new ArrayList<>() {
@Override
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/StrUtils.java b/solr/solrj/src/java/org/apache/solr/common/util/StrUtils.java
index 28723375fe5..f2aaea28671 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/StrUtils.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/StrUtils.java
@@ -23,7 +23,6 @@ import java.nio.CharBuffer;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import java.util.Locale;
import org.apache.solr.common.SolrException;
@@ -167,7 +166,7 @@ public class StrUtils {
* @return a list of file names with the escaping backslashes removed
*/
public static List<String> splitFileNames(String fileNames) {
- if (fileNames == null) return Collections.<String>emptyList();
+ if (fileNames == null) return List.of();
List<String> result = new ArrayList<>();
for (String file : fileNames.split("(?<!\\\\),")) {
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.java
index 1e2f69da972..164ae8ae7b0 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
@@ -284,7 +284,7 @@ public class Utils {
// Need below check in both fromJSON methods since
// utf8.length returns a NPE without this check.
if (utf8 == null || utf8.length == 0) {
- return Collections.emptyMap();
+ return Map.of();
}
return fromJSON(utf8, 0, utf8.length);
}
@@ -296,7 +296,7 @@ public class Utils {
public static Object fromJSON(
byte[] utf8, int offset, int length, Function<JSONParser, ObjectBuilder> fun) {
if (utf8 == null || utf8.length == 0 || length == 0) {
- return Collections.emptyMap();
+ return Map.of();
}
// convert directly from bytes to chars
// and parse directly from that instead of going through
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/ValidatingJsonMap.java b/solr/solrj/src/java/org/apache/solr/common/util/ValidatingJsonMap.java
index 09fe360cbbe..ff888a75bb2 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/ValidatingJsonMap.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/ValidatingJsonMap.java
@@ -360,7 +360,7 @@ public class ValidatingJsonMap implements Map<String, Object>, NavigableObject {
return Objects.hash(delegate);
}
- public static final ValidatingJsonMap EMPTY = new ValidatingJsonMap(Collections.emptyMap());
+ public static final ValidatingJsonMap EMPTY = new ValidatingJsonMap(Map.of());
public interface PredicateWithErrMsg<T> {
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientCacheTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientCacheTest.java
index d2a864f4a54..55d170ce652 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
@@ -106,7 +106,7 @@ public class CloudSolrClientCacheTest extends SolrTestCaseJ4 {
livenodes.addAll(Set.of("192.168.1.108:7574_solr", "192.168.1.108:8983_solr"));
ClusterState cs =
ClusterState.createFromJson(
- 1, COLL1_STATE.getBytes(UTF_8), Collections.emptySet(), Instant.now(), null);
+ 1, COLL1_STATE.getBytes(UTF_8), Set.of(), Instant.now(), null);
refs.put(collName, new Ref(collName));
colls.put(collName, cs.getCollectionOrNull(collName));
responses.put(
@@ -346,7 +346,7 @@ public class CloudSolrClientCacheTest extends SolrTestCaseJ4 {
private DocCollection loadCollection(String collection, int version) throws Exception {
ClusterState state =
ClusterState.createFromJson(
- version, COLL1_STATE.getBytes(UTF_8), Collections.emptySet(), Instant.now(), null);
+ version, COLL1_STATE.getBytes(UTF_8), Set.of(), Instant.now(), null);
return state.getCollectionOrNull(collection);
}
diff --git a/solr/solrj/src/test/org/apache/solr/common/SolrDocumentTest.java b/solr/solrj/src/test/org/apache/solr/common/SolrDocumentTest.java
index e538ff44651..f184e2ab76b 100644
--- a/solr/solrj/src/test/org/apache/solr/common/SolrDocumentTest.java
+++ b/solr/solrj/src/test/org/apache/solr/common/SolrDocumentTest.java
@@ -143,7 +143,7 @@ public class SolrDocumentTest extends SolrTestCase {
} catch (UnsupportedOperationException ex) {
}
try {
- doc.getFieldValueMap().put("key", Collections.emptyList());
+ doc.getFieldValueMap().put("key", List.of());
fail("should be unsupported!");
} catch (UnsupportedOperationException ex) {
}
diff --git a/solr/solrj/src/test/org/apache/solr/common/util/TestFastJavabinDecoder.java b/solr/solrj/src/test/org/apache/solr/common/util/TestFastJavabinDecoder.java
index 43146351656..14113670ccf 100644
--- a/solr/solrj/src/test/org/apache/solr/common/util/TestFastJavabinDecoder.java
+++ b/solr/solrj/src/test/org/apache/solr/common/util/TestFastJavabinDecoder.java
@@ -22,7 +22,6 @@ import java.io.InputStream;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -234,8 +233,7 @@ public class TestFastJavabinDecoder extends SolrTestCaseJ4 {
assertEquals(String.valueOf(subject), String.valueOf(d.getFieldValue("subject")));
assertEquals(String.valueOf(cat), String.valueOf(d.getFieldValue("cat")));
assertEquals(
- Objects.requireNonNullElse(d.getChildDocuments(), Collections.emptyList()).size(),
- children.size());
+ Objects.requireNonNullElse(d.getChildDocuments(), List.of()).size(), children.size());
@SuppressWarnings({"unchecked"})
List<Long> l = (List<Long>) d.getFieldValue("longs");
if (l != null) {
diff --git a/solr/solrj/src/test/org/apache/solr/common/util/TestPathTrie.java b/solr/solrj/src/test/org/apache/solr/common/util/TestPathTrie.java
index ad7e9066ad3..1fbe1bcad14 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,12 +17,12 @@
package org.apache.solr.common.util;
-import static java.util.Collections.emptyMap;
import static java.util.Collections.singletonMap;
import static org.apache.solr.api.ApiBag.HANDLER_NAME;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
import org.apache.solr.SolrTestCaseJ4;
@@ -30,12 +30,12 @@ public class TestPathTrie extends SolrTestCaseJ4 {
public void testPathTrie() {
PathTrie<String> pathTrie = new PathTrie<>(Set.of("_introspect"));
- pathTrie.insert("/", emptyMap(), "R");
- pathTrie.insert("/aa", emptyMap(), "d");
- pathTrie.insert("/aa/bb/{cc}/dd", emptyMap(), "a");
+ 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("/aa/bb/{cc}/{xx}", emptyMap(), "b");
- pathTrie.insert("/aa/bb", emptyMap(), "c");
+ pathTrie.insert("/aa/bb/{cc}/{xx}", Map.of(), "b");
+ pathTrie.insert("/aa/bb", Map.of(), "c");
HashMap<String, String> templateValues = new HashMap<>();
assertEquals("R", pathTrie.lookup("/", templateValues, null));
@@ -54,7 +54,7 @@ public class TestPathTrie extends SolrTestCaseJ4 {
assertEquals(3, subPaths.size());
pathTrie = new PathTrie<>(Set.of("_introspect"));
- pathTrie.insert("/aa/bb/{cc}/tt/*", emptyMap(), "W");
+ pathTrie.insert("/aa/bb/{cc}/tt/*", Map.of(), "W");
templateValues.clear();
assertEquals("W", pathTrie.lookup("/aa/bb/somepart/tt/hello", templateValues));
@@ -68,7 +68,7 @@ public class TestPathTrie extends SolrTestCaseJ4 {
assertEquals("W", pathTrie.lookup("/aa/bb/somepart/tt/hello/world/from/solr", templateValues));
assertEquals(templateValues.get("*"), "/hello/world/from/solr");
- pathTrie.insert("/1/2/{x}/4", emptyMap(), "a");
+ pathTrie.insert("/1/2/{x}/4", Map.of(), "a");
assertEquals("a", pathTrie.lookup("/1/2/3/4", null));
templateValues.clear();
assertEquals("a", pathTrie.lookup("/1/2/3/4", templateValues));
diff --git a/solr/test-framework/src/java/org/apache/solr/handler/component/TrackingShardHandlerFactory.java b/solr/test-framework/src/java/org/apache/solr/handler/component/TrackingShardHandlerFactory.java
index cfafc590cd1..7dfd7ce9e18 100644
--- a/solr/test-framework/src/java/org/apache/solr/handler/component/TrackingShardHandlerFactory.java
+++ b/solr/test-framework/src/java/org/apache/solr/handler/component/TrackingShardHandlerFactory.java
@@ -18,7 +18,6 @@ package org.apache.solr.handler.component;
import java.util.ArrayDeque;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Queue;
@@ -277,7 +276,7 @@ public class TrackingShardHandlerFactory extends HttpShardHandlerFactory {
}
}
}
- return Collections.emptyList();
+ return List.of();
}
/**