Bug 221473 - [config] ConfigurationImpl contains broken equals() method
Summary: [config] ConfigurationImpl contains broken equals() method
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Compendium (show other bugs)
Version: 3.4   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: equinox.compendium-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2008-03-05 04:29 EST by Neil Bartlett CLA
Modified: 2008-03-05 11:29 EST (History)
1 user (show)

See Also:


Attachments
patch (760 bytes, patch)
2008-03-05 04:29 EST, Neil Bartlett CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Neil Bartlett CLA 2008-03-05 04:29:39 EST
Created attachment 91623 [details]
patch

In org.eclipse.equinox.cm, ConfigurationImpl breaks the contract for Object.equals(). The implementation is as follows:

   return pid.equals(((Configuration) obj).getPid());

Which will throw a ClassCastException when the obj parameter is not an instance of Configuration, causing problems if these objects are used in a collection or a JFace viewer etc. It should simply return false, eg:

   return (obj instanceof Configuration)
      && pid.equals(((Configuration) obj).getPid());


Regards,
Neil
Comment 1 Simon Kaegi CLA 2008-03-05 09:09:47 EST
Thanks Neil. You're right.
I'll rerun tests and apply later on today.
Comment 2 Simon Kaegi CLA 2008-03-05 11:29:39 EST
Fixed in HEAD.