Bug 163782

Summary: Possible resource leaks
Product: [Eclipse Project] JDT Reporter: Roman Arkhangelskiy <rarkhangelskiy>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.3   
Target Milestone: 3.3 M4   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Roman Arkhangelskiy CLA 2006-11-08 05:21:53 EST
I have been running Jtest's BugDetective feature on Eclipse source code (build
of 29.10.2006) and it reported several possible resource leaks:

in org.eclipse.jdt.internal.compiler.parser.Parser:
1. writer.close() at line 231 will not be executed if an exception is thrown at line 230 (call to flush());
2. The same is with stream.close():429, which will not be reached if stream.write(bytes):428 thrown an exception;
3. stream.close():442 - the same problem.

in org.eclipse.jdt.internal.compiler.ClassFile:
output.close():383 will not be reached if the previous line (call to flush()) throws an exception;

Please let me know if this is a real problem or BugDetective is mistaken.

Thank you!
Comment 1 Olivier Thomann CLA 2006-11-08 10:57:17 EST
Released for 3.3M4.
Yes, they were potential resource leaks, but the methods in the Parser are not used directly inside Eclipse. They are used to generate the resource files of the Parser.
I changed the code in the ClassFile to be sure that output.close() is called. If it raised an IOException, the same handling is done.
Comment 2 Olivier Thomann CLA 2006-11-08 10:59:04 EST
Could you please try again on the code in HEAD and let me know if the same problems are found?
Comment 3 Roman Arkhangelskiy CLA 2006-11-09 04:23:17 EST
I have done it as you requested and happy to report that this time no resource leaks have been found. Thank you!
Comment 4 Frederic Fusier CLA 2006-12-13 03:27:44 EST
Verified for 3.3 M4 by reporter