jakartaee / jsonb-api

Jakarta JSON Binding
https://eclipse-ee4j.github.io/jsonb-api/
Other
79 stars 39 forks source link

Clarify for the `jsonb.fromJson()` methods should close the `InputStream` or `Reader` arguments #350

Closed jamezp closed 10 months ago

jamezp commented 10 months ago

The JavaDoc for Jsonb.fromJson() is inconsistent between the Reader and InputStream arguments.

The Jsonb.fromJson(InputStream, ?) states the following for the stream argument.

The stream is read as a JSON data. Upon a successful completion, the stream will be closed by this method.

The Reader versions do not state the reader will be closed. I would argue the correct behavior should be the stream is not closed. As pointed out in, not closing the stream would be consistent with Properties.load() and KeyStore.load().

There is also no description of what should happen on an unsuccessful completion.

In either case, it seems the Reader and InputStream methods should behave the same. If the decision to close the streams is made, there needs to be some clarification on what happens with an unsuccessful completion.

jamezp commented 10 months ago

Oops, I missed #346 this is a duplicate. Sorry about that.