title: How do I fix this error shown by Sonarlint?
body: <p>A cut-down version of my code looks something like this</p>
  
  <pre><code>package com.funbluebits.test;
  
  import static java.io.File.separator;
  import static java.nio.file.Files.lines;
  import static java.nio.file.Paths.get;
  
  import java.io.*;
  import org.apache.commons.io.FileUtils;
  import org.apache.commons.lang.StringUtils;
  
  public class SonarLintExample {
  
      public static void main(String[] args) {
  
          SonarLintExample sle = new SonarLintExample();
          try {
              sle.handleInputFile("hello.txt");
              sle.handleInputFile("");
              sle.handleInputFile("myfile.pgp");
          }
          catch (Exception e) {
  
          }
      }
  
      public String handleInputFile(final String filePath) throws Exception {
          MarketAndProvider marketAndProvider = null;
          try {
              marketAndProvider = extractMarketAndProvider(filePath);
  
              if (filePath.contains(".pgp") || filePath.contains(".gpg"))
                  return "encrypted";
              else {
                  throw new Exception("Can only process encrypted files ");
              }
  
          } catch (Exception e) {
              if (marketAndProvider == null) {
                  marketAndProvider = new MarketAndProvider("defaultMarket", "defaultProvider");
              }
              // real code does other stuff here too.
              throw new Exception(e);
          }
      }
  
      private MarketAndProvider extractMarketAndProvider(String filePath) {
          if (StringUtils.isEmpty(filePath))
          {
              return null;
          }
          int pos = filePath.indexOf(',');
          String market = filePath.substring(0,  pos);
          String provider = filePath.substring(pos+1);
          return new MarketAndProvider(market, provider);
  
      }
  
      public class MarketAndProvider {
          private final String market;
          private final String provider;
  
          public MarketAndProvider(String market, String provider) {
              this.market = market;
              this.provider = provider;
          }
  
          public String getMarket() {
              return market;
          }
  
          public String getProvider() {
              return provider;
          }
      }
  }
  </code></pre>
  
  <p>Sonarlint (v1.3.1) complains "Change this condition so that it does not always evaluate to "false"" at the line which checks if instance is null. It seems to assume that nothing in the try block is executed and so it would be null. But it is valid for the code to reach this point with 'instance' being set either to null or a value.</p>
  
  <p>What should I do to fix this? Is it a bug in Sonarlint? I don't especially want to turn off the rule - and don't know how to even if I could.</p>
  
  <p>Edited: I have amended the code to be a compilable example. It is cut down from the real code and so throws a number of other SonarLint errors that I am not worrying about here. Especially that marketAndProvider is not used!</p>
  
  <p>Thanks</p>