Stream.cumulate issue
Paul Sandoz
paul.sandoz at oracle.com
Tue Dec 4 13:10:38 PST 2012
Hi,
Thanks for reporting.
It's another one of those null tolerence bugs.
I know what's causing it, null is used to mean no result, as there are cases when the leaf nodes has no values to process.
Paul.
On Dec 4, 2012, at 4:24 PM, Georgiy Rakov <georgiy.rakov at oracle.com> wrote:
> Hello,
>
> cumulate().toArray() seems not to work properly with nulls. Consider following code:
>
> import java.util.Arrays;
> import java.util.stream.Stream;
>
> public class CumulateIssue {
> public static void main(String [] argv) {
> Stream<Object> stream = Arrays.parallel(new Object[]{null,
> null, null, null}).cumulate((a, b)->3);
> System.out.println(Arrays.toString(stream.toArray()));
> }
> }
>
>
> It obviously should output:
>
> [null, 3, 3, 3]
>
> But instead it outputs:
>
> [null, null, null, null]
>
> I could suppose it's a bug. Please confirm if it is.
>
> I use nightly build of November 5.
>
> The code is attached for your convenience.
>
> Thanks,
> Georgiy.
> <CumulateIssue.java>
More information about the lambda-dev
mailing list