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

[BUG] SDK doesn't convert int values correctly #554

Open
1 task done
iago-zwift opened this issue Jan 2, 2025 · 0 comments
Open
1 task done

[BUG] SDK doesn't convert int values correctly #554

iago-zwift opened this issue Jan 2, 2025 · 0 comments
Labels
acknowledged The issue has been acknowledged and being looked into. Further details will follow. bug

Comments

@iago-zwift
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

SDK Version

4.2.0

Current Behavior

I currently have a huge problem with the Java SDK.

The SDK tries to convert an Integer variable from the response, but this Integer could be a java.lang.Long, which raises a NumberFormatException and makes the SDK return the variable value as null. We've been using the Optimizely Agent (golang), which returns correctly, but are currently migrating to a Kotlin service that calls the Java SDK and hit this problem.

I can submit a PR to the SDK repo myself if needed, since I know where/how to fix the issue, but please let me know how to proceed.

Expected Behavior

Feature Variables declared as Integer with Long values are converted to java.lang.Long correctly, instead of throwing an error and being converted to null instead.

Steps To Reproduce

  1. Setup a feature
  2. Create an Integer variable with any name
  3. Set the variable value to a number that's considered Long in Java. E.g.: 8949425362
  4. Use the Optimizely Client decideForKeys passing the feature key created on step (1)
  5. See the SDK returning it as null and logging a NumberFormatException error

Java Version

21

Link

No response

Logs

2025-01-02 15:03:44,167 ERROR [com.optimizely.ab.Optimizely] (vert.x-eventloop-thread-4 - 63358) - trace_id  span_id  - NumberFormatException while trying to parse "3382019812" as Integer. java.lang.NumberFormatException: For input string: "8949425362"

Severity

Blocking development

Workaround/Solution

Clone the repo and fix the issue myself until this is fixed. This results in a maintenance burden since I'd need to support the cloned repo.

Recent Change

Migrating from golang to java. In the golang Optimizely Agent it works just fine.

Conflicts

No response

@iago-zwift iago-zwift added the bug label Jan 2, 2025
@muzahidul-opti muzahidul-opti added the acknowledged The issue has been acknowledged and being looked into. Further details will follow. label Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
acknowledged The issue has been acknowledged and being looked into. Further details will follow. bug
Projects
None yet
Development

No branches or pull requests

2 participants