I am having trouble figuring why findAny() throws a null pointer exception after filter() operation on a stream. In this particular test case, the filt
No, it's not the behavior, when the stream doesn't contain any elements. In which case it instead returns an Optional.empty().
Also, the NPE is the cause of a null value in the stream, as stated in the javadocs:
Returns: an Optional describing some element of this stream, or an empty Optional if the stream is empty Throws: NullPointerException - if the element selected is null