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

Bug 342093

Summary: FilterDescription#compareTo can throw a ClassCastException
Product: [Eclipse Project] Platform Reporter: Marco Massenzio <mmassenzio>
Component: ResourcesAssignee: Platform-Resources-Inbox <platform-resources-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Szymon.Brandys
Version: 4.1   
Target Milestone: 3.7   
Hardware: All   
OS: All   
Whiteboard:

Description Marco Massenzio CLA 2011-04-06 20:27:35 EDT
Build Identifier: M20100909-0800

The cast in compareTo is not protected by a test on instanceof:

public int compareTo(Object o) {
		FilterDescription that = (FilterDescription) o;
		IPath path1 = this.getResource().getProjectRelativePath();
// ...
}

hence, if we compare a FilterDescription object to something other another FilterDescription, a ClassCastException will be thrown.

Reproducible: Always

Steps to Reproduce:
1. create a new FileDescription fd
2. execute fd.compareTo(new Foo());
3. ClassCastException is thrown
Comment 1 Szymon Brandys CLA 2011-08-16 05:54:44 EDT
It was fixed in 3.7.