Conversation
Migrate from deprecated java.util.Collections factory methods to modern Java collection literals (List.of and Map.of) throughout the codebase. - Replace Collections.singletonList(x) with List.of(x) - Replace Collections.singletonMap(k, v) with Map.of(k, v) - Remove static imports of Collections.singletonList/singletonMap - Remove unused import java.util.Collections; where applicable - Add import java.util.List; and import java.util.Map; where needed - Preserve Collections.singletonList/singletonMap with @SuppressForbidden annotation in the 6 known cases where null is passed as an argument (List.of/Map.of throw NullPointerException on null values) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
These processors may receive null field values from SolrInputField, so List.of() would throw NPE. Use Collections.singletonList() with @SuppressForbidden to preserve null-tolerant behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: epugh <22395+epugh@users.noreply.github.com>
|
I want to track this from copilot for potentially seperate PR's.. cause using nulls intentionally in these seems, well, suss... Preserved with @SuppressForbidden (8 locations, 7 files)
Also: ConfigSetAdminRequest.java: Has an inner static class List that shadows java.util.List, so used java.util.List.of(stream) with fully-qualified name |
…ct, Utils.java null sentinel, and Min/MaxFieldValue null safety Co-authored-by: epugh <22395+epugh@users.noreply.github.com>
|
Okay, I think this is ready for merging. |
dsmiley
left a comment
There was a problem hiding this comment.
ConfigSetAdminRequest.java: Has an inner static class List that shadows java.util.List, so used java.util.List.of(stream) with fully-qualified name
this PR doesn't touch that file
Yeah, this was a note that copilot highlighted, and I wanted to keep it to look into.. It turns out it makes sense it has a "List" named class.. I wasn't sure if there was soemthing in there to dig into it. At somepoint I want to go back and look at some of the places we are using "null" to see if they are the best way of doing things... I don't plan on making any changes to this PR more unless somethign comes up in review. |
I believe most Java projects should adopt JSpecify w/ Nullaway. This is the kind of work that I believe you love doing. Happy to chat with you about it sometime. |
Cool! Those are both new to me! |
|
@dsmiley do you think I should do the removal of |
|
Yes
…On Mon, Mar 23, 2026 at 12:08 PM Eric Pugh ***@***.***> wrote:
*epugh* left a comment (apache/solr#4222)
<#4222 (comment)>
@dsmiley <https://github.com/dsmiley> do you think I should do the
removal of Collections.singletonList and Collections.singletonMap in this
PR as well?
—
Reply to this email directly, view it on GitHub
<#4222?email_source=notifications&email_token=AAC4DT7N6J32XPYUXH526634SFOOTA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTIMJRGE3TQOBTG4Z2M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-4111788373>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAC4DT3WN4QXNGUAQI3AXAL4SFOOTAVCNFSM6AAAAACWUPRIUKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DCMJRG44DQMZXGM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Migrate from deprecated java.util.Collections factory methods to modern Java collection literals (List.of and Map.of) throughout the codebase. - Replace Collections.singletonList(x) with List.of(x) - Replace Collections.singletonMap(k, v) with Map.of(k, v) - Remove static imports of Collections.singletonList/singletonMap - Remove unused import java.util.Collections; where applicable - Add import java.util.List; and import java.util.Map; where needed - Preserve Collections.singletonList/singletonMap with @SuppressForbidden annotation in the 6 known cases where null is passed as an argument (List.of/Map.of throw NullPointerException on null values) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
These processors may receive null field values from SolrInputField, so List.of() would throw NPE. Use Collections.singletonList() with @SuppressForbidden to preserve null-tolerant behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: epugh <22395+epugh@users.noreply.github.com>
…ct, Utils.java null sentinel, and Min/MaxFieldValue null safety Co-authored-by: epugh <22395+epugh@users.noreply.github.com>
Co-authored-by: epugh <22395+epugh@users.noreply.github.com> Agent-Logs-Url: https://github.com/epugh/solr/sessions/e4901319-6f84-4e8a-ae44-3be009aa1e58
…Value is null Co-authored-by: epugh <22395+epugh@users.noreply.github.com> Agent-Logs-Url: https://github.com/epugh/solr/sessions/8c9bcae9-935a-4b71-820a-bec798eb710c
There was a problem hiding this comment.
Pull request overview
This PR continues the SOLR-18164 effort by removing usages of Collections.singleton*() / Collections.singleton() across Solr modules (tests + production code) and updates forbidden-apis rules to disallow these methods in favor of List.of(...), Set.of(...), and Map.of(...), with targeted @SuppressForbidden where null sentinels are intentional.
Changes:
- Replace
Collections.singleton*()calls withList.of(...)/Set.of(...)/Map.of(...)throughout the codebase. - Add/adjust
@SuppressForbiddenfor cases whereCollections.singleton*(null)is intentionally used as a sentinel. - Update forbidden-apis defaults to forbid
Collections.singleton*()/Collections.singleton().
Reviewed changes
Copilot reviewed 247 out of 247 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| solr/test-framework/src/test/org/apache/solr/client/solrj/apache/ConnectionReuseTest.java | Replace singletonList usage with List.of(...) in test client builder. |
| solr/test-framework/src/test/org/apache/solr/client/solrj/apache/CloudSolrClientTest.java | Replace singletonList usage with List.of(...) across CloudSolrClient tests. |
| solr/test-framework/src/test/org/apache/solr/client/solrj/apache/CloudSolrClientBuilderTest.java | Replace singletonList usage with List.of(...) in builder tests. |
| solr/test-framework/src/test/org/apache/solr/client/solrj/apache/BasicHttpSolrClientTest.java | Replace singletonList usage with List.of(...) in HTTP client tests. |
| solr/test-framework/src/java/org/apache/solr/util/SecurityJson.java | Replace singletonMap/singletonList with Map.of(...) / List.of(...) for test security JSON. |
| solr/test-framework/src/java/org/apache/solr/schema/SortableBinaryField.java | Replace singletonList with List.of(...) for field creation. |
| solr/test-framework/src/java/org/apache/solr/handler/component/DummyCustomParamSpellChecker.java | Replace singletonList with List.of(...) for spelling result values. |
| solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudAuthTestCase.java | Replace singletonList with List.of(...) for metrics key list. |
| solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java | Replace singletonList with List.of(...) in Solr client builder helpers. |
| solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java | Replace singletonMap/singletonList with Map.of(...) / List.of(...) in setup and client builder. |
| solr/test-framework/src/java/org/apache/solr/client/solrj/apache/HttpSolrClient.java | Replace singleton set with Set.of(...) for constant error codes. |
| solr/solrj/src/test/org/apache/solr/common/util/TestPathTrie.java | Replace singletonMap with Map.of(...) in trie test. |
| solr/solrj/src/test/org/apache/solr/common/cloud/PerReplicaStatesIntegrationTest.java | Replace singletonMap with Map.of(...) for modifyCollection properties. |
| solr/solrj/src/test/org/apache/solr/client/solrj/response/NestableJsonFacetTest.java | Replace singletonList with List.of(...) in facet parsing tests. |
| solr/solrj/src/test/org/apache/solr/client/solrj/request/SchemaTest.java | Replace singletonList with List.of(...) for analyzer component lists in tests. |
| solr/solrj/src/test/org/apache/solr/client/solrj/impl/SendUpdatesToLeadersOverrideTest.java | Replace singletonList with List.of(...) in SolrJ client builder tests. |
| solr/solrj/src/test/org/apache/solr/client/solrj/impl/LBAsyncSolrClientTest.java | Replace singletonMap with Map.of(...) in async response generator test. |
| solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientTestBase.java | Replace singletonList/singletonMap with List.of(...) / Map.of(...) for params and ids. |
| solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpJdkSolrClientTest.java | Replace singletonMap with Map.of(...) for query params in helper method. |
| solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpClusterStateSSLTest.java | Replace singletonList with List.of(...) in CloudSolrClient.Builder calls. |
| solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientCacheTest.java | Replace singletonMap/singletonList with Map.of(...) / List.of(...) in cache tests. |
| solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientRetryTest.java | Replace singletonList with List.of(...) for zk host list. |
| solr/solrj/src/java/org/apache/solr/common/util/Utils.java | Keep Collections.singletonList(null) sentinel path with @SuppressForbidden; remove static import. |
| solr/solrj/src/java/org/apache/solr/common/util/RetryUtil.java | Replace singleton set with Set.of(...) for retry exception class set. |
| solr/solrj/src/java/org/apache/solr/common/util/JsonSchemaValidator.java | Replace singleton set with Set.of(...) for required property subset validation. |
| solr/solrj/src/java/org/apache/solr/common/util/CommandOperation.java | Replace singletonList/singletonMap with List.of(...) / Map.of(...) in parsing/toString paths. |
| solr/solrj/src/java/org/apache/solr/common/cloud/ZkNodeProps.java | Replace singletonMap with Map.of(...) for plus(key,val) convenience. |
| solr/solrj/src/java/org/apache/solr/common/cloud/ImplicitDocRouter.java | Replace singleton slice collection with Set.of(...). |
| solr/solrj/src/java/org/apache/solr/common/cloud/HashBasedRouter.java | Replace singletonList with List.of(...) for single-slice result. |
| solr/solrj/src/java/org/apache/solr/common/cloud/CompositeIdRouter.java | Replace singletonList with List.of(...) in routing helpers. |
| solr/solrj/src/java/org/apache/solr/common/cloud/Aliases.java | Replace singletonList/singletonMap with List.of(...) / Map.of(...); preserve null semantics via LinkedHashMap where needed. |
| solr/solrj/src/java/org/apache/solr/common/SolrInputField.java | Replace singleton iterator with Set.of(value).iterator() for non-collection value. |
| solr/solrj/src/java/org/apache/solr/client/solrj/routing/NodePreferenceRulesComparator.java | Replace singletonList with List.of(...) for sysProps tag collection. |
| solr/solrj/src/java/org/apache/solr/client/solrj/request/ConfigSetAdminRequest.java | Replace singletonList with List.of(...) for single content stream. |
| solr/solrj/src/java/org/apache/solr/client/solrj/impl/DelegatingClusterStateProvider.java | Replace singletonList with List.of(...) when no delegate is set. |
| solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java | Replace singletonList with List.of(...) for resolveAliases input. |
| solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java | Replace singletonList with List.of(...) when coercing a scalar to list. |
| solr/solrj/src/java/org/apache/solr/client/solrj/SolrClient.java | Replace singletonList with List.of(...) in getById delegation. |
| solr/solrj/src/java/org/apache/solr/client/solrj/RemoteSolrException.java | Replace singletonList with List.of(...) for metadata path extraction. |
| solr/solrj-zookeeper/src/test/org/apache/solr/common/cloud/SolrZkClientTest.java | Replace singletonList with List.of(...) for zk host list and auth info list. |
| solr/solrj-zookeeper/src/test/org/apache/solr/client/solrj/impl/NodeValueFetcherTest.java | Replace singletonList with List.of(...) for zk host list. |
| solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ZkStateReader.java | Replace singleton set with Set.of(...) when constructing state for one collection. |
| solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/PerReplicaStatesOps.java | Replace singletonList with List.of(...) for a single operation. |
| solr/modules/ltr/src/test/org/apache/solr/ltr/model/TestWrapperModel.java | Replace singletonList with List.of(...) in wrapper model test setup. |
| solr/modules/ltr/src/java/org/apache/solr/ltr/feature/FieldValueFeature.java | Replace singleton set with Set.of(...) for fieldAsSet. |
| solr/modules/jwt-auth/src/test/org/apache/solr/security/jwt/JWTAuthPluginTest.java | Replace singletonList with List.of(...) for issuers config. |
| solr/modules/jwt-auth/src/java/org/apache/solr/security/jwt/JWTIssuerConfig.java | Replace singletonList with List.of(...) for jwksUrl default / string coercion. |
| solr/modules/jwt-auth/src/java/org/apache/solr/security/jwt/JWTAuthPlugin.java | Replace singletonList with List.of(...) for redirectUris string coercion. |
| solr/modules/clustering/src/java/org/apache/solr/handler/clustering/ClusteringComponent.java | Replace singletonList with List.of(...) for “Other topics” label. |
| solr/modules/analysis-extras/src/java/org/apache/solr/update/processor/OpenNLPExtractNamedEntitiesUpdateProcessorFactory.java | Replace singletonList with List.of(...) for regex inclusion list. |
| solr/modules/analysis-extras/src/java/org/apache/solr/update/processor/DocumentCategorizerUpdateProcessorFactory.java | Replace singletonList with List.of(...) for regex inclusion list. |
| solr/modules/analysis-extras/src/java/org/apache/solr/schema/ICUCollationField.java | Replace singletonList with List.of(...) for field creation. |
| solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/consumer/PartitionManagerTest.java | Replace singletonMap with Map.of(...) for Kafka commitSync expectations. |
| solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/consumer/KafkaCrossDcConsumerTest.java | Replace singletonMap with Map.of(...) for ConsumerRecords creation. |
| solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/consumer/PartitionManager.java | Replace singletonMap with Map.of(...) for commitSync payload. |
| solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/consumer/KafkaCrossDcConsumer.java | Replace singletonList with List.of(...) for CloudSolrClient.Builder args. |
| solr/core/src/test/org/apache/solr/util/TestUtils.java | Replace singletonList/singleton set with List.of(...) / Set.of(...) for command parsing. |
| solr/core/src/test/org/apache/solr/util/SolrPluginUtilsTest.java | Replace singleton collection with Set.of(...) in DisjunctionMaxQuery. |
| solr/core/src/test/org/apache/solr/update/processor/TimeRoutedAliasUpdateProcessorTest.java | Replace singletonList with List.of(...) in update helper calls. |
| solr/core/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java | Replace singletonList with List.of(...) for content streams. |
| solr/core/src/test/org/apache/solr/update/processor/AddSchemaFieldsUpdateProcessorFactoryTest.java | Replace singleton sets with Set.of(...) in schema copy field property queries. |
| solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesStandalone.java | Replace singletonList with List.of(...) when building a mutable list wrapper. |
| solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesDistrib.java | Replace singletonList with List.of(...) in buildRandomIndex callsites. |
| solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.java | Replace singletonList with List.of(...) for node list. |
| solr/core/src/test/org/apache/solr/update/PeerSyncTest.java | Replace singletonList with List.of(...) for version lists. |
| solr/core/src/test/org/apache/solr/update/DeleteByIdWithRouterFieldTest.java | Replace singletonList with List.of(...) in map collector. |
| solr/core/src/test/org/apache/solr/update/AddBlockUpdateTest.java | Replace singleton with Set.of(...) for nested doc container. |
| solr/core/src/test/org/apache/solr/uninverting/TestUninvertingReader.java | Replace singletonMap with Map.of(...) for UninvertingReader config. |
| solr/core/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java | Replace singletonList with List.of(...) for tokens. |
| solr/core/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java | Replace singletonList with List.of(...) for tokens. |
| solr/core/src/test/org/apache/solr/spelling/DirectSolrSpellCheckerTest.java | Replace singletonList with List.of(...) for tokens. |
| solr/core/src/test/org/apache/solr/security/TestSha256AuthenticationProvider.java | Replace singletonMap/singletonList with Map.of(...) / List.of(...) for command ops. |
| solr/core/src/test/org/apache/solr/security/TestExternalRoleRuleBasedAuthorizationPlugin.java | Replace singleton role set with Set.of(...). |
| solr/core/src/test/org/apache/solr/security/PKIAuthenticationIntegrationTest.java | Replace singletonMap with Map.of(...) for authz/authn JSON. |
| solr/core/src/test/org/apache/solr/security/BasicAuthStandaloneTest.java | Replace singletonMap with Map.of(...) for query params. |
| solr/core/src/test/org/apache/solr/security/BasicAuthIntegrationTest.java | Replace singletonMap with Map.of(...) for security API payloads and query params. |
| solr/core/src/test/org/apache/solr/security/AuditLoggerPluginTest.java | Replace singleton structures with Map.of(...) / List.of(...) for test events/config. |
| solr/core/src/test/org/apache/solr/security/AuditLoggerIntegrationTest.java | Replace singletonMap with Map.of(...) for malformed query params. |
| solr/core/src/test/org/apache/solr/search/similarities/TestSweetSpotSimilarityFactory.java | Replace singleton document collection with Set.of(...). |
| solr/core/src/test/org/apache/solr/search/join/ShardToShardJoinAbstract.java | Replace singletonMap with Map.of(...) for plugin payload. |
| solr/core/src/test/org/apache/solr/search/facet/TestJsonFacets.java | Replace singleton iterable/list returns with Set.of(...) / List.of(...). |
| solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKGEquiv.java | Replace singletonMap with Map.of(...) for unordered buckets compare hint. |
| solr/core/src/test/org/apache/solr/search/facet/RangeFacetCloudTest.java | Replace singletonMap with Map.of(...) for collection properties. |
| solr/core/src/test/org/apache/solr/search/TestThinCache.java | Replace singletonMap with Map.of(...) for cache init parameters. |
| solr/core/src/test/org/apache/solr/search/TestSolr4Spatial2.java | Replace singletonList with List.of(...) for index values. |
| solr/core/src/test/org/apache/solr/search/TestRandomCollapseQParserPlugin.java | Replace singletonList with List.of(...) in debug assertions. |
| solr/core/src/test/org/apache/solr/search/TestMaxScoreQueryParser.java | Replace singletonMap with Map.of(...) for df param map. |
| solr/core/src/test/org/apache/solr/search/LargeFieldTest.java | Replace singletonList with List.of(...) when adding field types. |
| solr/core/src/test/org/apache/solr/search/CurrencyRangeFacetCloudTest.java | Replace singletonMap with Map.of(...) for collection properties. |
| solr/core/src/test/org/apache/solr/response/transform/TestSubQueryTransformerDistrib.java | Replace singletonMap/singletonList with Map.of(...) / List.of(...) for security JSON. |
| solr/core/src/test/org/apache/solr/response/TestRetrieveFieldsOptimizer.java | Replace singletonList with List.of(...) for expected vals map entries. |
| solr/core/src/test/org/apache/solr/response/TestPushWriter.java | Replace singletonMap with Map.of(...) in writer output test. |
| solr/core/src/test/org/apache/solr/request/macro/TestMacroExpander.java | Replace singletonMap with Map.of(...) for request map. |
| solr/core/src/test/org/apache/solr/packagemanager/TestPackageManager.java | Replace singletonList with List.of(...) for plugin list and collection list. |
| solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java | Replace singletonList with List.of(...) for payload list and component list. |
| solr/core/src/test/org/apache/solr/handler/tagger/XmlInterpolationTest.java | Replace singleton set with Set.of(...) for HTMLStripCharFilter escaped tags. |
| solr/core/src/test/org/apache/solr/handler/tagger/TaggerTestCase.java | Replace singleton iterable with Set.of(...) for request content stream. |
| solr/core/src/test/org/apache/solr/handler/tagger/EmbeddedSolrNoSerializeTest.java | Replace singleton collection with Set.of(...) for content stream. |
| solr/core/src/test/org/apache/solr/handler/designer/TestSchemaDesignerSettingsDAO.java | Replace singletonList with List.of(...) for languages. |
| solr/core/src/test/org/apache/solr/handler/designer/ManagedSchemaDiffTest.java | Replace singletonList with List.of(...) in diff assertions. |
| solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java | Replace singletonList with List.of(...) for expected xpath lists. |
| solr/core/src/test/org/apache/solr/handler/component/ParallelHttpShardHandlerTest.java | Replace singletonList with List.of(...) for LB request endpoints. |
| solr/core/src/test/org/apache/solr/handler/admin/ZookeeperStatusHandlerTest.java | Replace singletonList with List.of(...) in validation tests. |
| solr/core/src/test/org/apache/solr/handler/admin/TestApiFramework.java | Replace singletonList with List.of(...) for content streams in test request. |
| solr/core/src/test/org/apache/solr/handler/admin/AdminHandlersProxyTest.java | Replace singletonMap with Map.of(...) for request params. |
| solr/core/src/test/org/apache/solr/handler/DocumentAnalysisRequestHandlerTest.java | Replace singleton content stream iterable with Set.of(...). |
| solr/core/src/test/org/apache/solr/filestore/TestDistribFileStore.java | Add @SuppressForbidden for intentional singletonMap-with-null case. |
| solr/core/src/test/org/apache/solr/core/TestInitParams.java | Replace singletonMap with Map.of(...) in PluginInfo construction and matchPath tests. |
| solr/core/src/test/org/apache/solr/core/TestConfigSetService.java | Replace singletonMap with Map.of(...) for metadata set. |
| solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.java | Replace singletonList with List.of(...) for jar URLs. |
| solr/core/src/test/org/apache/solr/core/DirectoryFactoriesTest.java | Replace singleton set with Set.of(...) for sync filename. |
| solr/core/src/test/org/apache/solr/core/CoreSorterTest.java | Replace singletonList/singletonMap with List.of(...) / Map.of(...) in replica creation and collection props. |
| solr/core/src/test/org/apache/solr/cluster/placement/plugins/SimplePlacementFactoryTest.java | Replace singleton shard set with Set.of(...). |
| solr/core/src/test/org/apache/solr/cluster/placement/impl/PlacementPluginIntegrationTest.java | Replace singletonMap with Map.of(...) for plugin API payloads. |
| solr/core/src/test/org/apache/solr/cluster/maintenance/InactiveShardRemoverTest.java | Replace singletonMap with Map.of(...) for plugin add/remove payloads. |
| solr/core/src/test/org/apache/solr/cluster/events/impl/CollectionsRepairEventListenerTest.java | Replace singletonMap with Map.of(...) for plugin add payload. |
| solr/core/src/test/org/apache/solr/cluster/events/ClusterEventProducerTest.java | Replace singletonMap with Map.of(...) for plugin add/remove payloads. |
| solr/core/src/test/org/apache/solr/cloud/overseer/TestClusterStateMutator.java | Replace singletonMap with Map.of(...) for ClusterState construction. |
| solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionsAPIViaSolrCloudCluster.java | Replace singletonMap with Map.of(...) for collectionProperties constant. |
| solr/core/src/test/org/apache/solr/cloud/api/collections/ShardSplitTest.java | Replace singletonList with List.of(...) for zk host list. |
| solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java | Replace singletonList with List.of(...) for descriptor list. |
| solr/core/src/test/org/apache/solr/cloud/TestStressCloudBlindAtomicUpdates.java | Replace singletonMap with Map.of(...) for atomic update inc map. |
| solr/core/src/test/org/apache/solr/cloud/TestHashPartitioner.java | Replace singletonMap with Map.of(...) for collection props. |
| solr/core/src/test/org/apache/solr/cloud/ShardTermsTest.java | Replace singleton sets with Set.of(...) in term updates. |
| solr/core/src/test/org/apache/solr/cloud/ReindexCollectionTest.java | Replace singletonList with List.of(...) for zk host list. |
| solr/core/src/test/org/apache/solr/cloud/PeerSyncReplicationTest.java | Replace singletonList with List.of(...) in node failure helpers. |
| solr/core/src/test/org/apache/solr/cloud/OverseerModifyCollectionTest.java | Replace singletonMap with Map.of(...) in modifyCollection calls. |
| solr/core/src/test/org/apache/solr/cloud/MoveReplicaTest.java | Replace singleton node sets with Set.of(...) in replica activity checks. |
| solr/core/src/test/org/apache/solr/cloud/LeaderFailureAfterFreshStartTest.java | Replace singletonList with List.of(...) in node failure/restart helpers. |
| solr/core/src/test/org/apache/solr/cloud/LeaderFailoverAfterPartitionTest.java | Replace singletonList with List.of(...) for docs list in retry sender. |
| solr/core/src/test/org/apache/solr/cloud/ForceLeaderTest.java | Replace singletonList with List.of(...) for client builder and doc sending. |
| solr/core/src/test/org/apache/solr/cloud/DistributedVersionInfoTest.java | Replace singletonList with List.of(...) in doc send helper. |
| solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java | Replace singletonMap with Map.of(...) in modifyCollection calls. |
| solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java | Replace singletonList with List.of(...) for zk host list in clients. |
| solr/core/src/test/org/apache/solr/api/NodeConfigClusterPluginsSourceTest.java | Replace singletonMap with Map.of(...) for payload in v2 request. |
| solr/core/src/test/org/apache/solr/TestSimpleTrackingShardHandler.java | Replace singletonList with List.of(...) in tracking queue setup/cleanup. |
| solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java | Replace singletonList with List.of(...) for single paramSet name case. |
| solr/core/src/java/org/apache/solr/update/processor/RoutedAliasUpdateProcessor.java | Replace singletonList with List.of(...) when distributing add to leader. |
| solr/core/src/java/org/apache/solr/update/processor/ParseBooleanFieldUpdateProcessorFactory.java | Replace singleton sets with Set.of(...) for default true/false values. |
| solr/core/src/java/org/apache/solr/update/processor/MinFieldValueUpdateProcessorFactory.java | Add @SuppressForbidden for intentional singletonList null semantics. |
| solr/core/src/java/org/apache/solr/update/processor/MaxFieldValueUpdateProcessorFactory.java | Add @SuppressForbidden for intentional singletonList null semantics. |
| solr/core/src/java/org/apache/solr/update/processor/LastFieldValueUpdateProcessorFactory.java | Add @SuppressForbidden for intentional singletonList null semantics. |
| solr/core/src/java/org/apache/solr/update/processor/FirstFieldValueUpdateProcessorFactory.java | Add @SuppressForbidden for intentional singletonList null semantics. |
| solr/core/src/java/org/apache/solr/update/processor/DistributedZkUpdateProcessor.java | Replace singletonList with List.of(...) in leader forwarding setup. |
| solr/core/src/java/org/apache/solr/update/processor/CloneFieldUpdateProcessorFactory.java | Replace singletonList with List.of(...) for regex inclusion list. |
| solr/core/src/java/org/apache/solr/update/processor/AtomicUpdateProcessorFactory.java | Replace singletonMap with Map.of(...) for atomic update field operation map. |
| solr/core/src/java/org/apache/solr/update/processor/AtomicUpdateDocumentMerger.java | Replace singletonList with List.of(...) for child doc list coercion. |
| solr/core/src/java/org/apache/solr/update/UpdateLog.java | Replace singletonList with List.of(...) for LogReplayer inputs. |
| solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java | Replace singleton iterable with Set.of(...) for single Lucene doc case. |
| solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java | Replace singletonList with List.of(...) in equality check for core collection. |
| solr/core/src/java/org/apache/solr/security/cert/PathBasedCertPrincipalResolver.java | Replace singletonList with List.of(...) for pattern list input. |
| solr/core/src/java/org/apache/solr/security/Sha256AuthenticationProvider.java | Replace singletonMap with Map.of(...) for promptHeader creation. |
| solr/core/src/java/org/apache/solr/security/RuleBasedAuthorizationPluginBase.java | Add @SuppressForbidden for intentional singletonList(null) sentinel mapping logic. |
| solr/core/src/java/org/apache/solr/security/PermissionNameProvider.java | Replace values map construction; add @SuppressForbidden for singleton(null) usage in enum ctor. |
| solr/core/src/java/org/apache/solr/security/Permission.java | Replace singletonList with List.of(...); keep singleton(null) sentinel with @SuppressForbidden. |
| solr/core/src/java/org/apache/solr/security/MultiAuthRuleBasedAuthorizationPlugin.java | Replace singletonList with List.of(...) when delegating permission edit. |
| solr/core/src/java/org/apache/solr/security/MultiAuthPlugin.java | Replace singletonList with List.of(...) when delegating scheme plugin edit. |
| solr/core/src/java/org/apache/solr/security/AuditLoggerPlugin.java | Replace singletonList with List.of(...) for mute rule parsing. |
| solr/core/src/java/org/apache/solr/security/AuditEvent.java | Replace singletonList with List.of(...) for regex lists. |
| solr/core/src/java/org/apache/solr/search/mlt/MLTContentQParserPlugin.java | Replace singleton collection with Set.of(...) for multifield doc stream value. |
| solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/TopGroupsResultTransformer.java | Replace singleton field set with Set.of(...) for doc fetch. |
| solr/core/src/java/org/apache/solr/search/ValueSourceParser.java | Replace singletonList with List.of(...) when building vector sources. |
| solr/core/src/java/org/apache/solr/search/NumericHidingLeafReader.java | Replace singletonMap with Map.of(...) for uninverting config. |
| solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java | Replace singletonMap with Map.of(...) for uninverting config mapping. |
| solr/core/src/java/org/apache/solr/search/CacheConfig.java | Replace singletonMap with Map.of(...) for PluginInfo attributes. |
| solr/core/src/java/org/apache/solr/schema/TrieField.java | Replace singletonList with List.of(...) for field creation. |
| solr/core/src/java/org/apache/solr/schema/StrField.java | Replace singletonList with List.of(...) for created fields. |
| solr/core/src/java/org/apache/solr/schema/SortableTextField.java | Replace singletonList with List.of(...) for fields/docvalues creation. |
| solr/core/src/java/org/apache/solr/schema/IndexSchema.java | Replace singletonList/singletonMap with List.of(...) / Map.of(...) for addField overloads. |
| solr/core/src/java/org/apache/solr/schema/FieldType.java | Replace singletonList with List.of(...) for docvalues field list. |
| solr/core/src/java/org/apache/solr/schema/CollationField.java | Replace singletonList with List.of(...) for field creation. |
| solr/core/src/java/org/apache/solr/schema/BoolField.java | Replace singletonList with List.of(...) for created fields. |
| solr/core/src/java/org/apache/solr/schema/BinaryField.java | Replace singletonList with List.of(...) for created fields. |
| solr/core/src/java/org/apache/solr/response/transform/RawValueTransformerFactory.java | Replace singleton collection with Set.of(...) for raw field set. |
| solr/core/src/java/org/apache/solr/response/TextResponseWriter.java | Replace singleton set with Set.of(...) when rawFields size is 1. |
| solr/core/src/java/org/apache/solr/pkg/SolrPackageLoader.java | Replace singletonList with List.of(...) for notifying listeners. |
| solr/core/src/java/org/apache/solr/pkg/PackagePluginHolder.java | Replace singletonMap with Map.of(...) in packageDetails and PluginInfo. |
| solr/core/src/java/org/apache/solr/pkg/PackageAPI.java | Replace singletonMap with Map.of(...) when returning one package result. |
| solr/core/src/java/org/apache/solr/parser/SolrQueryParserBase.java | Replace singletonList with List.of(...) in RawQuery constructor. |
| solr/core/src/java/org/apache/solr/packagemanager/PackageManager.java | Replace singletonMap with Map.of(...) for uninstall and deploy payload composition. |
| solr/core/src/java/org/apache/solr/handler/export/ExportWriter.java | Replace singletonMap/singletonList with Map.of(...) / List.of(...) in error responses and headers. |
| solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java | Replace singletonList with List.of(...) for single dest field. |
| solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerAPI.java | Replace singletonMap with Map.of(...) for response values. |
| solr/core/src/java/org/apache/solr/handler/designer/DefaultSampleDocumentsLoader.java | Replace singletonList with List.of(...) for single JSON doc case. |
| solr/core/src/java/org/apache/solr/handler/component/ResponseLogComponent.java | Replace singleton set with Set.of(...) for uniqueKey field set. |
| solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java | Replace singleton set with Set.of(...) for decorateDocValueFields. |
| solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java | Replace singleton collections with Set.of(...) / List.of(...) for elevation IDs. |
| solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandlerZk.java | Replace singletonList with List.of(...) for ERR_MSGS list. |
| solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandlerLocal.java | Replace singletonList with List.of(...) for ERR_MSGS list. |
| solr/core/src/java/org/apache/solr/handler/admin/ColStatus.java | Replace singleton collection with Set.of(...) for single collection name case. |
| solr/core/src/java/org/apache/solr/handler/admin/BaseHandlerApiSupport.java | Replace singletonList/singletonMap with List.of(...) / Map.of(...) in GET and param wrapping. |
| solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java | Replace singletonList with List.of(...) for ERR_MSGS response list. |
| solr/core/src/java/org/apache/solr/handler/SchemaHandler.java | Replace singletonMap with Map.of(...); add guard for null pathParam. |
| solr/core/src/java/org/apache/solr/handler/RequestHandlerBase.java | Replace singleton with Set.of(...) for single Api wrapper collection. |
| solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java | Replace singleton collection with Set.of(...) for multifield doc stream value. |
| solr/core/src/java/org/apache/solr/handler/IndexFetcher.java | Replace singletonList with List.of(...) for allow-list check; replace singleton filename collection with Set.of(...) for sync. |
| solr/core/src/java/org/apache/solr/handler/ClusterAPI.java | Replace nested singletonMap with Map.of(...) for node-roles response shape. |
| solr/core/src/java/org/apache/solr/filestore/ClusterFileStore.java | Add @SuppressForbidden for intentional singletonMap null usage; replace singletonMap with Map.of(...) where safe. |
| solr/core/src/java/org/apache/solr/core/snapshots/SolrSnapshotMetaDataManager.java | Replace singletonList with List.of(...) for sync filename. |
| solr/core/src/java/org/apache/solr/core/backup/ShardBackupMetadata.java | Replace singleton filename set with Set.of(...) for repository delete. |
| solr/core/src/java/org/apache/solr/core/backup/BackupManager.java | Replace singletonMap with Map.of(...) when writing collection state JSON. |
| solr/core/src/java/org/apache/solr/core/SolrPaths.java | Replace Collections.singleton with Set.of(...) for ALL_PATHS constant. |
| solr/core/src/java/org/apache/solr/core/SolrCore.java | Replace singleton set with Set.of(...) for sync; replace singleton list with List.of(...) for default processor chain. |
| solr/core/src/java/org/apache/solr/core/RequestParams.java | Replace singletonMap with Map.of(...) for meta version merge. |
| solr/core/src/java/org/apache/solr/core/PluginBag.java | Replace singletonMap with Map.of(...) for handler name substitutes and PluginInfo attrs. |
| solr/core/src/java/org/apache/solr/core/MetricsConfig.java | Replace singletonMap with Map.of(...) for NO_OP PluginInfo. |
| solr/core/src/java/org/apache/solr/cluster/placement/PlacementPlugin.java | Replace singletonList with List.of(...) when delegating to computePlacements. |
| solr/core/src/java/org/apache/solr/cluster/events/impl/CollectionsRepairEventListener.java | Replace singletonList with List.of(...) for shard list in assign request builder. |
| solr/core/src/java/org/apache/solr/cloud/overseer/ZkStateWriter.java | Replace singletonMap with Map.of(...) for state.json serialization. |
| solr/core/src/java/org/apache/solr/cloud/api/collections/TimeRoutedAlias.java | Replace singletonList with List.of(...) when returning single action. |
| solr/core/src/java/org/apache/solr/cloud/api/collections/ReplicaMigrationUtils.java | Replace singletonList with List.of(...) for core name watcher list. |
| solr/core/src/java/org/apache/solr/cloud/api/collections/ReplaceNodeCmd.java | Replace singletonList with List.of(...) for shard list. |
| solr/core/src/java/org/apache/solr/cloud/api/collections/MoveReplicaCmd.java | Replace singletonList with List.of(...) for watcher core list. |
| solr/core/src/java/org/apache/solr/cloud/api/collections/MigrateReplicasCmd.java | Replace singletonList with List.of(...) for shard list. |
| solr/core/src/java/org/apache/solr/cloud/api/collections/DeleteCollectionCmd.java | Replace singleton exception set with Set.of(...). |
| solr/core/src/java/org/apache/solr/cloud/api/collections/DeleteBackupCmd.java | Replace singleton set with Set.of(...) for deleteBackupIds input. |
| solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java | Replace singletonMap with Map.of(...) for PRS state.json writes. |
| solr/core/src/java/org/apache/solr/cloud/api/collections/CreateAliasCmd.java | Replace singletonList with List.of(...) for validation input. |
| solr/core/src/java/org/apache/solr/cloud/api/collections/CollectionHandlingUtils.java | Replace singleton set with Set.of(...) for backup cleanup. |
| solr/core/src/java/org/apache/solr/cloud/api/collections/Assign.java | Replace singletonList with List.of(...) for shard list. |
| solr/core/src/java/org/apache/solr/cloud/api/collections/AddReplicaCmd.java | Replace singleton set with Set.of(...) for per-replica states ops lookup. |
| solr/core/src/java/org/apache/solr/cloud/DistributedClusterStateUpdater.java | Replace singletonMap with Map.of(...) for state.json; replace singletonList with List.of(...) for replicaOps list. |
| solr/core/src/java/org/apache/solr/cli/RunExampleTool.java | Replace singletonList with List.of(...) for zk host list in client. |
| solr/core/src/java/org/apache/solr/cli/ExportTool.java | Replace singletonList with List.of(...) for baseurl list in CloudSolrClient.Builder. |
| solr/core/src/java/org/apache/solr/cli/CLIUtils.java | Replace singletonList with List.of(...) for zkHost list in client builder. |
| solr/core/src/java/org/apache/solr/api/ApiBag.java | Replace singletonMap/singletonList with Map.of(...) / List.of(...); replace singleton stream set with Set.of(...). |
| solr/core/src/java/org/apache/solr/api/AnnotatedApi.java | Replace singletonList/singletonMap with List.of(...) / Map.of(...) in API construction and error capture. |
| solr/benchmark/src/test/org/apache/solr/bench/SolrBenchStateTest.java | Replace singleton lists with List.of(...) in benchmark state test. |
| solr/benchmark/src/java/org/apache/solr/bench/generators/Maps.java | Replace singletonMap with Map.of(...) for generating a Map.Entry. |
| gradle/validation/forbidden-apis/defaults.all.txt | Add forbidden-apis rules for Collections.singleton*() / Collections.singleton() with suggested replacements. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| final Map<String, String> pathValues = req.getPathTemplateValues(); | ||
| final Map<String, Object> map = | ||
| co == null || !(co.getCommandData() instanceof Map) | ||
| ? Collections.singletonMap("", co.getCommandData()) | ||
| ? Map.of("", co.getCommandData()) | ||
| : co.getDataMap(); |
There was a problem hiding this comment.
wrapParams now wraps non-map command data using Map.of("", co.getCommandData()). Map.of rejects null values, but CommandOperation can legitimately have commandData == null (e.g., commands with no payload / explicit JSON null), which would throw NPE here and break the API. Consider using a mutable map (e.g., new HashMap<>(1) + put) or another construction that permits a null value for this sentinel entry.
| protected void writeException(Exception e, PushWriter w, boolean logException) | ||
| throws IOException { | ||
| w.writeMap( | ||
| mw -> { | ||
| mw.put("responseHeader", singletonMap("status", 400)) | ||
| mw.put("responseHeader", Map.of("status", 400)) | ||
| .put( | ||
| "response", | ||
| Map.of( | ||
| "numFound", | ||
| 0, | ||
| "docs", | ||
| singletonList(singletonMap("EXCEPTION", e.getMessage())))); | ||
| Map.of("numFound", 0, "docs", List.of(Map.of("EXCEPTION", e.getMessage())))); | ||
| }); |
There was a problem hiding this comment.
writeException builds the error response using Map.of("EXCEPTION", e.getMessage()). Map.of does not permit null values, but many exceptions can have a null message; that would cause a secondary NPE while trying to report the original error. Consider coercing the message to a non-null string (e.g., Objects.toString(e.getMessage(), "")) or using a map implementation that allows null values for this field.
https://issues.apache.org/jira/browse/SOLR-18164
Description
Originally part of https://github.com/apache/solr/pull/4168/commits, this is to remove
.singletonusage.Solution
manual! can't quite get INtellij to do it for me for the Set version, but then leaned on copilot for the List and Map versions.
Tests
Ran unit and bats tests.