isaric opened a new pull request, #5417: URL: https://github.com/apache/solr/pull/5417
https://issues.apache.org/jira/browse/SOLR-18612 Suggested by @dsmiley on #5407: a way to find code that still puts repeated keys into a `SimpleOrderedMap`, which renders as duplicate JSON properties and silently loses entries wherever the map is read as a map. # Description `SimpleOrderedMap.add` and `addAll(NamedList)` now throw `IllegalArgumentException` when the key is already present, if the system property `solr.simpleOrderedMap.assertUniqueKeys` (env var `SOLR_SIMPLEORDEREDMAP_ASSERTUNIQUEKEYS`) is true. It is false by default, so production and ordinary test runs are unchanged. `put` and `putAll` keep replacing values as before. The Gradle test setup registers the property as a test option whose default is the `tests.nightly` value, so nightly runs enforce unique keys across the whole suite and report the abusers one by one. The option is kept out of the reproduce line since it only mirrors `tests.nightly`. AI disclosure: drafted with Claude Code, reviewed by me. # Tests - `SimpleOrderedMapTest`: `add` of an existing key throws, `addAll` with a repeated key throws before adding anything, `put` still replaces, repeated keys are accepted with the flag off, and the flag follows `tests.nightly` (verified by running the test with and without `-Ptests.nightly=true`). - Full `:solr:solrj:test` with `-Ptests.nightly=true` (1371 tests) finds two producers of repeated keys, both in solr-core, neither fixed here: - `LukeRequestHandler.getAnalyzerInfo` keys an analyzer's token filters by class simple name, so a chain with two `StopFilterFactory` entries repeats the key (`admin/luke?show=schema`; every `SolrExample*Test.testLukeHandler` and `EmbeddedSolrServerTest.testLukeHandler`). The Admin UI's schema browser reads that `filters` object, so changing its shape needs care. - `CombinedQueryComponent.process` calls `doFieldSortValues` on each sub-query's response after `QueryComponent.process` has already added `sort_values` to it, so a combined shard request carries the key twice per sub-query (`JsonQueryRequestIntegrationTest.testMultipleQueriesCanUseLocalParamsSyntax`). The values are the same, so this is duplicated work and output rather than wrong results. Everything else in SolrJ passes with the assertion on. I'll file both as JIRA issues. # Checklist Please review the following and check all that apply: - [x] I have reviewed the guidelines for [How to Contribute](https://github.com/apache/solr/blob/main/CONTRIBUTING.md) and my code conforms to the standards described there to the best of my ability. - [x] I have created a Jira issue and added the issue ID to my pull request title. - [x] I have given Solr maintainers [access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork) to contribute to my PR branch. (optional but recommended, not available for branches on forks living under an organisation) - [x] I have developed this patch against the `main` branch. - [x] I have run `./gradlew check`. - [x] I have added tests for my changes. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
