JDK-8042355 stream with sorted() causes downstream ops not to be lazy

Florian Weimer fweimer at redhat.com
Tue May 6 09:30:25 UTC 2014

On 05/05/2014 03:16 PM, Paul Sandoz wrote:
> Hi,
>    https://bugs.openjdk.java.net/browse/JDK-8042355
>    http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8042355-sorted-short-circuit/webrev/
> This is an optimization to ensure that sorted() in sequential pipelines does not aggressively push all sorted elements downstream if the pipeline is known to be short-circuiting.

Would it be possible to use something like heap sort to avoid sorting 
the entire input stream if only the first few smallest items are needed?

Florian Weimer / Red Hat Product Security Team

More information about the core-libs-dev mailing list