Affects PMD Version:
6.30.0
Rule:
https://pmd.github.io/latest/pmd_rules_java_errorprone.html#closeresource
Description:
if usingif (Objects.nonNull(preparedStmt))
instead ofif (preparedStmt != null)
rule still fires a violation
Code Sample demonstrating the issue:
PreparedStatement lPreparedStmt = null;
try {
lPreparedStmt = conn.prepareStatement(sqL);
lPreparedStmt.execute();
} catch (SQLException ex) {
LOG.debug("lPreparedStmt.execute();loooooooooooooose" + ex);
} finally {
if (Objects.nonNull(lPreparedStmt)) {
try {
lPreparedStmt.close();
} catch (SQLException pEx) {
LOG.error("unrecoverable", pEx);
}
}
}
Expected outcome:
false-positive
Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]
eclipse acanda plugin
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