johnzon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jörg Sautter (JIRA) <>
Subject [jira] [Commented] (JOHNZON-215) JsonReader.readObject() calls Reader.close()
Date Mon, 17 Jun 2019 12:48:00 GMT


Jörg Sautter commented on JOHNZON-215:

Hi Romain,

i agree that a lot of people might using it without calling close, but the behaviour it should
be the same for all JSR-353 implementations.
At development / testing time there might be another implementation used as in production,
this might lead to issues.
It might be a good idea to check the behaviour of the refence implementation and other implemenations,
if no explicit specification is found.

Inside the javadoc of JsonReader the example explicit calls .close() and the implementation
of Closeable implies a call to close is mandatory to get the resources closed.
If all the methods of this class do an instant close, it doesn't make sense to implement Closeable
in my mind, which is of course needed to implement the JsonReader interface.

I could not find anything else inside the JSR-353 downloads and i don't have access to the
TCK, perhaps something might be found there.

Kind regards,

> JsonReader.readObject() calls Reader.close()
> --------------------------------------------
>                 Key: JOHNZON-215
>                 URL:
>             Project: Johnzon
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 1.1.12
>            Reporter: Jörg Sautter
>            Priority: Major
> We try to use the JsonReader to read a Reader based on a channel holding an exclusive
file lock and later on we truncate the channel, write the content and close the channel /
release the lock.
> As soon as we call JsonReader.readObject() the reader and the channel is closed and the
file locks are gone. This should - from our point of view - not happen at this point, only
a explicit call to .close() should close the underlying resources.
> This is a code snippet to reproduce the issue:
> {{StringReader sr = new StringReader("{}");}}
> {{Reader wrapper = new Reader() {}}
> {{@Override}}
> {{public int read(char[] cbuf, int off, int len) throws IOException{}}
> {{return, off, len);}}
> {{}}}
> {{@Override}}
> {{public void close() throws IOException{}}
> {{throw new UnsupportedOperationException("someone closed the stream!");}}
> {{}}}
> {{};}}
> {{Json.createReader(wrapper).readObject();}}

This message was sent by Atlassian JIRA

View raw message