RFR: 8376698: Add Spliterator tests for TreeMap sub-maps
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. ------------- Commit messages: - Switch to Objects.requireNonNull - Add tests and fix impl Changes: https://git.openjdk.org/jdk/pull/29485/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=29485&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8376698 Stats: 30 lines in 2 files changed: 29 ins; 1 del; 0 mod Patch: https://git.openjdk.org/jdk/pull/29485.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/29485/head:pull/29485 PR: https://git.openjdk.org/jdk/pull/29485
On Thu, 29 Jan 2026 12:40:42 GMT, Oli Gillespie <ogillespie@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.
Thanks for this patch. For this bugfix we need a CSR that some methods in treemap view spliterators now start throwing NPE for empty views, for documentation purposes. I have filed the CSR. ------------- PR Comment: https://git.openjdk.org/jdk/pull/29485#issuecomment-3819918225
On Thu, 29 Jan 2026 12:40:42 GMT, Oli Gillespie <ogillespie@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.
Thanks! ------------- PR Comment: https://git.openjdk.org/jdk/pull/29485#issuecomment-3820025823
On Thu, 29 Jan 2026 12:40:42 GMT, Oli Gillespie <ogillespie@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.
src/java.base/share/classes/java/util/TreeMap.java line 2141:
2139: } 2140: public void forEachRemaining(Consumer<? super K> action) { 2141: Objects.requireNonNull(action);
Is there a test for NPE action on an empty Map? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/29485#discussion_r2743399918
On Thu, 29 Jan 2026 20:29:43 GMT, Roger Riggs <rriggs@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.
src/java.base/share/classes/java/util/TreeMap.java line 2141:
2139: } 2140: public void forEachRemaining(Consumer<? super K> action) { 2141: Objects.requireNonNull(action);
Is there a test for NPE action on an empty Map?
The new cases for subMap in SpliteratorTraversingAndSplittingTest should be sufficient. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/29485#discussion_r2743414552
On Thu, 29 Jan 2026 20:33:47 GMT, Chen Liang <liach@openjdk.org> wrote:
src/java.base/share/classes/java/util/TreeMap.java line 2141:
2139: } 2140: public void forEachRemaining(Consumer<? super K> action) { 2141: Objects.requireNonNull(action);
Is there a test for NPE action on an empty Map?
The new cases for subMap in SpliteratorTraversingAndSplittingTest should be sufficient.
I'd rather see it tested explicitly; its hard to identify exactly which test expects and catches the NPE. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/29485#discussion_r2743794120
On Thu, 29 Jan 2026 22:22:57 GMT, Roger Riggs <rriggs@openjdk.org> wrote:
The new cases for subMap in SpliteratorTraversingAndSplittingTest should be sufficient.
I'd rather see it tested explicitly; its hard to identify exactly which test expects and catches the NPE.
The modification to that test adds new entries to a data provider. The NPE is checked by the preexisting testNullPointerException which tests all speliterators in the data set. I don't think an additional explicit unit test provides much value over the existing "cartesian" setup. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/29485#discussion_r2743827273
On Thu, 29 Jan 2026 22:35:58 GMT, Chen Liang <liach@openjdk.org> wrote:
I'd rather see it tested explicitly; its hard to identify exactly which test expects and catches the NPE.
The modification to that test adds new entries to a data provider. The NPE is checked by the preexisting testNullPointerException which tests all speliterators in the data set. I don't think an additional explicit unit test provides much value over the existing "cartesian" setup.
Thanks, indeed [testNullPointerException](https://github.com/openjdk/jdk/blob/master/test/jdk/java/util/Spliterator/Sp...) runs on all of the input spliterators and sizes, and empty is [explicitly](https://github.com/openjdk/jdk/blob/master/test/jdk/java/util/Spliterator/Sp...) one of the chosen sizes, so I think that's appropriate coverage. Naturally I confirmed that it does fail the tests as expected without the fix. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/29485#discussion_r2745337433
On Thu, 29 Jan 2026 12:40:42 GMT, Oli Gillespie <ogillespie@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.
The CSR will need to wait for Stuart Marks' review; unfortunately he is tied up in the new JSON API (as disclosed in babylon) development. ------------- PR Comment: https://git.openjdk.org/jdk/pull/29485#issuecomment-3858032420
On Thu, 29 Jan 2026 12:40:42 GMT, Oli Gillespie <ogillespie@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.
Thanks. No rush :) ------------- PR Comment: https://git.openjdk.org/jdk/pull/29485#issuecomment-3858990523
On Thu, 29 Jan 2026 12:40:42 GMT, Oli Gillespie <ogillespie@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.
The code change looks fine to me. Let another core library engineer double check. Note this patch requires a release note according to the CSR: some calls like `new TreeSet<Integer>().subSet(-1, 1).stream().forEach(null);` now throws NPE instead of completing normally. ------------- Marked as reviewed by liach (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/29485#pullrequestreview-3823568148
On Thu, 29 Jan 2026 12:40:42 GMT, Oli Gillespie <ogillespie@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.
These two modified files also need their copyright years updated. ------------- PR Comment: https://git.openjdk.org/jdk/pull/29485#issuecomment-3924820609
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 ------------- Changes: - all: https://git.openjdk.org/jdk/pull/29485/files - new: https://git.openjdk.org/jdk/pull/29485/files/82be36d8..f376e3c1 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=29485&range=01 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=29485&range=00-01 Stats: 89511 lines in 1537 files changed: 44815 ins; 21887 del; 22809 mod Patch: https://git.openjdk.org/jdk/pull/29485.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/29485/head:pull/29485 PR: https://git.openjdk.org/jdk/pull/29485
On Thu, 19 Feb 2026 09:35:00 GMT, Oli Gillespie <ogillespie@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. Created release note: https://bugs.openjdk.org/browse/JDK-8378229 and updated copyright. ------------- PR Comment: https://git.openjdk.org/jdk/pull/29485#issuecomment-3926033142
On Thu, 19 Feb 2026 09:35:00 GMT, Oli Gillespie <ogillespie@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... 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
On Thu, 19 Feb 2026 09:35:00 GMT, Oli Gillespie <ogillespie@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. Updated release note to:
`Stream.forEach(Consumer<? super T> action)`, `Spliterator.forEachRemaining(Consumer<? super T> action)` and `Spliterator.tryAdvance(Consumer<? super T> action)` specify they throw `NullPointerException` if their argument is `null`. In prior releases, implementations of `Spliterator` and `Stream` for subsets of `TreeMap` and `TreeSet` did not throw `NullPointerException` when passed a null action if the subset was empty. These methods now throw `NullPointerException` when passed a null action for an empty subset instead of returning `false` or completing normally.
What do you think? ------------- PR Comment: https://git.openjdk.org/jdk/pull/29485#issuecomment-3927673153
On Thu, 19 Feb 2026 09:35:00 GMT, Oli Gillespie <ogillespie@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
The copyright year update and release note update look good to me. ------------- Marked as reviewed by liach (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/29485#pullrequestreview-3826335209
On Thu, 19 Feb 2026 09:35:00 GMT, Oli Gillespie <ogillespie@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! @RogerRiggs would you mind taking a look too? ------------- PR Comment: https://git.openjdk.org/jdk/pull/29485#issuecomment-3932778069
On Thu, 19 Feb 2026 09:35:00 GMT, Oli Gillespie <ogillespie@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
Looks good, thanks ------------- Marked as reviewed by rriggs (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/29485#pullrequestreview-3832717288
On Thu, 19 Feb 2026 09:35:00 GMT, Oli Gillespie <ogillespie@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
@olivergillespie Your change (at version f376e3c1376b91b9df0e79c78737a3c416fcb3b0) is now ready to be sponsored by a Committer. ------------- PR Comment: https://git.openjdk.org/jdk/pull/29485#issuecomment-3935684432
On Thu, 19 Feb 2026 09:35:00 GMT, Oli Gillespie <ogillespie@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 this improvement! Remember to follow the 4th step in ["Writing a release note"](https://openjdk.org/guide/#writing-a-release-note) that you should Resolve the note with resolution "Delivered" so it will show up in https://jdk.java.net/27/release-notes. ------------- PR Comment: https://git.openjdk.org/jdk/pull/29485#issuecomment-3935981647
On Thu, 19 Feb 2026 09:35:00 GMT, Oli Gillespie <ogillespie@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
The release note title should reflect the change in behavior. In retrospect, the issue should also have been re-titled to describe the problem, not the tests. ------------- PR Comment: https://git.openjdk.org/jdk/pull/29485#issuecomment-3936134325
On Thu, 19 Feb 2026 09:35:00 GMT, Oli Gillespie <ogillespie@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
The release note title is `Release Note: NPE for empty TreeMap/TreeSet sub-set Spliterator and Stream`, do you suggest something else?
In retrospect, the issue should also have been re-titled to describe the problem, not the tests.
Yes my bad, I started out just adding the tests and then realized the behaviour was wrong and fixed that. Forgot to update the title. ------------- PR Comment: https://git.openjdk.org/jdk/pull/29485#issuecomment-3936197508
On Thu, 29 Jan 2026 12:40:42 GMT, Oli Gillespie <ogillespie@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.
This pull request has now been integrated. Changeset: 932f28c6 Author: Oli Gillespie <ogillespie@openjdk.org> Committer: Chen Liang <liach@openjdk.org> URL: https://git.openjdk.org/jdk/commit/932f28c69b8573ad85fde2e0fa00cb3a46d93c2e Stats: 32 lines in 2 files changed: 29 ins; 1 del; 2 mod 8376698: Add Spliterator tests for TreeMap sub-maps Reviewed-by: liach, rriggs ------------- PR: https://git.openjdk.org/jdk/pull/29485
participants (4)
-
Chen Liang
-
duke
-
Oli Gillespie
-
Roger Riggs