Bug 405663 - [compiler][resource] leak at re-assignment no longer detected
Summary: [compiler][resource] leak at re-assignment no longer detected
Status: CLOSED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.3   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2013-04-13 03:59 EDT by Stephan Herrmann CLA
Modified: 2020-06-05 18:25 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stephan Herrmann CLA 2013-04-13 03:59:11 EDT
The following leak is correctly detected up-to 4.3 M1 but not with M2+

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class Bla {

    public static void bla(Connection c) {
        PreparedStatement stmt = null;
        try {
            stmt = c.prepareStatement("SELECT Bla"); // expect warning here
//            stmt.close();

            stmt = c.prepareStatement("SELECT Bli");
            stmt.close();

        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } finally {
            if( stmt != null ) {
                try {
                    stmt.close();
                } catch (SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
    }
}

Note that this test requires a JRE 7+ to consider PreparedStatement as
a resource.
Comment 1 Stephan Herrmann CLA 2013-04-13 04:00:13 EDT
I'll try to fix this regression in time for Kepler.
Comment 2 Stephan Herrmann CLA 2013-04-13 04:18:30 EDT
Regression is caused by the fix for bug 388996.

Out-of-order analysis of finally before try block gets the analysis
confused here, or more precisely: attempts to cope with this out-of-order
analysis from bug 388996 are over eager.
Comment 3 Stephan Herrmann CLA 2013-04-30 08:52:53 EDT
I didn't find the time to fix this for Kepler.
Comment 4 Stephan Herrmann CLA 2014-04-12 09:16:23 EDT
Java 8 work had priority during 4.4, deferring to 4.5
Comment 5 Stephan Herrmann CLA 2016-03-25 10:30:56 EDT
Too much on my plate for 4.6. Bulk deferral to 4.7
Comment 6 Stephan Herrmann CLA 2017-05-16 12:05:35 EDT
Ran out of time for 4.7. Bulk move to 4.8.
Comment 7 Manoj N Palat CLA 2018-05-16 12:56:21 EDT
bulk move out of 4.8