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

Bug 370701

Summary: Resource leak warning should be 'potential' if reader/writer is passed
Product: [Eclipse Project] JDT Reporter: Dani Megert <daniel_megert>
Component: CoreAssignee: Stephan Herrmann <stephan.herrmann>
Status: VERIFIED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: srikanth_sankaran, stephan.herrmann
Version: 3.8   
Target Milestone: 3.8 M6   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Dani Megert CLA 2012-02-06 06:07:18 EST
3.8 M5.

See org.eclipse.jdt.internal.ui.util.JavadocHelpContext.retrieveText(IJavaElement)

    reader= new HTML2TextReader(reader, null);

Adding
    reader.close()
does not get rid of the problem. I would expect that this would now only be reported as potential problem since normally, if a Writer/Reader takes another reader, the close() ripples through.
Comment 1 Stephan Herrmann CLA 2012-02-06 19:51:10 EST
Had we based bug 358903 on a general heuristic it would be exactly as
you expected. However, the agreement in bug 358903 comment 10 was to use
explicit white lists. HTML2TextReader is not on our white list,
so all the compiler sees is:
- reader is passed to some constructor, so the fresh object may / may not
  take over the responsibility
- the assignment drops the binding to the first reader so at this
  point we no longer have a direct reference

Ergo: we rank it equally to, e.g., this snippet:

   other.readSome(reader);
   return;

Do you still want this (as an enhancement)? If so, based on which heuristic,
exactly? Or can we close as WONTFIX?
Comment 2 Dani Megert CLA 2012-02-07 02:17:48 EST
(In reply to comment #1)
Fair enough.