Skip to content

Fix deferred double value after float access (fix #1813) - #1779

Merged
cowtowncoder merged 8 commits into
FasterXML:2.21from
vera-rubin:fix/deferred-double-after-float
Nov 3, 2026
Merged

cowtowncoder merged 8 commits into
FasterXML:2.21from
vera-rubin:fix/deferred-double-after-float

Conversation

@vera-rubin

@vera-rubin vera-rubin commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

(for fixing #1813)

For input 1.25, calling getNumberType(), getFloatValue(), then getDoubleValue() returns DOUBLE, 1.25, and 0.0. The double accessor promises the current numeric value, so we expect 1.25 regardless of accessor order.

try (var p = new JsonFactory().createParser("1.25")) {
    p.nextToken();
    p.getNumberType();
    p.getFloatValue();
    System.out.println(p.getDoubleValue()); // expected 1.25, got 0.0
}

We decode the deferred double before float access discards its source text, preserving independent rounding for both types.

The regression test, existing numeric parsing tests, and default Maven verification build pass on 2.21.

— ChipLab

@pjfanning

Copy link
Copy Markdown
Member

this is a bug fix - so target 2.21 and we will forward fit the change - this way it lands in more releases

we require a signed CLA - https://github.com/FasterXML/jackson/blob/main/CONTRIBUTING.md#paperwork

@github-actions

Copy link
Copy Markdown
Contributor

📈 Overall Code Coverage

Metric Coverage Change
Instructions coverage 86.51% 📉 -0.020%
Branches branches 80.60% 📉 -0.020%

Overall project coverage from JaCoCo test results. Change values compare against the latest base branch build.

@vera-rubin
vera-rubin changed the base branch from 3.x to 2.21 October 16, 2026 14:52
@vera-rubin
vera-rubin force-pushed the fix/deferred-double-after-float branch from 66bf8de to 9d2527b Compare October 16, 2026 14:53
@vera-rubin

Copy link
Copy Markdown
Contributor Author

@pjfanning, this now targets 2.21. Donmakino LLC's corporate CLA was filed with Tatu on Oct 15.

— ChipLab

@cowtowncoder

Copy link
Copy Markdown
Member

@pjfanning We do not need to backport all fixes to 2.21 -- 2.18 should get secvulns; 2.21 critical. Non-critical ones can go in 2.x.

But since this is targeted to 2.21 I can eventually merge it that way.

@cowtowncoder cowtowncoder added the cla-received PR already covered by CLA (optional label) label Oct 16, 2026
@vera-rubin

Copy link
Copy Markdown
Contributor Author

@cowtowncoder, the call materialized the deferred double before float access discarded its source text. It now explicitly assigns the result to _numberDouble, matching convertNumberToDouble().

— ChipLab

@cowtowncoder

cowtowncoder commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Let's re-consider things -- I don't like "double-parsing" (no pun intended) for decoding String into both float and double when just one is requested.
Since this may need bigger change, I think we need:

  1. Actual issue -- we (as Jackson project) have gotten into habit of only doing PRs, but issues are good at describing the problem first -- not just pr
  2. Do pr against 2.x unless we find a trivial (safe + efficient) fix.

I'll do 1 first.

EDIT: see #1813

EDIT/2: I think 2.21 may be fine after all & this is sort of critical fix.

@cowtowncoder cowtowncoder changed the title Fix deferred double value after float access Fix deferred double value after float access (fix #1813) Nov 3, 2026
@cowtowncoder
cowtowncoder merged commit 682b406 into FasterXML:2.21 Nov 3, 2026
8 checks passed
@cowtowncoder cowtowncoder added the 2.21 Issues planned (at earliest) for 2.21 label Nov 3, 2026
@cowtowncoder cowtowncoder added this to the 2.21.9 milestone Nov 3, 2026
@cowtowncoder

Copy link
Copy Markdown
Member

Thank you @vera-rubin ! I made some changes & filed related issues; this will go in 2.21.9 and later releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.21 Issues planned (at earliest) for 2.21 cla-received PR already covered by CLA (optional label)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getDoubleValue() returns 0.0 after getNumberType(), getFloatValue() for floating-point value

3 participants