Expected ISE on forking/linking for sequential()/parallel() methods not always happen
Dmitry Bessonov
dmitry.bessonov at oracle.com
Sun Dec 23 11:11:29 PST 2012
Hello,
Expected IllegalStateExceptions is not always thrown when stream (looks
like) has been already linked to a child stream.
The problem occurs with sequential()/parallel() methods when source is
of the same type:
Stream s = Arrays.asList(1, 2, 3).parallelStream();
Stream p1 = s.parallel();
Stream p2 = s.parallel();
Stream s1 = s.sequential();
No ISEs thrown. Just as nothing happens in the case of sequential stream:
Stream s = Arrays.asList(1, 2, 3).stream();
Stream f1 = s.filter( e -> true );
Stream s1 = s.sequential();
Stream s2 = s.sequential();
Stream s3 = s.sequential();
s, s1, s2, s3 refer to the same instance.
The spec for sequential() gives some slight hint on this.
Method parallel() has no spec (in b69) at all.
I might assume that the verdict - if it's a bug or not depends on how
exactly possibly thrown
"java.lang.IllegalStateException: Stream is already linked to a child
stream"
is going to be specified.
-Dmitry
More information about the lambda-dev
mailing list