SonarLint: "close()" calls should not be redundant

From Java 7 when we use try with resource, try with resource will automatically handle closing of the resources and hence we don't need to close the resource manually.

Noncompliant Code Example

try (PrintWriter writer = new PrintWriter(process.getOutputStream())) {
  String contents = file.contents();
  writer.write(new Gson().toJson(new MyObject(contents)));
  writer.flush();
  writer.close();     // Noncompliant
}

Compliant Solution

try (PrintWriter writer = new PrintWriter(process.getOutputStream())) {
  String contents = file.contents();
  writer.write(new Gson().toJson(new MyObject(contents)));
  writer.flush();
}