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

Bug 367482

Summary: Resource leak in ProcessHelper.copyBinaryFile may cause 'too many files opened' error
Product: [Tools] CDT Reporter: Raphael Zulliger <zulliger>
Component: cdt-coreAssignee: Sergey Prigogin <eclipse.sprigogin>
Status: RESOLVED FIXED QA Contact: Doug Schaefer <cdtdoug>
Severity: normal    
Priority: P3 CC: eclipse.sprigogin
Version: 8.1.0   
Target Milestone: 8.0.2   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Proposed fix cdtdoug: iplog+

Description Raphael Zulliger CLA 2011-12-23 03:50:57 EST
Build Identifier: 20110615-0604

In ProcessHelper.copyBinaryFile, the call to close() is missing for FileInputStream and FileOutputStream objects. This may cause "real problems" if this function is used to copy many files. In our case, we use the function in the "new project" context where we have to copy several hundred files.

Funnily, on Windows, no error occurs. I guess Windows can handle more opened files than my Ubuntu Linux can (by default).

Reproducible: Always

Steps to Reproduce:
1. Program a for-loop copying files using the mentioned function
2. Make sure to copy several hundred (e.g ~2000) files
3. The mentioned resource error will occur
Comment 1 Raphael Zulliger CLA 2011-12-23 03:57:25 EST
Created attachment 208765 [details]
Proposed fix
Comment 2 Sergey Prigogin CLA 2011-12-23 19:50:30 EST
Patch applied to cdt_8_0 and master.