From 60d198ca98fd4b2c8a829eb4b809cc63c7b91cd5 Mon Sep 17 00:00:00 2001 From: Owen Pearson Date: Mon, 16 Oct 2023 11:01:09 +0100 Subject: [PATCH] fix: add numbers strategy for Gson to prevent changing int to double Fixes an issue where json decoding was inconsistent between underlying platforms (ios/android) --- .../main/java/io/ably/flutter/plugin/AblyMessageCodec.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/io/ably/flutter/plugin/AblyMessageCodec.java b/android/src/main/java/io/ably/flutter/plugin/AblyMessageCodec.java index 8cbc88ec6..53c0af1aa 100644 --- a/android/src/main/java/io/ably/flutter/plugin/AblyMessageCodec.java +++ b/android/src/main/java/io/ably/flutter/plugin/AblyMessageCodec.java @@ -8,6 +8,7 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import com.google.gson.ToNumberPolicy; import java.io.ByteArrayOutputStream; import java.nio.ByteBuffer; @@ -82,7 +83,11 @@ T decode(Map jsonMap) { } private Map codecMap; - private static final Gson gson = new Gson(); + private static final Gson gson = new Gson() + .newBuilder() + .setObjectToNumberStrategy(ToNumberPolicy.LONG_OR_DOUBLE) + .create(); + private final CipherParamsStorage cipherParamsStorage;