Repository navigation
Conversation
NamedList is now sealed, permitting only SimpleOrderedMap (non-sealed). CloudSolrClient.RouteResponse extends SimpleOrderedMap instead of NamedList, since it cannot be permitted from another package without a module-info. NestableJsonFacetTest no longer uses anonymous NamedList subclasses. Adds a changelog entry and an 11.0 upgrade note. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XL2ChskWQPpS1niMQgCaQa
Per review: SimpleOrderedMap is final rather than non-sealed. CloudSolrClient.RouteResponse is removed; a routed update returns the condensed SimpleOrderedMap, whose responseHeader now carries each route's achieved replication factor under "rfByRoute", and getShardReplicationFactor reads that instead of casting. Tests verify routing via DocRouter and the new header entry. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XL2ChskWQPpS1niMQgCaQa
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XL2ChskWQPpS1niMQgCaQa
A cast from a NamedList-typed expression to List is a compile error now that the hierarchy is sealed and no subtype implements List; the value there was never a NamedList, so type the containing map as NamedList<Object>. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XL2ChskWQPpS1niMQgCaQa
| String coreUrl = | ||
| col.getRouter().getTargetSlice(id, null, null, null, col).getLeader().getCoreUrl(); | ||
| SolrClient solrClient = | ||
| new CollectionScopedSolrClient( |
There was a problem hiding this comment.
no point in using CollectionScopedSolrClient when in the next line you could pass the extracted core name to the 1st arg of the process method.
| NamedList<Object> list = new NamedList<>(); | ||
| list.add("count", count); | ||
| return list; | ||
| } |
There was a problem hiding this comment.
the method name confused me as to what it does. Note this could simply call SimpleOrderedMap.of("count", count) and you could inline that trivial thing, dropping the method.
| list.clear(); | ||
|
|
||
| list.add("count", 12L); | ||
| buckets = |
There was a problem hiding this comment.
It's pleasantly ironic to see that a short-cut trick/hack somebody did to try to be concise ended up being much more verbose than what we're coming up with now.
There was a problem hiding this comment.
I love that the changes here are simpler than before :-)
I suppose a side-effect of this change is that if someone were to serialize the response NamedList, they'd see information in the responseHeader that previously wasn't there. But so what.
Query the leader core via process(client, core) instead of wrapping it
in a CollectionScopedSolrClient, and inline SimpleOrderedMap.of("count",
...) in NestableJsonFacetTest instead of a helper.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XL2ChskWQPpS1niMQgCaQa
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XL2ChskWQPpS1niMQgCaQa
|
🤖 AI text below 🤖 (reviewed by Nick Shanin) Hi @isaric, I have a tested follow-up that adds missing coverage for the per-shard replication-factor API: diff. The current tests exercise the minimum factor, but nothing pins the full shard-to-factor map the API returns, so a regression that returned the same factor for every shard would pass unnoticed. It adds the missing tests to Verification on Linux at `b244ae94d6` (JDK 21.0.12.1, Gradle 9.7.0, seed `18603C0DE`)
The commits are a fast-forward of your current PR head: git switch SOLR-18603-seal-namedlist
git fetch https://github.com/nick-boss-tech/solr.git solr-18603-submit
git merge --ff-only b244ae94d6c84eec06bf1de5754e566b0fdb88d1You're welcome to take the commits or adapt the changes. If you would rather I open it as a separate PR after this one merges, I can do that instead. Separately, the Crave failure in |
https://issues.apache.org/jira/browse/SOLR-18603
Description
Step 4 of SIP-22: NamedList Reduction: use Java 17 sealed classes so that the
NamedListtype hierarchy is exactly what we want. Agreed as the next step on the dev list (thread).NamedListis nowsealed, permitting onlySimpleOrderedMap, which isfinal. No public method signatures change.Solution
An audit of
mainfound three subclasses ofNamedList, not one:SimpleOrderedMap– expected.CloudSolrClient.RouteResponse– a public nested class returned byCloudSolrClient.request()for routed updates, carrying the per-route responses so thatgetShardReplicationFactor()could read each shard's achieved replication factor. SolrJ has nomodule-info.java, so a permitted subclass must live inNamedList's package, which rules out keeping it as a subclass. As agreed on the Jira, it is removed:condenseResponsenow records each route'srfin the mergedresponseHeaderunderrfByRoute(CloudSolrClient.REPFACT_BY_ROUTE), next to the existing minimumrfand in the same way the tolerant-updateerrorsare merged, andgetShardReplicationFactor()reads that entry instead of casting. Its signature and result are unchanged;getMinAchievedReplicationFactor()is untouched.condenseResponse(NamedList, int)now returnsSimpleOrderedMap<Object>, and the protectedSupplieroverload is gone (nothing overrode it).NestableJsonFacetTest(double-brace initialisation), rewritten to plainadd()calls.One further consequence of sealing: a cast from a
NamedList-typed expression toListis now a compile error, since no permitted subtype implementsList. One test (DistributedFacetSimpleRefinementLongTailTest) did that on a value that was never aNamedList; the containing map is now typedNamedList<Object>.Sealing a public SolrJ class is a plugin-compatibility change: third-party subclasses of
NamedListorSimpleOrderedMapwill no longer compile. This ismain/ 11.0 only, with a changelog entry and an upgrade note inmajor-changes-in-solr-11.adocthat also documentsrfByRoute.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.testRoutingpreviously inspectedRouteResponse.getRoutes(); it now checks each document on the leader of the shardDocRouterroutes it to, andcheckSingleServerasserts that every route URL inrfByRouteis 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 subclassesNamedList. 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:
mainbranch../gradlew check.