Expected ISE on forking/linking for sequential()/parallel() methods not always happen
Paul Sandoz
paul.sandoz at oracle.com
Fri Dec 28 07:53:26 PST 2012
On Dec 25, 2012, at 3:28 PM, Dmitry Bessonov <dmitry.bessonov at oracle.com> wrote:
> I think here's another "implementations may..." spec casefound.
>
> To throw "java.lang.IllegalStateException: Stream source is already
> consumed" stream source should truly have been consumed as the following
> doesn't throw anything:
>
> Stream<String> stream = Arrays.asList("a", "b", "c").stream();
> stream.into((Stream.Destination) s -> {});
> stream.into((Stream.Destination) s -> {});
> stream.into((Stream.Destination) s -> {});
>
That's because the destination does nothing with the Stream passed to it.
The EG is currently discussing how to remove/replace Stream.into.
The example you present is a good one of the issues with that method.
Paul.
More information about the lambda-dev
mailing list