Description
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
- Setup a feature
- Create an Integer variable with any name
- Set the variable value to a number that's considered Long in Java. E.g.:
8949425362
- Use the Optimizely Client
decideForKeys
passing the feature key created on step (1) - 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