Skip to content

Fix #1438: change ParserBase.close() to clear _currToken #1439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 30, 2025

Conversation

cowtowncoder
Copy link
Member

No description provided.

@cowtowncoder cowtowncoder merged commit 971773d into 2.x May 30, 2025
5 checks passed
@cowtowncoder cowtowncoder deleted the tatu/2.20/1438-parser-base-close-curr-token branch May 30, 2025 20:15
@@ -403,6 +403,8 @@ public void overrideCurrentName(String name) {
// 19-Jan-2018, tatu: as per [core#440] need to ensure no more data assumed available
_inputPtr = Math.max(_inputPtr, _inputEnd);
_closed = true;
// 30-May-2025, tatu: was missing before 2.20
_currToken = null;
Copy link
Member

Choose a reason for hiding this comment

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

could this be viewed as a bug and potentially considered for 2.19.1?

Copy link
Member Author

Choose a reason for hiding this comment

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

Potentially too risky for 2.19.1, even if bug (which it seemed to me it is). That's why targeting 2.20.

But... I am now re-considering this change: the reason being that there are 2 test failures from jackson-databind for verifying information from InvalidFormatException.
(found out via cascading rebuilds).
This is done through exception-included JsonParser and it appears that parser gets closed before test has a chance to access the current token.
I'll see if there is something in the test to change, and perhaps MismatchedInputException ought to get "current token" directly. But there are many other things parser would have access to, at point of throwing an exception.

Will have to think about this a bit...

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah. Test uses ObjectReader.readValue(String) which will create JsonParser but also close it (since caller wouldn't have access to it).

So it's probably ok -- can change test, but also explain why new behavior makes sense and how to avoid JsonParser.close() from occurring.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmmmh. I think there's need for new StreamReadFeature flag for this, actually.

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