Streams.stream(aMethod()) versus aMethod().stream()

Note to self:
If getMessages() results in null, the following will cause an NPE:

Object messages = getMessages().stream().anyThing.

The following won’t:

Object messages = Streams.stream(getMessages()).anyThing.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.