Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions streams/src/main/java/org/apache/kafka/streams/KeyValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public boolean equals(Object other) {
if (other instanceof KeyValue) {
KeyValue otherKV = (KeyValue) other;

return key == null ? otherKV.key == null : key.equals(otherKV.key)
&& value == null ? otherKV.value == null : value.equals(otherKV.value);
return (key == null ? otherKV.key == null : key.equals(otherKV.key))
&& (value == null ? otherKV.value == null : value.equals(otherKV.value));
} else {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class KeyValueTest {

private KeyValue<String, Long> kv1a = new KeyValue<>("key1", 1L);
private KeyValue<String, Long> kv1b = new KeyValue<>("key1", 1L);
private KeyValue<String, Long> kv1c = new KeyValue<>("key1", 2L);
private KeyValue<String, Long> kv2 = new KeyValue<>("key2", 2L);
private KeyValue<String, Long> kv3 = new KeyValue<>("key3", 3L);

Expand All @@ -34,12 +35,16 @@ public void testEquals() {
assertTrue(kv1a.equals(kv1a));
assertTrue(kv1a.equals(kv1b));
assertTrue(kv1b.equals(kv1a));
assertFalse(kv1a.equals(kv1c));
assertFalse(kv1c.equals(kv2));
assertFalse(kv1a.equals(kv2));
assertFalse(kv1a.equals(kv3));
assertFalse(kv2.equals(kv3));
assertFalse(kv1a.equals(null));
}



@Test
public void testHashcode() {
assertTrue(kv1a.hashCode() == kv1b.hashCode());
Expand Down