Community
Participate
Working Groups
Build ID: eclipse-SDK-3.4RC1 Steps To Reproduce: 1. 2. 3. More information: I'm only getting this exception on the linux platform. My program works fine in Windows. Please take a look at this exception: Java Model Exception: Core Exception [code 368] Resource '/TestFile.java' does not exist. at org.eclipse.jdt.internal.core.Buffer.save(Buffer.java:384) at org.eclipse.jdt.internal.core.Openable.save(Openable.java:480) at org.eclipse.jdt.internal.core.CompilationUnit.save(CompilationUnit.java:1270) at foo.DumpApplication.externalize(DumpApplication.java:123) Caused by: org.eclipse.core.internal.resources.ResourceException: Resource '/TestFile.java' does not exist. at org.eclipse.core.internal.resources.Resource.checkExists(Resource.java:317) at org.eclipse.core.internal.resources.Resource.checkAccessible(Resource .java:194) at org.eclipse.core.internal.resources.File.getContentDescription(File.java:277) at org.eclipse.jdt.internal.core.Buffer.save(Buffer.java:361) at org.eclipse.jdt.internal.core.Openable.save(Openable.java:480) at org.eclipse.jdt.internal.core.CompilationUnit.save(CompilationUnit.java:1270) at foo.DumpApplication.externalize(DumpApplication.java:123) When I debug into JDT Buffer.java, I found that at line 361, we should only call: IContentDescription description = this.file.getContentDescription(); if this.file.exists() == true similar to line 373.
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
+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!