title: Java Null Dereference when setting a field to null - Fortify
body: <p>Fortify is complaining about a Null Dereference when I set a field to null:</p>
  
  <pre><code>String sortName = null;
  if (lastName != null &amp;&amp; lastName.length() &gt; 0) {
     sortName = lastName;
  }
  sortOptions.setSortField(sortName);  &lt;--  Fortify Null Dereference
  </code></pre>
  
  <p>Fortify's analysis trace says:</p>
  
  <pre><code>Assigned null: sortName
  Branch taken: if (lastName != null &amp;&amp; lastName.length() &gt; 0)
  Dereferenced: sortName
  </code></pre>
  
  <p>I could try:</p>
  
  <pre><code>if (sortName == null)
     sortOptions.setSortField(null);
  else
     sortOptions.setSortField(sortName);
  </code></pre>
  
  <p>But that seems really silly. Anyone have experience with this one? I'd prefer to get rid of the finding vs. just write it off.</p>