isaric opened a new pull request, #5334:
URL: https://github.com/apache/solr/pull/5334

   https://issues.apache.org/jira/browse/SOLR-18631
   
   # Description
   
   `SimpleOrderedMap` overrides `clone()` to return a `SimpleOrderedMap`, but 
not `getImmutableCopy()`, which `NamedList` implements by wrapping the cloned 
pairs in a new plain `NamedList`. So an immutable copy of a `SimpleOrderedMap` 
degrades to a `NamedList`: the `Map` view from SOLR-17623 is gone, and a later 
`instanceof SimpleOrderedMap` or cast fails.
   
   Nothing in `main` hits this today (the only caller of `getImmutableCopy()` 
is `InitParams`, on config `NamedList`s), but every SOLR-18612 slice creates 
more `SimpleOrderedMap` instances, and SIP-22 step 6 needs the copy operations 
inside `NamedList` to preserve the receiver's kind. This is the 
`SimpleOrderedMap` half of that.
   
   # Solution
   
   Override `getImmutableCopy()` in `SimpleOrderedMap` the same way `clone()` 
is overridden: clone, then wrap the pairs in an unmodifiable list through the 
existing private list-backed constructor. The override narrows the return type 
to `SimpleOrderedMap<T>`, which is source-compatible for callers.
   
   AI disclosure: the test, the fix and this description were drafted with 
Claude Code and reviewed by me.
   
   # Tests
   
   `SimpleOrderedMapTest.testGetImmutableCopyKeepsType`, written first and 
failing on `main`: asserts the copy is a `SimpleOrderedMap`, equals the 
original, has the expected pairs, rejects `add`, `remove` and `setVal`, and 
does not see later changes to the original. `SimpleOrderedMapTest` and 
`NamedListTest` pass, as does `./gradlew check -x test`.
   
   # 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`.
   - [x] I have added tests for my changes.
   - [ ] 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]

Reply via email to