Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add numbers strategy for Gson to prevent changing int to double #462

Merged
merged 1 commit into from Apr 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -7,6 +7,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;
Expand Down Expand Up @@ -80,7 +81,12 @@ T decode(Map<String, Object> jsonMap) {
}

private Map<Byte, CodecPair> 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;

public AblyMessageCodec(CipherParamsStorage cipherParamsStorage) {
Expand Down