Tighten SolrQueryResponse.getResponseHeader/addResponseHeader to SimpleOrderedMap - #4809
Open
serhiy-bzhezytskyy wants to merge 2 commits into
Open
Conversation
…leOrderedMap getResponseHeader() always returned an actual SimpleOrderedMap internally, masked by an unchecked cast; declaring the real type removes the cast and lets 4 call sites in QueryComponent/CombinedQueryComponent use put() instead of asShallowMap().put()/remove()+add(). It also turns the exact class of bug hit in SOLR-18373 (a test mock returning a plain NamedList, causing a runtime ClassCastException) into a compile error instead. Binary-incompatible for external callers compiled against the old NamedList signature (verified: NoSuchMethodError). Flagging for review since this is long-standing public API, not something marked experimental/internal.
dsmiley
approved these changes
Aug 25, 2026
dsmiley
left a comment
Contributor
There was a problem hiding this comment.
For Solr 11. The binary incompatibility break for a prolific API like this wouldn't be nice for Solr plugin writers.
Contributor
|
@serhiy-bzhezytskyy can you add a changelog since this is a binary incompatbility? |
Contributor
Author
|
Added — see |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to @dsmiley's suggestion on #4761 (review thread on
QueryComponent.java): rather than keep theremove()+add()workaround needed there becausegetResponseHeader()'s declared return type (NamedList<Object>) doesn't have aput(), this tightens the declared type to what it always actually is at runtime --SimpleOrderedMap<Object>-- removing the internal unchecked cast and letting the 4 call sites inQueryComponent/CombinedQueryComponentuseput()directly.This also closes the actual hole that caused #4761's
ClassCastException:MockResponseBuilder's mock was stubbinggetResponseHeader()to return a bareNamedList, which the contract allowed but reality never produced. With the tightened return type, that mismatch is now a compile error instead of a runtimeClassCastException.Compatibility note: this is binary-incompatible for any external caller compiled against the old
NamedListsignature -- verified locally (compiled a caller against the old class files, ran it against the new ones without recompiling):NoSuchMethodErroron bothgetResponseHeader()andaddResponseHeader(NamedList).SolrQueryResponseis@since solr 0.9public API with no experimental/internal marker, so flagging this explicitly rather than treating it as a purely internal cleanup -- your call whether that's acceptable for 11.0.AI-assisted (Claude Sonnet 5)