Bug 128963 - [compiler] null reference analysis: incorrect analysis
Summary: [compiler] null reference analysis: incorrect analysis
Status: RESOLVED DUPLICATE of bug 128962
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-22 07:23 EST by Danny Yates CLA
Modified: 2006-02-22 08:07 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 ***