title: How should we manage jdk8 stream for null values
body: <p>I know the subject may be a bit <code>in advance</code> as the JDK8 is not yet released (and not for now anyway..) but I was reading some articles about the Lambda expressions and particularly the part related to the new collection API known as Stream.</p>
  <p>Here is the example as given in the <a href="http://www.oraclejavamagazine-digital.com/javamagazine_open/20130304#pg42" rel="noreferrer">Java Magazine article</a> (it is an otter population algorithm..):</p>
  <pre><code>Set&lt;Otter&gt; otters = getOtters();
  System.out.println(otters.stream()
      .filter(o -&gt; !o.isWild())
      .map(o -&gt; o.getKeeper())
      .filter(k -&gt; k.isFemale())
      .into(new ArrayList&lt;&gt;())
      .size());
  </code></pre>
  <p>My question is what happen if in the middle of the Set internal iteration, one of the otter is null?</p>
  <p>I would expect a NullPointerException to be thrown but maybe am I still stuck in the previous development paradigm (non-functional), can someone enlighten me as how this should be handled?</p>
  <p>If this really throw a NullPointerException, I find the feature quite dangerous and will have to be used only as below:</p>
  <ul>
  <li>Developer to ensure there is no null value (maybe using a previous
  .filter(o -&gt; o != null))</li>
  <li>Developer to ensure the application is never
  generating null otter or a special NullOtter object to deal with.</li>
  </ul>
  <p>What is the best option, or any other option?</p>