title: findbugs: Possible null pointer dereference warning
body: <p>I got <code>Possible null pointer dereference in convertMultiPartToFile(MultipartFile) due to return value of called method [line 91]</code> in my findbugs report.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>private File convertMultiPartToFile(MultipartFile file) throws IOException {
          //line below is the line 91
          if (file == null || file.getOriginalFilename() == null)
              throw new InputValidationException("fileNameInvalid", i18n, file.getOriginalFilename());
          File convFile = new File(file.getOriginalFilename());
          FileOutputStream fos = new FileOutputStream(convFile);
          fos.write(file.getBytes());
          fos.close();
          return convFile;
  }
  </code></pre>
  
  <p>I already check the null value of the file, why do I still get the warning?</p>
  
  <p><strong>Update 1:</strong></p>
  
  <p>After I removed the file name in the exception, it still has a warning on the line below.</p>
  
  <pre><code>private File convertMultiPartToFile(MultipartFile file) throws IOException {           
          if (file == null || file.getOriginalFilename() == null)
              throw new InputValidationException("fileNameInvalid", i18n, "");
          File convFile = new File(file.getOriginalFilename()); // warning here
          FileOutputStream fos = new FileOutputStream(convFile);
          fos.write(file.getBytes());
          fos.close();
          return convFile;
  }
  </code></pre>
  
  <p><strong>Update 2:</strong></p>
  
  <pre><code>private File convertMultiPartToFile(MultipartFile file) throws IOException {
      File convFile = null;
      if (file != null &amp;&amp; file.getOriginalFilename() != null) {
          convFile = new File(file.getOriginalFilename()); //line 91
          try (FileOutputStream fos = new FileOutputStream(convFile);) {
              fos.write(file.getBytes());
          }
      }
      return convFile;
  }
  </code></pre>
  
  <p>Adapted @Michael Peacock's answer, the warning is still there.</p>
  
  <blockquote>
    <p>Possible null pointer dereference in convertMultiPartToFile(MultipartFile) due to return value of called method</p>
    
    <p>Bug type NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE (click for details)
    In class com.corpobids.server.service.AwsAPIService
    In method convertMultiPartToFile(MultipartFile)</p>
    
    <p>Local variable stored in JVM register ?</p>
    
    <p>Method invoked at Service.java:[line 91]</p>
    
    <p>Known null at Service.java:[line 91]</p>
  </blockquote>