forEach loops forever for infinite streams
Brian Goetz
brian.goetz at oracle.com
Wed Nov 14 06:55:38 PST 2012
Yes, the previous behavior that threw ISE were just "training wheels" to
get comfortable with the concepts. If you perform a terminal operation
that consumes all the input (forEach, into, reduce, etc), it will
consume all of the future as well.
There are some terminal operations that are safe(r) on infinite streams,
such as findFirst/findAny, and some intermediate operations that
guarantee a finite result (such as limit).
On 11/14/2012 9:28 AM, Georgiy Rakov wrote:
> Hello,
>
> forEach method call on infinite stream causes infinite looping over
> supplied block. Some of previous build threw IllegalStateException. The
> current behavior seems to be obvious and logic; could you please just
> confirm that it's really the expected behavior.
>
> Thanks, Georgiy.
>
More information about the lambda-dev
mailing list