You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2022/10/20 06:14:08 UTC
[iotdb] branch master updated: [IOTDB-4699] Override peer's equals and hashcode
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 66e01dfcfc [IOTDB-4699] Override peer's equals and hashcode
66e01dfcfc is described below
commit 66e01dfcfc9fc2eb9394487379df87adb788ba15
Author: William Song <48...@users.noreply.github.com>
AuthorDate: Thu Oct 20 14:14:03 2022 +0800
[IOTDB-4699] Override peer's equals and hashcode
---
.../java/org/apache/iotdb/consensus/common/Peer.java | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/consensus/src/main/java/org/apache/iotdb/consensus/common/Peer.java b/consensus/src/main/java/org/apache/iotdb/consensus/common/Peer.java
index c7466206f1..8438e90e30 100644
--- a/consensus/src/main/java/org/apache/iotdb/consensus/common/Peer.java
+++ b/consensus/src/main/java/org/apache/iotdb/consensus/common/Peer.java
@@ -79,23 +79,21 @@ public class Peer {
@Override
public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
Peer peer = (Peer) o;
- return Objects.equals(groupId, peer.groupId) && Objects.equals(endpoint, peer.endpoint);
+ return nodeId == peer.nodeId
+ && Objects.equals(groupId, peer.groupId)
+ && Objects.equals(endpoint, peer.endpoint);
}
@Override
public int hashCode() {
- return Objects.hash(groupId, endpoint);
+ return Objects.hash(groupId, endpoint, nodeId);
}
@Override
public String toString() {
- return "Peer{" + "groupId=" + groupId + ", endpoint=" + endpoint + '}';
+ return "Peer{" + "groupId=" + groupId + ", endpoint=" + endpoint + ", nodeId=" + nodeId + '}';
}
}