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

It is intrusive and aggressive to close not owned input/output stream by default #505

Open
kezhuw opened this issue Dec 16, 2018 · 1 comment
Labels
3.x Issues to be only tackled for Jackson 3.x, not 2.x

Comments

@kezhuw
Copy link

kezhuw commented Dec 16, 2018

In 2.x, JsonParser and JsonGenerator enable JsonParser.Feature.AUTO_CLOSE_SOURCE and JsonGenerator.Feature.AUTO_CLOSE_TARGET by default. I think it is too intrusive and aggressive to enable these features by default since they operate on input/output stream not owned by parser/generator as the javadoc states.

Besides this, I found YAMLGenerator closes input/output stream always without consulting these features. This makes me can't use ObjectMapper.writeValue(OutputStream out, Object value) to write yaml content embedded in another stream, say zipped file stream.

PS: I saw these features are migrated to StreamReadFeature and StreamWriteFeature in master.

@cowtowncoder cowtowncoder added the 3.x Issues to be only tackled for Jackson 3.x, not 2.x label Dec 16, 2018
@cowtowncoder
Copy link
Member

cowtowncoder commented Dec 16, 2018

On YAML, this:

FasterXML/jackson-dataformats-text#99

was the issue; fixed now in 2.9.8. It's a good idea to report these directly for project.

We can definitely consider default settings for 3.0, but the reason for these settings is that I experienced the opposite pain when frameworks like Stax (XML API) did the opposite and left hanging file handles, sometimes running out and causing service failures. So there is a reason why default is that way.

Same is true for some other features, such as "fail on unknown properties": debugging problems when nothing matches is annoying. But I can see how the opposite setting can be problematic as well.

One thing I'll need to figure out is how to collect all ideas for changing defaults. I think they should be considered as a group, as sort of "Jackson Improvement Project" or something, for bigger v3 changes/additions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x Issues to be only tackled for Jackson 3.x, not 2.x
Projects
None yet
Development

No branches or pull requests

2 participants