Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 512257

Summary: [compiler][resource] bogus resource leak warning with return in lambda
Product: [Eclipse Project] JDT Reporter: Ahmed Ashour <asashour>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED WONTFIX QA Contact: Stephan Herrmann <stephan.herrmann>
Severity: normal    
Priority: P3 CC: jarthana
Version: 4.6   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard: stalebug

Description Ahmed Ashour CLA 2017-02-15 16:13:54 EST
Build ID: 20161208-0600

The below code:


public class SomeTest {

    public void test() throws FileNotFoundException {
        SomeTest someTest = new SomeTest();
        InputStream is = new FileInputStream(".");
        someTest.addListener(() -> {
            return ""; // Resource leak: 'is' is not closed at this location
        });
        someTest.setConnection(is);
    }

    void setConnection(InputStream c) {
    }

    void addListener(Listener l) {
    }

    static interface Listener {
        String test();
    }
}



gives an incorrect Resource Leak warning in the line mentioned.

If you for example, comment the "someTest.setConnection(is);", then the warning is gone
Comment 1 Eclipse Genie CLA 2020-02-18 04:54:44 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.