Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 345819 - TaskRepository breaks the hashcode/equels contract!
Summary: TaskRepository breaks the hashcode/equels contract!
Status: RESOLVED WORKSFORME
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Mylyn (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows 7
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Mylyn Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-14 14:09 EDT by elhanan Maayan CLA
Modified: 2011-05-15 07:43 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 elhanan Maayan CLA 2011-05-14 14:09:49 EDT
hi..
in my attempt to decipher why TaskRepository does not persist well in my view i noticed that it's hash code implementation differs from the equels one,
meaning the hashcode only refers to the connector kind attribute while equels refers to both connector kind AND url. 

i saw no documentation, explaining this , which means the objects with the same hashcode may not be equel
Comment 1 Steffen Pingel CLA 2011-05-15 07:43:45 EDT
I believe the implementation is correct. Please take a look at the contract for hashCode(). Basically if equals returns true for two Objects, the value returned by hashCode() must also be the same. The implementation in TaskRepository meets that contract. If two objects have the same hashCode() it is not guaranteed however that they are equal. 

In the case of TaskRepository it is implemented this way since the repository URL is mutable. Not hashing over the URL allows storing of TaskRepository objects in hash tables without having to worry about modifications to the objects.