RFR 8193856 takeWhile produces incorrect result with elements produced by flatMap
jbluettduncan at gmail.com
Wed Dec 20 22:47:49 UTC 2017
It seems that some clever Googler managed to find a workaround for
aggressive `flatMap` operations in the form of a so-called
`MoreStreams.flatten` operation, implemented in a side project called
google/mug. I'm sharing the javadoc
GitHub project homepage <https://github.com/google/mug> with you and the
rest of the mailing list in the hope that they prove to be useful.
On 20 December 2017 at 21:28, Paul Sandoz <paul.sandoz at oracle.com> wrote:
> Please review this fix for a bug in the stream takeWhile operation:
> takeWhile-incorrect-results/webrev/ <http://cr.openjdk.java.net/~
> The flatMap operation is currently aggressive and does not detect if a
> downstream operation may or has cancelled processing, and will push all of
> it’s elements downstream. Short-circuiting operations should be guarded
> against such behaviour but unfortunately takeWhile was not guarded.
> Separately i plan to figure out a way to ensure flatMap operations become
> less aggressive if there are short-circuiting downstream operations. This
> may increase efficiency and also allow support for flat map results that
> are infinite.
More information about the core-libs-dev