Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 202095

Summary: Linked resources are not found when device id of location is lower case
Product: [Eclipse Project] Platform Reporter: Gerhard Schaber <gerhard.schaber>
Component: ResourcesAssignee: Szymon Brandys <Szymon.Brandys>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: eclipse, john.arthorne, martin.gutschelhofer, mober.at+eclipse, Szymon.Brandys, tomasz.zarna, wbprio
Version: 3.3Flags: john.arthorne: review+
Target Milestone: 3.4 M2   
Hardware: PC   
OS: Windows XP   
Whiteboard: hasPatch
Attachments:
Description Flags
Fix
none
Updated patch
none
Extra tests none

Description Gerhard Schaber CLA 2007-09-03 12:55:30 EDT
Build ID: I20070323-1616

Steps To Reproduce:
1. Create a project
2. Create a linked folder with a variable
3. Set the value (location) of the variable to c:\temp (use lower case for c:\)
4. Try to lookup the linked folder using ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(new Path("c:/temp"))

The resource cannot be found, because of FileSystemResourceManager.allPathsForLocation. location has always an upper case device id.




More information:
A solution could be to insert the following line at line 86 (right before relative = testLocation.relativize(location)):
   testLocation = FileUtil.canonicalURI(testLocation);
Comment 1 Martin Oberhuber CLA 2007-09-04 04:20:09 EDT
What if org.eclipse.core.runtime.Path#canonicalize() always pushed the device id to uppercase, when running on Windows?
Comment 2 John Arthorne CLA 2007-09-04 16:49:19 EDT
The general strategy in resources (in cases where paths are going to be compared) is to convert paths to canonical form as they cross the API boundary (see bug 119705). This is done for the path parameter in the findFilesForLocation method. It looks like we missed IPathVariableManager#setValue, which should also convert to canonical form.  I don't like the idea of changing the case sensitivity of Path, since Path is used in situations that are always case-sensitive, even when the underlying local file system is not.
Comment 3 Szymon Brandys CLA 2007-09-11 09:24:59 EDT
Created attachment 78058 [details]
Fix
Comment 4 John Arthorne CLA 2007-09-11 09:44:11 EDT
Thanks for the patch Szymon, do you have a JUnit for it? I believe IWorkspaceRootTest has some tests like this.
Comment 5 John Arthorne CLA 2007-09-11 13:15:32 EDT
I just released some fixes to IPathVariableManagerTest that were broken by the fix, but if you could add a couple of new tests that would be great.
Comment 6 John Arthorne CLA 2007-09-11 13:17:07 EDT
Created attachment 78081 [details]
Updated patch

Your fix looks good. However, there is a line near the top of the method that is no longer necessary if we are doing the canonicalization. Here is a small update to your patch.
Comment 7 John Arthorne CLA 2007-09-11 13:21:45 EDT
Patch released.
Comment 8 Szymon Brandys CLA 2007-09-12 09:38:45 EDT
Created attachment 78178 [details]
Extra tests
Comment 9 Martin Oberhuber CLA 2007-09-12 10:08:40 EDT
Could this bug also be a candidate for going into 3.3.1 ?

For our commercial product, it would help us live without a questionable workaround on the client side, that's unsure whether it works in all situations.
Comment 10 John Arthorne CLA 2007-09-12 10:17:50 EDT
Martin, it would have been possible, but the hopefully final 3.3.1 build is occurring as I write this:

http://www.eclipse.org/eclipse/development/freeze_plan_3_3_1.html

How about 3.3.2?
Comment 11 John Arthorne CLA 2007-09-12 10:55:33 EDT
Extra tests released.
Comment 12 John Arthorne CLA 2007-09-13 10:48:04 EDT
This fix caused test failures on Mac (bug 203251), because the fix also causes symlinks in path variable values to be resolved. It's a good thing we didn't release to 3.3.x, because this may have other unwanted side-effects for clients. 
Comment 13 Tomasz Zarna CLA 2007-09-19 08:26:48 EDT
Verified in I20070917-0010.