optimizely / optimizely/java-sdk

[BUG] Gson deserialization treats integers as doubles, breaking downstream serializers

Open
#622 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

acknowledged bug
Dominant language
Java
Stars
44
Forks
32
Avg merge
8h 39m
Merged PRs (30d)
1

Description

Is there an existing issue for this?
  • I have searched the existing issues
SDK Version

4.4.0

Current Behavior

When using JSON variables with GsonConfigParser, integers within JSON variables appear as doubles to outside consumers. The Map output then can't be returned to valid JSON for use with downstream JSON parsing tools, like kotlinx.serialization.

Expected Behavior

Integer-looking JSON values are deserialized to longs, while decimal-looking JSON values are deserialized to doubles.

Steps To Reproduce

See associated pull request.

Java Version

21

Link

No response

Logs

No response

Severity

Minor issue

Workaround/Solution

Re-interpret doubles as integers where needed.

Recent Change

No response

Conflicts

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the GsonConfigParser entry point in SDK version 4.4.0 and reproduce the JSON-variable behavior described in the issue using Java 21. Compare integer-looking and decimal-looking values in the resulting Map; done means integers are represented as longs and decimals as doubles without breaking downstream JSON serialization.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.