PreparedStatement automatically close ResultSet (use try-with-resources or close this "ResultSet" in a "finally" clause)

SonarLint 4.7.0.17141 on IntelliJ


When the PreparedStatement is closed, ResultSet is closed automatically so it doesn’t need to warn if the statement is inside a try with resources

Yes, the above issue is a false-positive. Java documentation contract for java.sql.Statement#close() is saying:

When a Statement object is closed, its current ResultSet object, if one exists, is also closed.

Ticket created: SONARJAVA-3430

Thanks for your feedback,

Alban

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.