Bug 433636 - Bug_233939.testMultipleLinksToFolder() throws NPE when executed with Java 7 fragment
Summary: Bug_233939.testMultipleLinksToFolder() throws NPE when executed with Java 7 f...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 4.4   Edit
Hardware: All Windows 7
: P3 normal (vote)
Target Milestone: 4.4 M7   Edit
Assignee: Szymon Ptaszkiewicz CLA
QA Contact:
URL:
Whiteboard:
Keywords: test
Depends on: 380325
Blocks:
  Show dependency tree
 
Reported: 2014-04-28 06:01 EDT by Szymon Ptaszkiewicz CLA
Modified: 2014-04-30 06:15 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Szymon Ptaszkiewicz CLA 2014-04-28 06:01:46 EDT
When running Bug_233939.testMultipleLinksToFolder() with Java 7 fragment on Windows 7 with admin privileges (the test needs to be enabled by commenting out isWindowsVistaOrHigher() at the beginning of the test), the test fails because of NPE:

java.lang.NullPointerException
	at org.eclipse.core.tests.resources.ResourceTest.existsInWorkspace(ResourceTest.java:701)
	at org.eclipse.core.tests.resources.ResourceTest.assertExistsInWorkspace(ResourceTest.java:317)
	at org.eclipse.core.tests.resources.ResourceTest.assertExistsInWorkspace(ResourceTest.java:309)
	at org.eclipse.core.tests.resources.regression.Bug_233939.symLinkAndRefresh(Bug_233939.java:55)
	at org.eclipse.core.tests.resources.regression.Bug_233939.testMultipleLinksToFolder(Bug_233939.java:130)
	...
Comment 1 Szymon Ptaszkiewicz CLA 2014-04-28 06:54:55 EDT
The test can be fixed in DosHandler by using Files.exists(path, LinkOption.NOFOLLOW_LINKS) to correctly check the existence of the link instead of the link target. At the moment, the existence of the link is checked by Files.exists(path) which by default follows symbolic links. This seems to be wrong because we are interested in the existence of the link not the link target, but since the test passes on Linux, it needs more investigation to understand the difference.
Comment 2 Szymon Ptaszkiewicz CLA 2014-04-29 10:35:09 EDT
Interestingly, when asked about the existence of the link, Linux native fragment answers by checking the existence of the link target. This results in a situation where symbolic links pointing at non-existing files/folders are not shown in Eclipse which is surprising, at least for me. Windows native fragment shows such links but they are not usable so it behaves in the same way as Windows Explorer. Martin, do you know if the Linux native fragment works correctly here?
Comment 3 Szymon Ptaszkiewicz CLA 2014-04-29 11:03:05 EDT
Steps to reproduce the bug manually:
1. Create a project.
2. Create a folder in the project.
3. Create a symbolic link in the folder pointing at non-existing folder.
4. Refresh the project and expand all nodes.
=> The symbolic link is not shown at all when using Java 7 fragment but is shown when using Windows native fragment.
Comment 5 Martin Oberhuber CLA 2014-04-29 12:03:18 EDT
(In reply to Szymon Ptaszkiewicz from comment #2)
> Interestingly, when asked about the existence of the link, Linux native
> fragment answers by checking the existence of the link target.

Yes, I think it works correctly because the IFileInfo#exists() API had to retain the behavior that was originally observed from java.io.File#exists() before the native fragments were added. java.io.File#exists() would also return false for symlinks pointing to nowhere.

In general, java.io.File would always follow symbolic links, and the EFS implementation (and therefore Eclipse Resource system) mostly resembles that concept.
Comment 6 Szymon Ptaszkiewicz CLA 2014-04-29 12:10:34 EDT
(In reply to Martin Oberhuber from comment #5)
> (In reply to Szymon Ptaszkiewicz from comment #2)
> > Interestingly, when asked about the existence of the link, Linux native
> > fragment answers by checking the existence of the link target.
> 
> Yes, I think it works correctly because the IFileInfo#exists() API had to
> retain the behavior that was originally observed from java.io.File#exists()
> before the native fragments were added. java.io.File#exists() would also
> return false for symlinks pointing to nowhere.
> 
> In general, java.io.File would always follow symbolic links, and the EFS
> implementation (and therefore Eclipse Resource system) mostly resembles that
> concept.

Thank you for clarification.
Comment 7 Szymon Ptaszkiewicz CLA 2014-04-30 06:15:37 EDT
Verified in I20140429-2000.