Summary: | Java Model Exception from org.eclipse.jdt.internal.core.Buffer.save(Buffer.javga:361) | ||||||
---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Jack Fong <jackfong> | ||||
Component: | Core | Assignee: | Jerome Lanneluc <jerome_lanneluc> | ||||
Status: | VERIFIED FIXED | QA Contact: | |||||
Severity: | blocker | ||||||
Priority: | P3 | CC: | david_audel, jpitman, Olivier_Thomann, philippe_mulet, thomas | ||||
Version: | 3.4 | Flags: | philippe_mulet:
review+
frederic_fusier: review+ david_audel: review+ |
||||
Target Milestone: | 3.4 RC3 | ||||||
Hardware: | PC | ||||||
OS: | Linux | ||||||
Whiteboard: | |||||||
Attachments: |
|
Description
Jack Fong
2008-05-28 02:49:26 EDT
Reassigning to jdt-core-inbox since I don't think this is in any way related to the spaces project. Looking at the trace, it appears that it is impossible to get in this situation since Openable.save(...) first acquires a buffer which ensures that the file exists. In fact, this can happen if a race condition occurs: the file is deleted after the buffer is acquired, and thus the Buffer.save(...) operation fails if the encoding is "UTF-8". I was able to confirm this behavior on Jack's machine. I entered bug 234551 to capture the race condition issue. However one can see this issue by using IBuffer.save(...) directly. The following snippet shows the problem: IBuffer buffer = (new WorkingCopyOwner() {}).createBuffer( getCompilationUnit("/P/X234307.java")); buffer.setContents( "public class X234307 {\n" + "}" ); IProject project = getProject("P"); String defaultCharset = project.getDefaultCharset(); try { project.setDefaultCharset("UTF-8", null); String newContents = "public interface X234307 {\n" + "}"; buffer.setContents(newContents); buffer.save(null, false/*don't force*/); char[] contents = Util.getFileCharContent( getFile("/P/X234307.java").getLocation().toFile(), null); assertSourceEquals("Unexpected source", newContents, new String(contents)); } finally { deleteBuffer(buffer); // this deletes the file as well project.setDefaultCharset(defaultCharset, null); } Since there is no workaround, and the reporter marked the bug as blocker we should fix this bug for 3.4RC3 Created attachment 102594 [details]
Proposed fix and regression test
Philippe, Frederic, David, can you please approve/review? Patch looks good: +1 Patch looks good: +1 +1 for 3.4rc3 Fix and test released for 3.4RC3 Tested patch and it is good. Thank you Jerome. Verified for 3.4RC4. The copyright was not updated! |