RFR: 8343426: ConcurrentSkipListMap.spliterator() can no longer split the stream [v2]

kabutz duke at openjdk.org
Tue Nov 12 16:02:20 UTC 2024


> Since Java 10, spliterators for the ConcurrentSkipListMap were pointing to the head, which has item == null, rather than to the first element. The trySplit() method no longer worked, and always returned null. Therefore, parallel streams have not worked for ConcurrentSkipListMap and ConcurrentSkipListSet since Java 10. It worked correctly in Java 8 and 9.
> 
> The problem lies in the constructor calls for the various spliterators. In Java 9, we pass in head.node.next as "origin" into the  constructor. In Java 10, this was changed to just head.node as "origin". Since the "item" field is always null on head.node, we never enter the first if() statement in the trySplit() method and thus it always returns null.

kabutz 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 two additional commits since the last revision:

 - Merge branch 'openjdk:master' into 8343426-cslm-spliterator-bug
 - Fixed bug in spliterators

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/21820/files
  - new: https://git.openjdk.org/jdk/pull/21820/files/28658230..7edb48c8

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=21820&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=21820&range=00-01

  Stats: 218051 lines in 2420 files changed: 138428 ins; 54883 del; 24740 mod
  Patch: https://git.openjdk.org/jdk/pull/21820.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/21820/head:pull/21820

PR: https://git.openjdk.org/jdk/pull/21820


More information about the core-libs-dev mailing list