NPE thrown by Stream.findFirst()/findAny() for a stream having null elements

Brian Goetz brian.goetz at oracle.com
Tue Oct 23 06:53:00 PDT 2012


Yes.  We will not be bending over backwards to support null elements in 
streams.  The FindXxx methods take the found value and pass them to new 
Optional(), which rejects the null elements.  This is expected behavior.

On 10/23/2012 8:38 AM, Dmitry Bessonov wrote:
> Hello,
>
>    For example the following lines both cause NPEs if run on the current
> implementation:
>
>           Arrays.asStream(null, null, null).findFirst();
>           Arrays.asStream(null, null, null).findAny();
>
> -Dmitry
>
>
>


More information about the lambda-dev mailing list