Community
Participate
Working Groups
With the following method: public CachedRowSet executeQuery(Connection conn, String sqlStatement) throws SQLException { CachedRowSet result = null; Statement st = conn.createStatement(); try { result = new CachedRowSetImpl(); ResultSet resultSet = st.executeQuery(sqlStatement); try { result.populate(resultSet); } finally { resultSet.close(); resultSet = null; } } finally { st.close(); st = null; } return result; } the variable st in the line with executeQuery() is highlighted with the warning: "The variable st can only be null; it was either set to null or checked for null when last used". Clearly, this is not the case. I guess this is something to do with the finally block. Strange then, that the resultSet variable is not affected. If I delete the "st = null" line, the warning goes away, but the resultSet variable is still not highlighted.
*** Bug 128963 has been marked as a duplicate of this bug. ***
Reproduced with I20060217-1115 (aka M5).
Reduced the test case to: public class X { public void foo(Y y) throws E { try { new Y(); y.bar(); // should be quiet } finally { y = null; } } } class Y { Y() throws E { } void bar() throws E { } } class E extends Exception { private static final long serialVersionUID = 1L; } (NullRefenceTest #519.)
Created attachment 36803 [details] HEAD - suggested fix plus test case
Added NullReferenceTest #520 to track the same issue into QualifiedAllocationExpression. The problem comes from a side effect on flow info null bits when stored along with exceptions within the enclosing context.
*** Bug 129117 has been marked as a duplicate of this bug. ***
Fixed and released in HEAD. Verification can leverage the original submission or the added test cases. The key is the fact that the constructor may throw a checked exception.
The Target Milestone must be 3.2M6 and not 3.2RC1. I correct it. Verified for 3.2 M6 using build 3.2M6
*** Bug 136509 has been marked as a duplicate of this bug. ***