Skip to main content

[jsr353-experts] Re: [json-processing-spec users] Re: JsonParser.close() and exceptions

  • From: Jonathan Fuerth < >
  • To:
  • Subject: [jsr353-experts] Re: [json-processing-spec users] Re: JsonParser.close() and exceptions
  • Date: Mon, 17 Dec 2012 11:08:51 -0500

On 2012-12-17, at 10:55 AM, wenshao wrote:

if jsr353 is a part of JDK 8, should AutoCloseable. if it is library, should not be AutoCloseable.


Yeah, sorry, I made a misleading comment about this. Jitu corrected me in a previous message: Closable extends AutoClosable, so everything works in ARM blocks as it exists today.

My apologies for incorrectly suggesting otherwise.

-Jonathan


-+ wenshao +-


Date: Sat, 15 Dec 2012 10:21:20 -0800
From:  ">
To:  ">
Subject: [jsr353-experts] Re: JsonParser.close() and exceptions

On 12/15/12 9:45 AM, Werner Keil wrote:
">Why would we target Java 6 with this release?
Java 7 is final, and I heard, 6 is phased out by March 2013 or so.
It would make great sense, to allow "try with resource" unless some users or developers insist on using Java 6 forever?
They can still take advantage of ARM blocks and use SE 7 features in the applications(It is just that we use Closeable instead of AutoCloseable in the API but that doesn't restrict them to use only wiht SE 6)

My preference is to use SE 7 as the base. We had the following discussion[1] and some of them suggested the need to use SE 6, so we went with it. If that's not case, let me know. We can gladly use SE 7 as the base and AutoCloseable !

Jitu

[1] http://java.net/projects/json-processing-spec/lists/users/archive/2012-10/message/2

">While leaving subsetting an option for later (AFAIK CLDC 8 also plans to support "try with resource" the main scope for this JSR is Java EE7 which is based on Java7 anyway.
Werner
Am 15.12.2012 18:39 schrieb "Jonathan Fuerth" < "> >:
JsonParser.close() documents that it closes the underlying input source if there is one. The underlying input source is wrapped in JsonTokenizer and JsonTokenizerReader, both of which declare IOException on their close() methods and let any exceptions pass through. But JsonParserImpl.close() chooses to wrap the IOException in an (unchecked) JsonException. This is not mentioned in the doc comment.

At first I was going to file a JIRA with a suggested rewording of the doc comment on JsonParser.close(), but I think this warrants discussion.

I guess the value of using the unchecked JsonException on JsonParser.close() is that it eliminates the need for exception handling when client code knows it is using the JsonStructureParser implementation, which never throws IOExceptions. On the other hand, leaving JsonParser.close() without a checked IOException tempts lazy developers (like me!) to leave off the try/catch around the call to close(), even when we know there might be a real InputStream underneath.

On the other other hand, none of this matters much when JsonParser is used together with try-with-resources in Java 7. In this case, close() will always be called with proper exception handling. But I guess we're still targeting JDK6 with this API.

I think my preference is still for IOException in JsonParser.close(). What does everyone else think?

-Jonathan





[jsr353-experts] JsonParser.close() and exceptions

Jonathan Fuerth 12/15/2012

[jsr353-experts] Re: JsonParser.close() and exceptions

Werner Keil 12/15/2012

[jsr353-experts] Re: JsonParser.close() and exceptions

Jitendra Kotamraju 12/15/2012

[jsr353-experts] Re: JsonParser.close() and exceptions

Werner Keil 12/17/2012

[jsr353-experts] Re: [json-processing-spec users] Re: JsonParser.close() and exceptions

Jonathan Fuerth 12/17/2012

[jsr353-experts] Re: [json-processing-spec users] Re: JsonParser.close() and exceptions

Werner Keil 12/17/2012

[jsr353-experts] Re: JsonParser.close() and exceptions

wenshao 12/17/2012

[jsr353-experts] Re: [json-processing-spec users] Re: JsonParser.close() and exceptions

Jonathan Fuerth 12/17/2012

[jsr353-experts] Re: [json-processing-spec users] Re: JsonParser.close() and exceptions

Werner Keil 12/17/2012

[jsr353-experts] Re: [json-processing-spec users] Re: Re: JsonParser.close() and exceptions

Jonathan Fuerth 12/17/2012

[jsr353-experts] Re: [json-processing-spec users] Re: Re: JsonParser.close() and exceptions

Werner Keil 12/17/2012

[jsr353-experts] Re: [json-processing-spec users] Re: Re: Re: JsonParser.close() and exceptions

wenshao 12/18/2012

[jsr353-experts] Re: JsonParser.close() and exceptions

Werner Keil 12/17/2012
 
 
Close
loading
Please Confirm
Close