Sorting streams containing nulls

Georgiy Rakov georgiy.rakov at oracle.com
Wed Nov 7 02:22:09 PST 2012


Hello.

When we make sorted(...).iterator() on Stream instance containing one 
ore more nulls we receive NPE. The example of stack trace is below:

    java.lang.NullPointerException
         at java.util.PriorityQueue.offer(PriorityQueue.java:320)
         at java.util.PriorityQueue.add(PriorityQueue.java:306)
         at java.util.streams.ops.SortedOp.iterator(SortedOp.java:105)
         at java.util.streams.ops.SortedOp.wrapIterator(SortedOp.java:97)
         at
    java.util.streams.AbstractPipeline.iterator(AbstractPipeline.java:329)
         ...

Could you please tell if it is considered as expected behavior or it's 
going to be fixed somehow.

Georgiy.


More information about the lambda-dev mailing list