You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
EqualsVerifier fails on the following class:
private final class ArrayThing {
private final int id;
private final byte[] arr;
public ArrayThing(int id, byte[] arr) {
this.id = id;
this.arr = arr;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ArrayThing)) {
return false;
}
ArrayThing other = (ArrayThing)obj;
return arr == null ? other.arr == null : Arrays.equals(arr, other.arr);
}
@Override
public int hashCode() {
return arr == null ? 0 : arr.hashCode();
}
@Override
public String toString() {
return "ArrayThing: " + id + ", " + arr;
}
}
This happens because two instances of ArrayThing that are supposed to be equal,
are initialised with different instances of arr.
Original issue reported on code.google.com by jan.ouw...@gmail.com on 11 Jun 2010 at 7:40
The text was updated successfully, but these errors were encountered:
It turns out the problem was caused by the fact that Arrays.hashCode() should
have been used instead of the array's own hashCode() method.
EqualsVerifier now catches this error and reports it properly. (It already
reported for Arrays.equals().)
Original comment by jan.ouw...@gmail.com on 12 Jun 2010 at 10:40
Original issue reported on code.google.com by
jan.ouw...@gmail.com
on 11 Jun 2010 at 7:40The text was updated successfully, but these errors were encountered: