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

Bug 345819

Summary: TaskRepository breaks the hashcode/equels contract!
Product: z_Archived Reporter: elhanan Maayan <elh.mailgate>
Component: MylynAssignee: Mylyn Inbox <mylyn-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: major    
Priority: P3    
Version: 3.4   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

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.