Sonarqube keeps marking code with this issue which is, in my opinion, a false positive. Code looks like this:
try(PreparedStatement st=con.prepareStatement(myQuery)){
st.setInt(1, myValue);
...
ResultSet rs = st.executeQuery();
...
}
If I'm not mistaken, the PreparedStatement implements Closeable and, when closing itself, it also closes the underlying ResultSet.
This behaviour would prevent the ResultSet from being kept open, yet Sonarqube analysis marks it as a critical error.
Am I mistaken? Any way of making Sonarqube ignore this rule under this circumstances?
Tested under Sonarqube 6.7.3 and JDK 8.
From the ResultSet
javadoc:
A ResultSet object is automatically closed when the Statement object that generated it is closed, re-executed, or used to retrieve the next result from a sequence of multiple results.
sonar-project.properties
file or properties from pom if you're using maven-plugin) maybe in that place could be something wrong. – Baroness