Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 342093 - FilterDescription#compareTo can throw a ClassCastException
Summary: FilterDescription#compareTo can throw a ClassCastException
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 4.1   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.7   Edit
Assignee: Platform-Resources-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-06 20:27 EDT by Marco Massenzio CLA
Modified: 2011-08-16 05:54 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.