Behavior of concat(null)
Brian Goetz
brian.goetz at oracle.com
Mon Nov 19 07:57:50 PST 2012
We do not guarantee that any given operation WILL or WILL NOT throw NPE
when present with nulls. We have made some efforts to avoid throwing
NPEs from within the Streams library code, but even that is not
guaranteed (put that in the "reasonable efforts" category.) We expect
most, but not all, NPEs resulting from null elements to come from code
outside java.util.stream, such as lambdas passed to the operation,
Arrays.sort(), the constructor of Optional, etc.
On 11/19/2012 10:17 AM, elena votchennikova wrote:
> Hello,
>
> I'm trying to use method concat(Stream) of some Stream implementation
> with null-argument and currently it doesn't throw NullPointerException.
> Exception is thrown only when I call some method of the resulting
> Stream, for example iterator().
>
> Could you please explain - is it an expected behavior or concat() with
> null-argument should throw NPE?
>
>
> Thanks a lot,
> Elena
>
More information about the lambda-dev
mailing list