[ 
https://issues.apache.org/jira/browse/SOLR-18631?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18148544#comment-18148544
 ] 

ASF subversion and git services commented on SOLR-18631:
--------------------------------------------------------

Commit c4329cf57a68f351a84519f7f4618d7dd9e7dcdc in solr's branch 
refs/heads/branch_10x from Ivan Šarić
[ https://gitbox.apache.org/repos/asf?p=solr.git;h=c4329cf57a6 ]

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.

Backport delta: omits testSerialVersionUID, which extends the Java 
serialization tests from SOLR-18196 (#4995) that are not on branch_10x.

Co-authored-by: Nick Shanin <[email protected]>
(cherry picked from commit 4c4bd95cce945804ffe4122635cd633f47c2dff0)


> 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 20m
>  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]

  • [jira] [Commented] (SOLR... ASF subversion and git services (Jira) via issues
    • [jira] [Commented] ... ASF subversion and git services (Jira) via issues

Reply via email to