You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ratis.apache.org by ad...@apache.org on 2023/02/27 08:50:39 UTC

[ratis] branch master updated: RATIS-1792. Replace parallelStream usage in PeerProxyMap (#831)

This is an automated email from the ASF dual-hosted git repository.

adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ratis.git


The following commit(s) were added to refs/heads/master by this push:
     new 4afe4b2de RATIS-1792. Replace parallelStream usage in PeerProxyMap (#831)
4afe4b2de is described below

commit 4afe4b2ded83da451cd1ed7154d45639d3ab2623
Author: Doroszlai, Attila <64...@users.noreply.github.com>
AuthorDate: Mon Feb 27 09:50:34 2023 +0100

    RATIS-1792. Replace parallelStream usage in PeerProxyMap (#831)
    
    (cherry picked from commit 349aee18da0aea754ead28bddfedc5cc1f99a369)
---
 ratis-common/src/main/java/org/apache/ratis/util/PeerProxyMap.java | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/ratis-common/src/main/java/org/apache/ratis/util/PeerProxyMap.java b/ratis-common/src/main/java/org/apache/ratis/util/PeerProxyMap.java
index d9f0107a8..7655a3ff3 100644
--- a/ratis-common/src/main/java/org/apache/ratis/util/PeerProxyMap.java
+++ b/ratis-common/src/main/java/org/apache/ratis/util/PeerProxyMap.java
@@ -165,8 +165,10 @@ public class PeerProxyMap<PROXY extends Closeable> implements RaftPeer.Add, Clos
 
   @Override
   public void close() {
-    peers.values().parallelStream().forEach(
-        pp -> pp.setNullProxyAndClose().ifPresent(proxy -> closeProxy(proxy, pp)));
+    ConcurrentUtils.parallelForEachAsync(peers.values(),
+        pp -> pp.setNullProxyAndClose().ifPresent(proxy -> closeProxy(proxy, pp)),
+        r -> new Thread(r).start()
+    ).join();
   }
 
   private void closeProxy(PROXY proxy, PeerAndProxy pp) {