forked from phoedos/pmd
@@ -571,6 +571,39 @@ public class Foo {
|
||||
stmt.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description>#1372 False Negative for CloseResource rule.</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<expected-linenumbers>8</expected-linenumbers>
|
||||
<rule-property name="types">Connection,Statement,ResultSet,PreparedStatement</rule-property>
|
||||
<rule-property name="closeTargets">closeLocalResources,closeResultSet</rule-property>
|
||||
<code><![CDATA[
|
||||
public class CloseResourceTest {
|
||||
public Object selectOne(final int val, final int val2) {
|
||||
getCurrentSession().doWork(new Work() {
|
||||
|
||||
@Override
|
||||
public void execute(Connection connection) throws SQLException {
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
stmt = createDefaultPreparedStatement(connection, CONSTANTS.QUERY_STRING);
|
||||
stmt.setInt(1, vaL);
|
||||
stmt.setInt(2, val2);
|
||||
rs = stmt.executeQuery();
|
||||
// do result set processing
|
||||
} catch (SQLException se) {
|
||||
// error
|
||||
} finally {
|
||||
closeLocalResources(stmt);
|
||||
//closeResultSet(rs); // --- ERROR
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
@@ -17,6 +17,7 @@
|
||||
* [#1364](https://sourceforge.net/p/pmd/bugs/1364/): FieldDeclarationsShouldBeAtStartOfClass false positive using multiple annotations
|
||||
* [#1365](https://sourceforge.net/p/pmd/bugs/1365/): Aggregated javadoc report is missing
|
||||
* [#1366](https://sourceforge.net/p/pmd/bugs/1366/): UselessParentheses false positive on multiple equality operators
|
||||
* [#1372](https://sourceforge.net/p/pmd/bugs/1372/): False Negative for CloseResource rule.
|
||||
* [#1375](https://sourceforge.net/p/pmd/bugs/1375/): CloseResource not detected properly
|
||||
|
||||
**API Changes:**
|
||||
|
Reference in New Issue
Block a user