Bug 128963

Summary: [compiler] null reference analysis: incorrect analysis
Product: [Eclipse Project] JDT Reporter: Danny Yates <danny>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3    
Version: 3.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Danny Yates CLA 2006-02-22 07:23:06 EST
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.
Comment 1 Olivier Thomann CLA 2006-02-22 08:07:06 EST

*** This bug has been marked as a duplicate of 128962 ***