This is an automated email from the ASF dual-hosted git repository.
tison pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/curator.git
The following commit(s) were added to refs/heads/master by this push:
new e9497317 CURATOR-694. Improve test reliability by resolving
nondeterministic order by sorting (#491)
e9497317 is described below
commit e949731759f18f7d747651f6228ed24110367369
Author: Hannah Chi <[email protected]>
AuthorDate: Sat Dec 2 01:32:55 2023 -0600
CURATOR-694. Improve test reliability by resolving nondeterministic order
by sorting (#491)
---
.../org/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 90cb3fc6..46538fa7 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.ByteArrayInputStream;
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 class EnsembleTracker implements Closeable,
CuratorWatcher {
@VisibleForTesting
public static String configToConnectionString(QuorumVerifier data) throws
Exception {
StringBuilder sb = new StringBuilder();
- for (QuorumPeer.QuorumServer server : data.getAllMembers().values()) {
+
+ List<QuorumPeer.QuorumServer> 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;