[ https://issues.apache.org/jira/browse/RATIS-134?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16240755#comment-16240755 ]
Tsz Wo Nicholas Sze commented on RATIS-134: ------------------------------------------- Thanks, Mukul. We should use {code} peers.computeIfAbsent(p.getId(), k -> new PeerAndProxy(p)); {code} to make it atomic. > PeerProxyMap#addPeers should add peers only if it is not already present in > the proxymap > ---------------------------------------------------------------------------------------- > > Key: RATIS-134 > URL: https://issues.apache.org/jira/browse/RATIS-134 > Project: Ratis > Issue Type: Bug > Reporter: Mukul Kumar Singh > Assignee: Mukul Kumar Singh > Attachments: RATIS-134.001.patch > > > {{PeerProxyMap#addPeers}} currently adds peers to the proxyMap without > checkint the current state. This should be optimized to allow addition only > if the peer is not present in the proxyMap. > {code} > public void addPeers(Iterable<RaftPeer> newPeers) { > for(RaftPeer p : newPeers) { > peers.put(p.getId(), new PeerAndProxy(p)); > } > } > {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029)