Bug 151022 - ResourceException in buffer.save()
Summary: ResourceException in buffer.save()
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.6 M1   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-07-18 19:16 EDT by Roberto Scaramuzzi CLA
Modified: 2009-08-04 08:45 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Roberto Scaramuzzi CLA 2006-07-18 19:16:45 EDT
The following code throws a ResourceException when the default encoding is UTF-8 (for example on Fedora Core Linux 4 and 5)

ICompilationUnit unit = a compilation unit corresponding to a file that does not exist
ICompilationUnit working_copy = (ICompilationUnit) unit.getWorkingCopy (
            null, null, null);
IBuffer buffer = working_copy.getBuffer();
buffer.setContents("blah blah");
buffer.save(null, true);

This throws a ResourceException at Buffer.java line 361
The problem is that IFile.getContentDescription throws the exception when the file does not exist.

The obvious fix is to skip the enclosing if block if the file does not exist, but the if block is there to fix another bug, so I am not sure if this is the right fix.
Comment 1 Olivier Thomann CLA 2009-06-25 14:24:52 EDT
Should not you create the unit instead of creating a working copy on a unit that doesn't have an underlying file?
For me this looks like it works as expected.
Closing as INVALID.
Please reopen if I misunderstood what you want to do.
Comment 2 Frederic Fusier CLA 2009-08-04 08:45:16 EDT
Verified for 3.6M1