Skip to content

Commit 0f52cca

Browse files
committed
Fixed flaky should_encode_recovery_key_context_object test by making RecoveryKeyContext#channelSerials
as a treemap
1 parent 83e347c commit 0f52cca

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

lib/src/main/java/io/ably/lib/types/RecoveryKeyContext.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import com.google.gson.JsonSyntaxException;
44

5-
import java.util.HashMap;
65
import java.util.Map;
6+
import java.util.TreeMap;
77

88
import io.ably.lib.util.Log;
99
import io.ably.lib.util.Serialisation;
@@ -13,7 +13,8 @@ public class RecoveryKeyContext {
1313

1414
private final String connectionKey;
1515
private final long msgSerial;
16-
private final Map<String, String> channelSerials = new HashMap<>();
16+
// Sorted so encode() produces deterministic, key-ordered JSON regardless of input map ordering.
17+
private final Map<String, String> channelSerials = new TreeMap<>();
1718

1819
public RecoveryKeyContext(String connectionKey, long msgSerial, Map<String, String> channelSerials) {
1920
this.connectionKey = connectionKey;

0 commit comments

Comments
 (0)