Skip to content

Preserve explicit "+" sign across buffer boundaries for "+0..." on async parser#1614

Merged
cowtowncoder merged 3 commits into
FasterXML:3.xfrom
seonwooj0810:fix/async-plus-zero-resumption
May 27, 2026
Merged

Preserve explicit "+" sign across buffer boundaries for "+0..." on async parser#1614
cowtowncoder merged 3 commits into
FasterXML:3.xfrom
seonwooj0810:fix/async-plus-zero-resumption

Conversation

@seonwooj0810

@seonwooj0810 seonwooj0810 commented May 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Splits out the drive-by async-parser fix from #1613 per @cowtowncoder's request, so the hex feature PR can stay focused.

The non-blocking parser reused MINOR_NUMBER_ZERO for both the bare-zero (0…) and explicit-plus-zero (+0…) suspension paths, so the leading + was lost when input arrived byte-by-byte. The sibling tests in AsyncNonStandardNumberParsingTest already disagreed with each other:

  • leadingPlusSignInDecimalEnabled (+123) — asserted "+123"
  • leadingPlusSignInDecimalEnabled2 (+0.123) — asserted "0.123" ❌ (lost the +)

This change adds a dedicated MINOR_NUMBER_PLUSZERO state alongside MINOR_NUMBER_ZERO / MINOR_NUMBER_MINUSZERO. _finishNumberLeadingPosNegZeroes now stores MINOR_NUMBER_PLUSZERO when negative=false, so the buffered text on resume retains the leading +, matching the blocking parsers and the sibling +123 path.

AsyncNonStandardNumberParsingTest#leadingPlusSignInDecimalEnabled2 is updated to assert the now-preserved "+0.123" output. The previous "0.123" assertion was masked by the bug.

Background

Discovered while implementing the JSON5 hex feature (#1613) — async tests with 1-byte feeds surfaced the divergence. Per maintainer comment ("yes, please, that'd be worth fixing separately, can merge quickly"), splitting it out here. Unrelated to the hex feature itself, so easy to review in isolation.

Test plan

  • mvn test — 1675 tests, 0 failures, 0 regressions (2 pre-existing skips).
  • AsyncNonStandardNumberParsingTest — 18 tests pass, including the updated leadingPlusSignInDecimalEnabled2.

Notes

…arser

The non-blocking parser reused MINOR_NUMBER_ZERO for both bare-zero ("0...")
and explicit-plus-zero ("+0...") suspension paths, so the leading '+' was
lost when input arrived byte-by-byte. Add a dedicated MINOR_NUMBER_PLUSZERO
state alongside MINOR_NUMBER_ZERO/MINOR_NUMBER_MINUSZERO;
_finishNumberLeadingPosNegZeroes now stores MINOR_NUMBER_PLUSZERO when
negative=false, restoring symmetry with the blocking parsers and the sibling
"+123" path.

Update AsyncNonStandardNumberParsingTest#leadingPlusSignInDecimalEnabled2
to assert "+0.123" -- the previous "0.123" assertion contradicted the
sibling test for "+123" and was masked by the bug.

Noticed while working on hex-literal support (FasterXML#707); split out per
maintainer request.
seonwooj0810 added a commit to seonwooj0810/jackson-core that referenced this pull request May 27, 2026
The async-parser '+0...' resumption fix is being split out into PR FasterXML#1614.
This commit renumbers MINOR_NUMBER_PLUSZERO from 35 to 33 (and shifts the
hex constants to 34/35) so feat/707 matches whatever the split PR lands as
in 3.x -- avoiding a numeric collision when 3.x is merged back in.

Also drops the leftover [core#707] tag from the PLUSZERO comment now that
the primitive lives in its own PR; the comment in NonBlockingUtf8 is
reformatted for the same reason.
@cowtowncoder

cowtowncoder commented May 27, 2026

Copy link
Copy Markdown
Member

Nice clean split — easy to review in isolation. One small thing worth calling out in the PR description (not a blocker):

_finishTokenWithEOF still groups MINOR_NUMBER_PLUSZERO with MINOR_NUMBER_ZERO / MINOR_NUMBER_MINUSZERO and returns _valueCompleteInt(0, "0"), so the input +0<EOF> resumes as "0" (sign lost) — diverging from the blocking parser the same way +0.123 did before this fix. Looks intentional (bug-compatible with the pre-existing -0<EOF> behavior, and the existing inline comment already flags it as deferrable), I'll add a comment.

@cowtowncoder cowtowncoder left a comment

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.

Will add fix for the +0<EOF> / -0<EOF> text-loss cases.

@github-actions

Copy link
Copy Markdown
Contributor

📈 Overall Code Coverage

Metric Coverage Change
Instructions coverage 83.03% 📈 +0.020%
Branches branches 75.74% 📈 +0.030%

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

@cowtowncoder cowtowncoder merged commit c5df9e0 into FasterXML:3.x May 27, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants