Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 379193 - Eclipse doesn't distinguish between I/O errors and deleted files
Summary: Eclipse doesn't distinguish between I/O errors and deleted files
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 3.7.2   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.3 M4   Edit
Assignee: Sergey Prigogin CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-10 21:32 EDT by Sergey Prigogin CLA
Modified: 2013-01-16 14:45 EST (History)
5 users (show)

See Also:
john.arthorne: review? (john.arthorne)


Attachments
Proposed fix (7.89 KB, patch)
2012-05-11 21:20 EDT, Sergey Prigogin CLA
no flags Details | Diff
Proposed fix (8.11 KB, patch)
2012-05-13 21:59 EDT, Sergey Prigogin CLA
no flags Details | Diff
Proposed fix (10.67 KB, patch)
2012-07-02 01:24 EDT, Sergey Prigogin CLA
eclipse.sprigogin: review?
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sergey Prigogin CLA 2012-05-10 21:32:50 EDT
Consider the following scenario:
A project, which is located on a local disk, contains a linked folder that maps to a directory on NFS. Eclipse has few editors open on resources corresponding to NFS files. User leaves Eclipse up for the weekend. Eclipse looses access to NFS due to expiration of the Kerberos ticket. When Eclipse refreshes its resources by periodic polling, it thinks that the files and directories on NFS have been deleted. Eclipse removes the corresponding resources and closes all editors associated with the removed resources. When the user comes to work on Monday and renews the Kerberos ticket, the state of open editors that Eclipse had on Friday is lost.

CDT projects suffer even more since they react to the resource delta by removing the corresponding files from the index. Restoring the original state of the index is a lengthy operation.

The root cause of the problem is that org.eclipse.core.internal.filesystem.local.unix.UnixFileNatives.fetchFileInfo(String) does not distinguish between nonexistent files and I/O errors. Furthermore, the current IFileStore/IFileInfo API doesn't allow for such distinction.
Comment 1 Sergey Prigogin CLA 2012-05-11 21:20:07 EDT
Created attachment 215514 [details]
Proposed fix

Could please somebody review the attached proposed fix. The patch is intended for post-Juno and doesn't yet include changes to the native Windows code. If you agree with the general approach, I can add the missing Windows part.
Comment 2 Sergey Prigogin CLA 2012-05-13 21:59:27 EDT
Created attachment 215544 [details]
Proposed fix

Fixed an error that was introduced when creating the previous patch.
Comment 3 John Arthorne CLA 2012-05-15 16:58:19 EDT
Did you explore the idea that exists() should return true in the case of an error? Can you check what java.io.File#exists does in this case? What about a bash script test like if [ -e $file ]. Generally being consistent with native tools on that platform is the best answer.
Comment 4 Sergey Prigogin CLA 2012-05-15 17:24:01 EDT
(In reply to comment #3)
> Did you explore the idea that exists() should return true in the case of an
> error?
This would be a deviation from java.io.File semantics (see below).

> Can you check what java.io.File#exists does in this case?

java.io.File returns false in case of errors although the Javadoc doesn't explicitly say that.

in Java 1.7
java.nio.file.Files.exists(Path, LinkOption...) returns {@code true} if the file exists; {@code false} if the file does not exist or its existence cannot be determined.
java.nio.file.Files.notExists(Path, LinkOption...) returns {@code true} if the file does not exist; {@code false} if the file exists or its existence cannot be determined

> What about a
> bash script test like if [ -e $file ]. Generally being consistent with native
> tools on that platform is the best answer.

Agree. -e $file also returns false in case of error.
Comment 5 Sergey Prigogin CLA 2012-05-22 15:27:13 EDT
John, could you please give your blessing to the general approach taken in the patch. I would then add the native Windows code and push the updated patch to Gerrit.
Comment 6 Sergey Prigogin CLA 2012-07-02 01:24:40 EDT
Created attachment 218138 [details]
Proposed fix

This is a complete set of changes including native code for Windows and a prebuilt Win32 localfile_1_0_0.dll. Two remaining dlls for other Windows architectures have to be built by somebody who has access to the appropriate machines. John, I'll appreciate if you can review the patch. Thanks.
Comment 7 Szymon Brandys CLA 2012-07-03 03:54:25 EDT
Hi Sergey, could you push the fix to https://git.eclipse.org/r/p/platform/eclipse.platform.resources.git, please? Thanks
Comment 8 Sergey Prigogin CLA 2012-07-03 13:50:38 EDT
(In reply to comment #7)
> Hi Sergey, could you push the fix to
> https://git.eclipse.org/r/p/platform/eclipse.platform.resources.git, please?
> Thanks

Done: https://git.eclipse.org/r/6599
Comment 9 Szymon Brandys CLA 2012-09-11 07:59:00 EDT
(In reply to comment #8)
> (In reply to comment #7)
> > Hi Sergey, could you push the fix to
> > https://git.eclipse.org/r/p/platform/eclipse.platform.resources.git, please?
> > Thanks
> 
> Done: https://git.eclipse.org/r/6599

The patch looks good in general. You need to update version in pom.xml to 1.4.0. It would be also nice to have test cases for the new thing.
Comment 10 John Arthorne CLA 2012-09-11 09:42:22 EDT
I like the idea. One suggest is to change the boolean hasError to something with an int return value (maybe getError). For now it could just return something generic like IO_ERROR or NONE, but this would allow us in the future to expand this to expose different kinds of errors (like errno in the unix stat function).
Comment 11 Szymon Brandys CLA 2012-09-11 11:21:09 EDT
(In reply to comment #10)
> I like the idea. One suggest is to change the boolean hasError to something
> with an int return value (maybe getError). For now it could just return
> something generic like IO_ERROR or NONE, but this would allow us in the
> future to expand this to expose different kinds of errors (like errno in the
> unix stat function).

Feel free to open a separate bug for tests, we can release them in a separate commit. When you do the change to pom.xml and to hasError (as per John's suggestion), please push the new fix to gerrit again.
Comment 12 Sergey Prigogin CLA 2012-09-11 16:17:28 EDT
(In reply to comment #11)
An updated patch has been pushed to Gerrit. This patch includes pom.xml file that I missed last time (my apology for that) and IFileInfo.getError method as John suggested. I'd be glad to add tests but could quite figure out how to simulate file errors. Any ideas for how to do that will be appreciated. I've created bug 389337 to track test creation.
Comment 13 John Arthorne CLA 2012-09-26 15:53:26 EDT
This fix looks good to me. Two small things:

 - FileInfo.setError still takes a boolean, even though getError returns an int. Seems like we should make this consistent.
 - Can you provide compiled win64 dll as well?
Comment 14 Sergey Prigogin CLA 2012-09-27 09:59:05 EDT
(In reply to comment #13)
I'm on currently on vacation and will make the requested changes when I come back in mid October. I won't be able to compile for win64 since I don't have access to such machine.
Comment 15 Dani Megert CLA 2012-10-05 04:54:14 EDT
(In reply to comment #13)
> This fix looks good to me. Two small things:
> 
>  - FileInfo.setError still takes a boolean, even though getError returns an
> int. Seems like we should make this consistent.
>  - Can you provide compiled win64 dll as well?

This fix is not good. On Windows 7 32-bit I now get a log entry each time I start (see below). Yes, I know, the entry says something about "may not be an error", but how can I know? Why log it then in the first place? This log entry has to go away again and only be logged if it is really missing on a platform where it is expected to exist.


!ENTRY org.eclipse.core.filesystem 1 1 2012-10-05 10:48:20.646
!MESSAGE Could not load library: localfile_1_0_0.dll.  This library provides platform-specific optimizations for certain file system operations.  This library is not present on all platforms, so this may not be an error.  The resources plug-in will safely fall back to using java.io.File functionality.
!STACK 0
java.lang.UnsatisfiedLinkError: C:\eclipse\drops\4.3-N20121004-2000\configuration\org.eclipse.osgi\bundles\40\1\.cp\os\win32\x86\localfile_1_0_0.dll: Can't load this .dll (machine code=0xbd) on a IA 32-bit platform
Comment 16 Dani Megert CLA 2012-10-05 05:22:25 EDT
John, it would be good to mention in the bug report when a fix gets pushed to the shared repository. When I looked at
http://git.eclipse.org/c/platform/eclipse.platform.resources.git/
I was first quite confused to see a 9 day old fix not being part of this weeks I-build. I assume you committed it locally and then for some reason decided to push it only one week later.
Comment 17 Szymon Brandys CLA 2012-10-05 10:20:19 EDT
(In reply to comment #15)
> (In reply to comment #13)
> > This fix looks good to me. Two small things:
> > 
> >  - FileInfo.setError still takes a boolean, even though getError returns an
> > int. Seems like we should make this consistent.
> >  - Can you provide compiled win64 dll as well?
> 
> This fix is not good. On Windows 7 32-bit I now get a log entry each time I...

The new dll does not load and we lost functionality on win32.x86. Sergey was asked to provide win.x64 dll, so I would expect he will fix x32 dll in the same time. He is back in mid Oct. Till then, I think we can rollback to the previous version of dll.
Comment 18 John Arthorne CLA 2012-10-05 10:27:52 EDT
I never intended to push this. I cherry-picked Sergey's patch last week in order to test it. It wasn't ready yet, so I gave some comments here and left it. I should have reverted my local master but I forgot. Yesterday I made a completely unrelated change and pushed, and missed that this cherry-picked commit was still in my local master. I messed up here and I have reverted it:

http://git.eclipse.org/c/platform/eclipse.platform.resources.git/commit/?id=b4719f7c958d562ea2138c6493a6a7e057194507
Comment 19 Szymon Brandys CLA 2012-10-31 10:00:32 EDT
We are mostly done with M3, moving to M4.
Comment 20 Sergey Prigogin CLA 2012-11-07 00:34:03 EST
(In reply to comment #13)
Uploaded an updated patch to https://git.eclipse.org/r/#/c/6599/. Please review.
Comment 21 John Arthorne CLA 2012-11-09 16:11:22 EST
This latest patch looks good to me. We just need to track down a win64 machine with compiler license to create a binary there.

The org.eclipse.core.filesystem bundle version needs a minor increment for the new API. No need to submit a new patchset for that Sergey, we can just make the change locally in manifest and pom.
Comment 22 Szymon Brandys CLA 2012-11-12 09:00:14 EST
The latest patch is merged to master. I built the lib for win32.x86_64 and will build for ia64 tomorrow. Then I will close the bug. Thanks Sergey.
Comment 23 Sergey Prigogin CLA 2012-11-12 12:59:06 EST
Thanks a lot!
Comment 24 Sergey Prigogin CLA 2013-01-16 14:37:36 EST
Should this bug be marked as fixed?
Comment 25 John Arthorne CLA 2013-01-16 14:45:17 EST
Yes this was in M4.