Menu

#1021 false positive on OBL_UNSATISFIED_OBLIGATION

closed-rejected
5
2017-10-22
2012-01-09
No

This code matches the bug pattern, but I believe is a false positive:

String status = null;
String sql = ...
PreparedStatement ps = null;
try {
ps = conn.getPreparedStatement(sql);
ps.setString(1, id);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
status = rs.getString(1);
}
}
catch (Exception e) {
e.printStackTrace();
}
finally {
if (ps != null) {
try {
ps.close();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}
return status;

The java.sql.Statment docs for close() indicate that closing a statement will also close its current ResultSet.

Regards-
--
Paul Morken

Discussion

  • William Pugh

    William Pugh - 2012-01-09
    • status: open --> open-accepted
     
  • Kirikaza

    Kirikaza - 2013-05-15

    May be related: "All execution methods in the Statement interface implicitly close a statment's current ResultSet object if an open one exists."

     
  • Gonzalo Ortiz Jaureguizar

    It is still happening :/

     
  • Andrey Loskutov

    Andrey Loskutov - 2017-10-22
    • Status: open-accepted --> closed-rejected
     

Log in to post a comment.

MongoDB Logo MongoDB