-
Notifications
You must be signed in to change notification settings - Fork 61
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 JsonGenerator.close regression #404
Comments
Actually I don't think it should close the underlying Writer/OutputStream at all. My golden rules
The caller passes in the OutputStream or the Writer when creating the JsonGenerator, so the caller is responsible for closing it properly (one can use try-with-resource). The #close() on JsonGenerator must only close the resources it created (buffer and others). |
In other words, there is something to fix, but I would not revert the change, I would remove the close on the underlying stream at all. And make it clear in the javadoc that it's under the caller responsability to monitor and enforce the lifecycle of the resources it opens. |
@jeanouii does not look consistent with the api, JsonGenerator is designed to be autocloseable and to wrap an underlying stream, if it does not close the stream it does leak, even tck are written this way ( jsonp-api/tck/tck-tests/src/main/java/ee/jakarta/tck/jsonp/api/jsongeneratortests/Generator.java Line 97 in 4d57820
Indeed it can be rediscussed in a v3 but not in a minor IMHO. |
…lose the underlying stream Signed-off-by: Jean-Louis Monteiro <jlmonteiro@tomitribe.com>
Please check #156, this issue introduced by a too quick review a big regression on JSON-P API design (and implementations/doc bugs) so it is more than likely and welcomed to revert this by documenting properly the behavior and harnessing it instead of breaking the JSON-P api design.
The text was updated successfully, but these errors were encountered: