Hello!
I have a little problem when try to use object as key with BinaryMarshaller.
Bug occurred only with BinaryMarshaller, on JdkMarshaller all is working fine
as expected.
Here is example:
UserObject class used as key that override hashCode and equals methods but
seems that BinaryMarshaller using all fields from key object for building
hashCode
private static class UserObject implements Serializable {
private final Integer id;
private final Integer notIdField;
UserObject(Integer id, Integer notIdField) {
this.id = id;
this.notIdField = notIdField;
}
public Integer getId() {
return id;
}
public Integer getNotIdField() {
return notIdField;
}
@Override
public int hashCode() {
return Objects.hash(id);
}
@Override
public boolean equals(Object obj) {
if (obj instanceof UserObject) {
return Objects.equals(((UserObject) obj).getId(), getId());
}
return false;
}
}
public void testObjectKey() throws Exception {
IgniteCache<UserObject, Integer> cache = ignite.getOrCreateCache("test");
for (int i = 0; i < 10; i++) {
cache.put(new UserObject(0, i), i);
Assert.assertEquals(1, cache.size(CachePeekMode.PRIMARY));
}
}
Is it expected behaviour or bug?
With best regards
Alisher Alimov
[email protected]