From ec8128afe6e66a02e3234b61b84ce13a163ddd9e Mon Sep 17 00:00:00 2001 From: huiyang Date: Wed, 15 Nov 2023 12:52:14 -0600 Subject: [PATCH] Resolve flaky test --- .../apache/curator/framework/imps/EnsembleTracker.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/EnsembleTracker.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/EnsembleTracker.java index 90cb3fc60..46538fa74 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/imps/EnsembleTracker.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/EnsembleTracker.java @@ -26,6 +26,9 @@ import java.io.Closeable; import java.net.InetAddress; import java.net.InetSocketAddress; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import java.util.Properties; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; @@ -149,7 +152,12 @@ public void processResult(CuratorFramework client, CuratorEvent event) throws Ex @VisibleForTesting public static String configToConnectionString(QuorumVerifier data) throws Exception { StringBuilder sb = new StringBuilder(); - for (QuorumPeer.QuorumServer server : data.getAllMembers().values()) { + + List servers = + new ArrayList<>(data.getAllMembers().values()); + Collections.sort(servers, (a, b) -> a.toString().compareTo(b.toString())); + + for (QuorumPeer.QuorumServer server : servers) { if (server.clientAddr == null) { // Invalid client address configuration in zoo.cfg continue;