Back to Intellij Community

RedundantExplicitClose

java/java-impl/resources/inspectionDescriptions/RedundantExplicitClose.html

2025.3-rc-2334 B
Original Source

Reports unnecessary calls to close() at the end of a try-with-resources block and suggests removing them.

Example :

try(MyAutoCloseable ac = new MyAutoCloseable()) {
    foo();
    ac.close();
  }

After the quick-fix is applied:

try(MyAutoCloseable ac = new MyAutoCloseable()) {
    foo();
  }

New in 2018.1