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

duke duke at openjdk.org
Wed Nov 13 17:00:30 UTC 2024


On Tue, 12 Nov 2024 16:12:36 GMT, kabutz <duke at openjdk.org> wrote:

>> 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 incrementally with one additional commit since the last revision:
> 
>   Removed NPE when set is empty and added TCK test

@kabutz 
Your change (at version d167b88fcc213b02080d25d9cf4761d41f4bfc1b) is now ready to be sponsored by a Committer.

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

PR Comment: https://git.openjdk.org/jdk/pull/21820#issuecomment-2474200282


More information about the core-libs-dev mailing list