Skip to content

Commit e447d7c

Browse files
yonghanlinyhlin
andauthored
Fix nondeterministic test (#1219)
Co-authored-by: yhlin <yhlin@wirelessprv-10-194-20-3.near.illinois.edu>
1 parent bd38307 commit e447d7c

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

test/com/esotericsoftware/kryo/serializers/GenericsTest.java

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -436,17 +436,29 @@ public boolean equals (Object obj) {
436436
if (obj == null) return false;
437437
if (getClass() != obj.getClass()) return false;
438438
ClassWithMap other = (ClassWithMap)obj;
439-
if (values == null) {
440-
if (other.values != null) return false;
441-
} else if (!values.toString().equals(other.values.toString())) return false;
442-
return true;
439+
return Objects.equals(values, other.values);
440+
}
441+
442+
@Override
443+
public int hashCode() {
444+
return Objects.hash(values);
443445
}
444446

445447
public static class MapKey {
446448
public String field1, field2;
447449

448-
public String toString () {
449-
return field1 + ":" + field2;
450+
@Override
451+
public boolean equals(Object obj) {
452+
if (this == obj) return true;
453+
if (!(obj instanceof MapKey)) return false;
454+
MapKey other = (MapKey) obj;
455+
return Objects.equals(field1, other.field1) &&
456+
Objects.equals(field2, other.field2);
457+
}
458+
459+
@Override
460+
public int hashCode() {
461+
return Objects.hash(field1, field2);
450462
}
451463
}
452464
}

0 commit comments

Comments
 (0)