isaric opened a new pull request, #5267: URL: https://github.com/apache/solr/pull/5267
https://issues.apache.org/jira/browse/SOLR-18603 # Description Step 4 of [SIP-22: NamedList Reduction](https://cwiki.apache.org/confluence/spaces/SOLR/pages/340036504/SIP-22+NamedList+Reduction): use Java 17 sealed classes so that the `NamedList` type hierarchy is exactly what we want. Agreed as the next step on the dev list ([thread](https://lists.apache.org/thread/2o09q8yjmsx4l9b58mqqk5mgdbv7qf36)). `NamedList` is now `sealed`, permitting only `SimpleOrderedMap`, which is `final`. No public method signatures change. # Solution An audit of `main` found three subclasses of `NamedList`, not one: 1. `SimpleOrderedMap` – expected. 2. `CloudSolrClient.RouteResponse` – a public nested class returned by `CloudSolrClient.request()` for routed updates, carrying the per-route responses so that `getShardReplicationFactor()` could read each shard's achieved replication factor. SolrJ has no `module-info.java`, so a permitted subclass must live in `NamedList`'s package, which rules out keeping it as a subclass. As agreed on the Jira, it is removed: `condenseResponse` now records each route's `rf` in the merged `responseHeader` under `rfByRoute` (`CloudSolrClient.REPFACT_BY_ROUTE`), next to the existing minimum `rf` and in the same way the tolerant-update `errors` are merged, and `getShardReplicationFactor()` reads that entry instead of casting. Its signature and result are unchanged; `getMinAchievedReplicationFactor()` is untouched. `condenseResponse(NamedList, int)` now returns `SimpleOrderedMap<Object>`, and the protected `Supplier` overload is gone (nothing overrode it). 3. Twelve anonymous subclasses in `NestableJsonFacetTest` (double-brace initialisation), rewritten to plain `add()` calls. One further consequence of sealing: a cast from a `NamedList`-typed expression to `List` is now a compile error, since no permitted subtype implements `List`. One test (`DistributedFacetSimpleRefinementLongTailTest`) did that on a value that was never a `NamedList`; the containing map is now typed `NamedList<Object>`. Sealing a public SolrJ class is a plugin-compatibility change: third-party subclasses of `NamedList` or `SimpleOrderedMap` will no longer compile. This is `main` / 11.0 only, with a changelog entry and an upgrade note in `major-changes-in-solr-11.adoc` that also documents `rfByRoute`. AI disclosure: the audit, code changes, changelog/doc text and this description were drafted with Claude Code and reviewed by me. # Tests No new test classes; the compiler enforces the hierarchy. `CloudHttp2SolrClientTest.testRouting` previously inspected `RouteResponse.getRoutes()`; it now checks each document on the leader of the shard `DocRouter` routes it to, and `checkSingleServer` asserts that every route URL in `rfByRoute` is a shard leader (and that the entry is present). Ran: - `./gradlew tidy` – applied. - `./gradlew check -x test` – passes across all modules, so nothing else in the repo subclasses `NamedList`. The Antora ref-guide site task could not fetch its UI bundle in my environment; I built the ref-guide separately with a local bundle to confirm the upgrade-note page renders with no warnings. - `./gradlew :solr:solrj:test --tests NestableJsonFacetTest --tests CloudHttp2SolrClientTest` – both pass. # 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`. - [ ] I have added tests for my changes. - [x] I have added documentation for the [Reference Guide](https://github.com/apache/solr/tree/main/solr/solr-ref-guide) - [x] I have added a [changelog entry](https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc) for my change -- 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]
