RFR: 8376698: Add Spliterator tests for TreeMap sub-maps [v2]

Chen Liang liach at openjdk.org
Thu Feb 19 14:23:57 UTC 2026


On Thu, 19 Feb 2026 09:35:00 GMT, Oli Gillespie <ogillespie at openjdk.org> wrote:

>> Add missing cases to SpliteratorTraversingAndSplittingTest. This came up when I was fixing https://bugs.openjdk.org/browse/JDK-8372946, and I noticed the tests do not cover these sub-maps.
>> 
>> Two interesting parts:
>> 
>> 1. These tests failed when first added because `SubMapKeyIterator` and `DescendingSubMapKeyIterator` do not eagerly throw `NullPointerException` for `null` action arguments. The spec says "Throws: NullPointerException - if the specified action is null", so I updated the implementation to match other spliterators.
>> 2. Since the descending maps have the reverse expected iteration order, I added support in the test harness for descending maps.
>
> Oli Gillespie has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:
> 
>  - Update copyright
>  - Merge remote-tracking branch 'origin/master' into spliterator-test
>  - Switch to Objects.requireNonNull
>  - Add tests and fix impl

Thanks for the update. For the release note, I recommend emulating https://bugs.openjdk.org/browse/JDK-8371963: you should describe the specified behavior of NPE for Spliterator and Stream: https://github.com/openjdk/jdk/blob/bea48b54e2f423693e1e472129a86b030baf9eee/src/java.base/share/classes/java/util/stream/Stream.java#L123-L127

and describe the behaviors before (returns false; completes normally) and after the fix (NPE)

-------------

PR Comment: https://git.openjdk.org/jdk/pull/29485#issuecomment-3927600171


More information about the core-libs-dev mailing list