Bug 137435

Summary: [DataBinding] IdentityWrapper violates requirements for equals
Product: [Eclipse Project] Platform Reporter: Daniel Krügler <daniel.kruegler>
Component: UIAssignee: Boris Bokowski <bokowski>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: bradleyjames, Konstantin.Scheglov
Version: 3.2Keywords: contributed
Target Milestone: 3.3 M3   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed fix for equals none

Description Daniel Krügler CLA 2006-04-19 02:12:24 EDT
3.2M6: The current implementation of IdentityWrapper violates the basic requirements for equals (see http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html#equals(java.lang.Object)),
namely

"For any non-null reference value x, x.equals(null) should return false"

because it can't handle null values. The current implementation:

 public boolean equals(Object obj) {
  if (obj.getClass() != IdentityWrapper.class) {
   return false;
  }
  return o == ((IdentityWrapper) obj).o;  }

should be changed to:

 public boolean equals(Object obj) {
  if (obj == null || obj.getClass() != IdentityWrapper.class) {
   return false;
  }
  return o == ((IdentityWrapper) obj).o;  }

to fix this issue. (Note: I'm aware that IdentityWrapper is an internal
class, but it looks like a class which might be made public in the
future, so I mentioned this point)
Comment 1 Daniel Krügler CLA 2006-04-19 02:14:42 EDT
*** Bug 137434 has been marked as a duplicate of this bug. ***
Comment 2 Brad Reynolds CLA 2006-04-19 20:15:20 EDT
Daniel, can you attach a patch?  If not I can take care of it, not a big deal.  Also if null is passed the current code will throw a NPE.
Comment 3 Daniel Krügler CLA 2006-04-20 02:17:11 EDT
Created attachment 39007 [details]
Proposed fix for equals

"Can't handle" was just a nicer description for the NPE ;-)
Comment 4 Boris Bokowski CLA 2006-09-26 12:04:09 EDT
This was already fixed, I added the contribution comment and removed a duplicate of this class.