Bug 140950 - EFS URI comparison problem
Summary: EFS URI comparison problem
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 3.2   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.3 M1   Edit
Assignee: John Arthorne CLA
QA Contact:
URL:
Whiteboard:
Keywords: core
Depends on:
Blocks:
 
Reported: 2006-05-09 18:07 EDT by Tianchao Li CLA
Modified: 2006-06-12 17:15 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tianchao Li CLA 2006-05-09 18:07:44 EDT
The current implementation delegates the comparison of two URI to the FileStore:
	public static boolean equals(URI one, URI two) {
		try {
			return EFS.getStore(one).equals(EFS.getStore(two));
		} catch (CoreException e) {
			// fall back to default equality test
			return one.equals(two);
		}
	}
However, this only works if the FileStore has a custom implementation of equals(), otherwise the Object.equals() will be called:
    public boolean equals(Object obj) {
	return (this == obj);
    }

This will return false even if the two URI are equal!
It seems that there are specific reasons for URIUtil.equals() to delegate its work to FileStore, so FileStore be specified that an equal() method must be implemented.
Comment 1 John Arthorne CLA 2006-05-10 15:24:06 EDT
Darn, I thought I had written a default equals implementation for the base FileStore class. This should be fixed for the next release.
Comment 2 John Arthorne CLA 2006-05-10 15:27:22 EDT
Note: this method was added because URI.equals(...) frequently does not provide the desired behaviour.  The main examples:

file://home/foo  is not equal to file://home/foo/ (trailing slash added)
file://d:\home\foo is not equal to file://D:\home\foo (device case is changed)
Comment 3 John Arthorne CLA 2006-06-05 15:17:09 EDT
A default equals implementation should be added to FileStore for 3.3.
Comment 4 John Arthorne CLA 2006-06-06 10:19:55 EDT
Fix released.
Comment 5 John Arthorne CLA 2006-06-12 17:15:53 EDT
Moving to new M1 milestone