Skip to content

Fix deferred double value after float access - #1779

Open
vera-rubin wants to merge 1 commit into
FasterXML:2.21from
vera-rubin:fix/deferred-double-after-float
Open

vera-rubin wants to merge 1 commit 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

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
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
}
// Decode a deferred double before discarding its textual representation.
if ((_numTypesValid & NR_DOUBLE) != 0) {
_getNumberDouble();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh? Why do we call it and throw away return value?

This branch has not been deployed

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

Labels

cla-received PR already covered by CLA (optional label)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants