[
https://issues.apache.org/jira/browse/SOLR-18631?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18147054#comment-18147054
]
ASF subversion and git services commented on SOLR-18631:
--------------------------------------------------------
Commit 4c4bd95cce945804ffe4122635cd633f47c2dff0 in solr's branch
refs/heads/main from Ivan Šarić
[ https://gitbox.apache.org/repos/asf?p=solr.git;h=4c4bd95cce9 ]
SOLR-18631: SimpleOrderedMap.getImmutableCopy() now keeps its type (#5334)
SimpleOrderedMap.getImmutableCopy() now returns a SimpleOrderedMap, as clone()
does, instead of degrading the copy to a plain NamedList and losing its Map
view.
Co-authored-by: Nick Shanin <[email protected]>
> SimpleOrderedMap.getImmutableCopy() returns a plain NamedList
> -------------------------------------------------------------
>
> Key: SOLR-18631
> URL: https://issues.apache.org/jira/browse/SOLR-18631
> Project: Solr
> Issue Type: Bug
> Components: SolrJ
> Reporter: Ivan Saric
> Priority: Minor
> Labels: pull-request-available
> Fix For: main(11.0)
>
> Time Spent: 1h 10m
> Remaining Estimate: 0h
>
> {{SimpleOrderedMap}} overrides {{clone()}} to return a {{SimpleOrderedMap}},
> but not {{getImmutableCopy()}}, which {{NamedList}} implements as {{new
> NamedList<>(Collections.unmodifiableList(copy.nvPairs))}}. So an immutable
> copy of a {{SimpleOrderedMap}} is a plain {{NamedList}}: the caller loses the
> {{Map}} view (SOLR-17623) and the single-key intent, and a later {{instanceof
> SimpleOrderedMap}} or cast fails.
> Found while auditing {{NamedList}} instantiations for SOLR-18612 (SIP-22 step
> 5); the two instantiations inside {{NamedList}} itself were left alone there
> because they must preserve the receiver's kind, and this is the
> {{SimpleOrderedMap}} half of that.
> Fix: override {{getImmutableCopy()}} in {{SimpleOrderedMap}} the way
> {{clone()}} is, returning a {{SimpleOrderedMap}} backed by an unmodifiable
> list, with a unit test asserting the type, immutability and contents of the
> copy.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]