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

Bug 333660

Summary: [implementation] FileStoreTextFileBuffer eats IOException on external file save
Product: [Eclipse Project] Platform Reporter: James Blackburn <jamesblackburn+eclipse>
Component: TextAssignee: Dani Megert <daniel_megert>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, remy.suen
Version: 3.7   
Target Milestone: 3.7 M5   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
potential fix
none
further fix daniel_megert: iplog+, daniel_megert: review+

Description James Blackburn CLA 2011-01-06 10:26:34 EST
Created attachment 186172 [details]
potential fix

FileStoreTextFileBuffer.java seems to incorrectly handle IOExceptions.

- If the file exists, #setFileContents is called. This method eats all IOExceptions.
- If the file doesn't exist the IOException is eaten on close() (can lead to a similar issue as described in Bug 332543)

Potential patch for the issue.  Make #setFileContents throw IOException and commitFileBufferContent re-throws the IOException as a CoreException. 

Existing tests in FileBuffersTestSuite pass.
Comment 1 Dani Megert CLA 2011-01-07 03:42:34 EST
Fixed without using the patch (FileStoreTextFileBuffer.java rev. 1.12).
Available in builds >= N20110107-2000.
Comment 2 James Blackburn CLA 2011-01-07 04:26:51 EST
Created attachment 186252 [details]
further fix

Thanks Dani.  

Unfortunately your fix still suffers from the issue in Bug 332543. You need to explicitly close() the outputstreams without disregarding the IOException, as some filesystems defer errors to close rather than on write.
Comment 3 James Blackburn CLA 2011-01-07 04:28:43 EST
Issue still exists on close()
Comment 4 Dani Megert CLA 2011-01-11 08:33:21 EST
Thanks James. Committed the patch to HEAD with the following addition to the copyright notice:
James Blackburn <jamesblackburn+eclipse@gmail.com> - [implementation] FileStoreTextFileBuffer eats IOException on external file save - https://bugs.eclipse.org/333660
Comment 5 Dani Megert CLA 2011-01-25 10:39:47 EST
Verified in I20110124-1800 through code inspection.