Eclipse 4发出警告,说明stmt可能无法关闭并导致资源泄漏:
class Test {
public void test() {
PreparedStatement stmt = null;
try {
stmt = HibernateSession.instance().connection().prepareStatement("");
} catch (final SQLException e) {
e.printStackTrace();
} finally {
if (stmt != null)
try {
stmt.close();
} catch (final SQLException e) {
e.printStackTrace();
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
在哪种情况下会发生这种情况?