You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by GitBox <gi...@apache.org> on 2022/08/17 01:09:42 UTC

[GitHub] [ratis] leo65535 commented on a diff in pull request #714: RATIS-1673. Verify duplicate peerid when init raft group

leo65535 commented on code in PR #714:
URL: https://github.com/apache/ratis/pull/714#discussion_r947364738


##########
ratis-common/src/main/java/org/apache/ratis/protocol/RaftGroup.java:
##########
@@ -62,7 +62,12 @@ private RaftGroup(RaftGroupId groupId, Iterable<RaftPeer> peers) {
       this.peers = Collections.emptyMap();
     } else {
       final Map<RaftPeerId, RaftPeer> map = new HashMap<>();
-      peers.forEach(p -> map.put(p.getId(), p));
+      peers.forEach(p -> {
+        Preconditions.assertTrue(!map.containsKey(p.getId()),
+            () -> "PeerId " + p.getId() + " has already appeared in this group.");

Review Comment:
   Make sense.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@ratis.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org