Behavior of concat(null)
Remi Forax
forax at univ-mlv.fr
Mon Nov 19 14:57:36 PST 2012
Elena,
just to understand do you try to call
1) stream.concat(null);
or
2) stream.concate(stream2); // with some null in stream2
for case 1) concat should throw a NPE, for case 2) see the answer of
Brian :)
Rémi
On 11/19/2012 04:57 PM, Brian Goetz wrote:
> 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