title: Why does FindBugs complain that .collect(toSet()) might return null?
body: <p>I have the following code, which as far as I can see it cannot return null:</p>
  
  <pre><code>import javax.annotation.Nonnull;
  
  public static @Nonnull Set&lt;String&gt; foo() {
      return Arrays.asList("a","b","c").stream().collect(Collectors.toSet()); // line 166
  }
  </code></pre>
  
  <p>But FindBugs complains with a <code>NP_NONNULL_RETURN_VIOLATION</code> error.</p>
  
  <pre><code>[INFO] MyClass.foo() may return null, 
     but is declared @Nonnull [MyClass, MyClass]
     Returned at MyClass.java:[line 166]
     Known null at MyClass.java:[line 166]
     NP_NONNULL_RETURN_VIOLATION
  </code></pre>
  
  <p>I have checked the documentation to "collect" and "toSet" and they don't mention anything about nulls, neither that they return them, nor that they don't. But I can't imagine a situation in which that returns null.</p>
  
  <p>I was thinking maybe FindBugs just doesn't understand Java 8 stream features. But FindBugs otherwise does seem to understand Java 8 features (e.g. the <code>@Nonnull</code> annotation itself.)</p>
  
  <p>I am using the FindBugs Maven Plug-in version 3.0.4, and my source depends on the FindBugs 3.0.1 in Maven. I understand these are the latest versions at the time of writing.</p>
  
  <p>(The code may appear to be a bit pointless, it's just an example.)</p>