Repository navigation
fix(java): preserve precision for untyped JSON numbers - #4178
Open
mohitjoshi-hey wants to merge 2 commits into
Open
mohitjoshi-hey wants to merge 2 commits into
mohitjoshi-hey wants to merge 2 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Author
|
Hey, @chaokunyang! Can you please review my PR. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why?
When JSON is read into
Object.class, decimal and exponent-form number literals were converted toDouble. This caused precision loss for literals that could not be represented exactly as adouble, for example:1.2345678901234567890123456789012345678901e4000.1000000000000000055511151231257827021181583404541015625This is problematic for schemaless applications that first read JSON without a type and resolve the type later.
What does this PR do?
BigDecimal.Longrange remainLong.BigInteger.1e400.Related issues
Fixes #4170
Validation
Command:
Result:

AI Contribution Checklist
yesyes, I included a completed AI Contribution Checklist in this PR description and the requiredAI Usage Disclosure.yes, my PR description includes the requiredai_reviewsummary and screenshot evidence or equivalent persisted links of the final clean AI review results from both fresh reviewers described inAI_POLICY.md, the Fory-guided reviewer and the independent general reviewer, on the current PR diff or current HEAD after the latest code changes.AI Usage Disclosure
mvn -pl fory-json -Dtest=JsonContainerTest#preserveNaturalDecimalPrecision testResult: Tests run: 2, Failures: 0, Errors: 0, Skipped: 0; BUILD SUCCESS.
Note: Verify the selected test method and investigate any unrelated suite failures before making broader test-suite claims.
Completed AI Review Checklist
yesyes, I included the standardizedAI Usage Disclosureblock above.yes, I can explain and defend all important changes without AI help.yes, I reviewed AI-assisted code changes line by line before submission.yes, I completed line-by-line self-review first and fixed issues before requesting AI review.yes, I ran two fresh AI review agents on the current PR diff or current HEAD after the latest code changes: one Fory-guided reviewer and one independent general reviewer.yes, I addressed all actionable AI review comments and repeated the review loop until both AI reviewers reported no further actionable comments.yes, I attached screenshot evidence or equivalent persisted links of the final clean-review results from both reviewers in this PR body.yes, I ran a focused test command and recorded its result above.yes, I added regression tests for the reported issue.yes, I validated protocol and performance impacts; no binary protocol change was introduced.yes, I verified licensing and provenance compliance.Does this PR introduce any user-facing change?
The untyped JSON result for decimal and exponent-form numbers changes from
DoubletoBigDecimalso that the original number literal is preserved. Explicitly typed numeric reads are intended to remain unchanged.Benchmark
No benchmark was run. This is intended as a correctness fix for untyped JSON number materialization. Benchmarking may be needed if review identifies a meaningful performance impact.