title: Sonarqube issue - Change this "try" to a try-with-resources. How to handle conditional resources?
body: <p>Checked similar questions regarding this topic but I did not find solution to my use-case.
  <br>Following method shows Sonar issue with <code>Major code smell</code> as - <code>Change this &quot;try&quot; to a try-with-resources.</code></p>
  <pre><code>private void readExcel() {
          Workbook workbook = null;
          BufferedReader br = null;
          
          try {
              File file = path.toFile();
              if (file.getName().endsWith(FILE_TYPES.XLS.value) &amp;&amp; (file.length() / (1024 * 1024)) &lt; 25) {
                  workbook = new HSSFWorkbook(new POIFSFileSystem(file));
                  Sheet sheet = workbook.getSheetAt(0);
                  readExcel(sheet);
              } else if ((file.getName().endsWith(FILE_TYPES.XLSX.value)) &amp;&amp; (file.length() / (1024 * 1024)) &lt; 25) {
                  workbook = new XSSFWorkbook(file);
                  Sheet sheet = workbook.getSheetAt(0);
                  readExcel(sheet);
              } else if (file.getName().endsWith(FILE_TYPES.CSV.value)) {
                  // Apache POI cant read/write CSV. Hence using Java IO.
                  br = new BufferedReader(new FileReader(file));
                  readExcel(br);
              }
          } catch (IOException | InvalidFormatException ex) {
                  // set invalid flags and call clean-up
          } finally {
              try {
                  if (workbook != null) {
                      workbook.close();
                  }
                  if (br != null) {
                      br.close();
                  }
              } catch (IOException ex) {
                  // set invalid flags and call clean-up
              }
          } // try-catch-finally closed
      }
  </code></pre>
  <p>Is this false positive sonar issue?</p>