Bug 137435 - [DataBinding] IdentityWrapper violates requirements for equals
Summary: [DataBinding] IdentityWrapper violates requirements for equals
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 M3   Edit
Assignee: Boris Bokowski CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
: 137434 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-04-19 02:12 EDT by Daniel Krügler CLA
Modified: 2006-09-26 12:04 EDT (History)
2 users (show)

See Also:


Attachments
Proposed fix for equals (653 bytes, patch)
2006-04-20 02:17 EDT, Daniel Krügler CLA
no flags Details | Diff

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