Skip to content
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

fix corrupted json generator state after exception #27

Merged
merged 1 commit into from
Apr 29, 2019

Conversation

bakomchik
Copy link

fix bug with stack overflow error
demonstrated here
bakomchik@f933ba0

generator.writeEndArray();
} else if (ctx.inObject()) {
generator.writeEndObject();
} else {
Copy link
Owner

Choose a reason for hiding this comment

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

I think resetGeneratorState has a short-coming which has already been addressed in rescueJsonGeneratorState. Consider the following:

JsonGenerator jsonGenerator = objectMapper.getFactory().createGenerator(outputStream);
jsonGenerator.writeStartObject();
jsonGenerator.writeFieldName("foo");

At this state, neither a ], nor a } would suffice; a jsonGenerator.writeFieldValue(someRandomValue) is required. I am working on top of your changes to make this work, FYI.

vy added a commit that referenced this pull request Apr 21, 2019
…and instantiate a new one.

Given[1] there is no proper way to recover from a corrupted JsonGenerator
state, rather than waiting for the next bug report of this hack, I just
ditched it off.

[1] https://groups.google.com/d/msg/jackson-user/vsJST_drx04/rFSF5jSyBQAJ
@vy
Copy link
Owner

vy commented Apr 21, 2019

@bakomchik (@labakomchev?), see the 3addd31 fix I have just pushed. Would you mind testing and reporting back if this fixes the issue, please?

BTW, I have already added your "nickname" and GitHub account to the list of contributors. Do you a certain name rather than "bakomchik"?

@vy
Copy link
Owner

vy commented Apr 29, 2019

Merged the changes to master and cut a release. v0.18 should momentarily arrive in Maven Central.

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.

None yet

3 participants