jsonp-api
jsonp-api copied to clipboard
Clarification needed: Should JsonWriter write methods close the underlying writer/stream
Hi,
I'm evaluating Johnzon [1] as JSON-P implementation. My concern is that Johnzon's JsonWriter implementation closes the writer/stream after invocation of any of the write*() methods: [2]. The javadoc does not explicitly mention that the stream/writer has to be closed, but says that the write* methods are one-time use only, which might be interpreted that they close the stream/writer.
Please clarify if it's ok for the write* methods to close the underlying stream/writer.
[1] https://github.com/apache/johnzon [2] https://github.com/apache/johnzon/blob/180eb6133e4194832541bbd0c29b23e40765617c/johnzon-core/src/main/java/org/apache/johnzon/core/JsonWriterImpl.java#L43
Kind regards, Svetlin
- Issue Imported From: https://github.com/javaee/jsonp/issues/51
- Original Issue Raised By:@SvetlinZarev
- Original Issue Assigned To: Unassigned
@m0mus Commented You are right, JSON-P specification only requires that write* methods called only once for a writer instance. It doesn't require closing the stream though, so it's up to implementations.
JSON-P RI doesn't close the stream. It flushes it on each write and throws an exception if another write attempt happens.