Affects PMD Version:
maven-pmd-plugin 3.13.0 (pmd 6.21.0)
Rule: UseTryWithResources
Description:
PMD Failure: UseTryWithResources when resource is not AutoCloseable and closed via external class which implement AutoCloseable
Code Sample demonstrating the issue:
public class PMDUseTryWithResources { static class ResourceCloser implements AutoCloseable { public static void close(NotAutoCloseable notAutoCloseable) { notAutoCloseable.close(); } @Override public void close() throws Exception { // nothing } } interface NotAutoCloseable { void close(); } public void useTryWithResources() { NotAutoCloseable notAutoCloseable = null; try { notAutoCloseable = new NotAutoCloseable() { @Override public void close() { } }; } finally { if (notAutoCloseable != null) { ResourceCloser.close(notAutoCloseable); } } } }
Steps to reproduce:
Running PMD through: Maven
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4