Skip to content

Return null from nextTextValue() at end of input (2.x port of #899) - #902

Merged
cowtowncoder merged 1 commit into
2.xfrom
nexttextvalue-end-of-input-2.x
Aug 21, 2026
Merged

Return null from nextTextValue() at end of input (2.x port of #899)#902
cowtowncoder merged 1 commit into
2.xfrom
nexttextvalue-end-of-input-2.x

Conversation

@cowtowncoder

Copy link
Copy Markdown
Member

Port of #899 (3.x, by @Sahana2524) to the 2.x line.

FromXmlParser.nextTextValue() runs the XmlTokenStream event through a switch in which the XML_END branch has no break, so it falls into default: and throws:

java.lang.IllegalStateException: Internal error: unrecognized XmlTokenStream token: 8

One call past the last token therefore raises an unchecked exception instead of reporting end-of-input as null, the way nextToken() already does for XML_END. Callers that only catch JsonProcessingException do not see it.

Adds the missing break so XML_END reaches the method's shared return null, plus a test in XmlParserNextXxxTest making one call past the end (throws on 2.x as-is, returns null with the fix).

Verified: full 2.x suite green (423 tests); the new test fails without the one-line change and passes with it. Release notes updated for 2.23.0.

🤖 Generated with Claude Code

Port of the 3.x fix (PR #899 by @Sahana2524) to the 2.x line.

FromXmlParser.nextTextValue() runs the XmlTokenStream event through a switch
in which the XML_END branch has no `break`, so it falls into `default:` and
throws IllegalStateException. One call past the last token therefore raises an
unchecked exception instead of reporting end-of-input as null, the way
nextToken() already does for XML_END; callers that only catch JsonProcessingException
do not see it.

Adds the missing `break` so XML_END reaches the method's shared `return null`,
plus a test in XmlParserNextXxxTest covering one call past the end.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@cowtowncoder
cowtowncoder merged commit f9d0dce into 2.x Aug 21, 2026
4 checks passed
@cowtowncoder
cowtowncoder deleted the nexttextvalue-end-of-input-2.x branch August 21, 2026 23:51
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.

1 participant