Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.4.2
-
None
-
Patch
Description
Noticed that the equals implementation assumes the other parameter can be successfully cast to IdentityWrapper:
@Override @SuppressWarnings("rawtypes") public boolean equals(Object other) { return ((IdentityWrapper) other).instance == instance; }
(There is a chance that this could throw a ClassCastException.)
See BC_EQUALS_METHOD_SHOULD_WORK_FOR_ALL_OBJECTS.
I recommend:
@Override @SuppressWarnings("rawtypes") public boolean equals(Object other) { return other instanceof IdentityWrapper && ((IdentityWrapper) other).instance == instance; }