Remote config crash when retrieving integer value #3017
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: wordpress-mobile/WordPress-Android#20857
Please read the above issue's description for context.
It seems that the issue we’re experiencing, where integer fields are being converted to doubles, is due to the deserialization process within the Gson library. Gson has a tendency to treat all numbers as doubles when deserializing generic Map objects, which is what we are seeing.
A new custom NumberAwareMapDeserializer was created which ensures that numbers are correctly parsed and converted to the appropriate type (e.g., integer, long, double) based on their value.
A minor refactoring was needed so this is used only for remote config calls.
Testing steps: Use this WordPress PR.