Community
Participate
Working Groups
I believe I'm getting a false positive resource leak warning when resources are closed using apache dbutils closeQuietly methods. Simplified Code: public static void test(Connection con){ PreparedStatement ps = null; try { ps = con.prepareStatement("foo"); // Remove this loop for no warning for (int i = 0; i < 1; i++) { try { ps.executeUpdate(); } catch (SQLException e) { throw new SQLException("Some message", e); // << warning } // << move the closing finally to here for no warning } } catch (SQLException e) { throw new RuntimeException(e); } finally { DbUtils.closeQuietly(ps); // << change this to ps.close for no warning } } The warning is removed if: 1, I add the finally block after the inner try-catch 2, I change closeQuietly to ps.close() (with the required try-catch wrapper) 3, I remove the for-loop
It seems you missed the train on bug 381445 :) Please see bug 381445 comment 11 for utilities which are known to the analysis. It's amazing how many ppl implemented this one method closeQuietly ...
Ah, I had seen that bug but had missed that the fix doesn't support other close* methods. Apologies.
I've added support for the following methods from org.apache.commons.dbutils.DbUtils: - close(Connection conn) - close(ResultSet rs) - close(Statement stmt) - closeQuietly(Connection conn) - closeQuietly(Connection conn, Statement stmt, ResultSet rs) - closeQuietly(ResultSet rs) - closeQuietly(Statement stmt) - commitAndClose(Connection conn) - commitAndCloseQuietly(Connection conn) - rollbackAndClose(Connection conn) - rollbackAndCloseQuietly(Connection conn) Starting with JRE 1.7 all parameters are AutoCloseable (for 1.6 no leak analysis will be performed for these types). The 3-arg closeQuietely() is s.t. new: indeed all three arguments are AutoCloseable and invocation of close() has to be recorded for all three. Released for 4.4 M1 via commit c9c5f11eddd07d2a8299046a3df03585e022db6e.
resolved as per previous comment.
Nothing to verify. Verified for 4.4M1 using I20130805-0800 build.
(In reply to comment #5) > Nothing to verify. Verification done by checking for the presence of warning message in an earlier eclipse and the absence of warning message in the current version. > > Verified for 4.4M1 using I20130805-0800 build.