在哪种情况下这种资源会泄漏?

5 java eclipse

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)

在哪种情况下会发生这种情况?

小智 2

我猜这里的结论是:这是一个Eclipse bug?