JDK-8071597: close original Stream in default implementation?
Tagir F. Valeev
amaembo at gmail.com
Wed Jul 8 02:58:01 UTC 2015
Hello,
I was looking at default implementation of new Stream
takeWhile/dropWhile methods:
http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8071597-take-drop-while/webrev/src/java.base/share/classes/java/util/stream/Stream.java.cdiff.html
I think in order to make this default behavior more consistent, the
original Stream must be closed when the returned one is closed. Thus,
takeWhile return statement should look like this:
return StreamSupport.stream(
new WhileOps.UnorderedWhileSpliterator.OfRef.Taking<>
(spliterator(), true, predicate),
isParallel()).onClose(this::close);
The same for dropWhile method.
What do you think?
Regards,
Tagir Valeev.
More information about the core-libs-dev
mailing list