users@jax-rs-spec.java.net

[jax-rs-spec users] Re: Why does javax.ws.rs.core.Response not implement Closeable?

From: Steven Schlansker <stevenschlansker_at_gmail.com>
Date: Thu, 2 Oct 2014 10:21:40 -0700

It is true that both try-with-resources and AutoCloseable are Java 7 features, however Closeable has been around forever and is completely backwards compatible.
Iím glad to hear that it is coming in 2.1, though :)

On Oct 2, 2014, at 5:12 AM, Santiago Pericas-Geertsen <Santiago.PericasGeertsen_at_oracle.com> wrote:

> Steven,
>
> That's because try-with-resources and AutoClosable are SE 7 and JAX-RS 2.0 runs on SE 6. JAX-RS 2.1, upcoming in EE 8, will be able to take advantage of these new features.
>
> -- Santiago
>
> On Oct 1, 2014, at 6:18 PM, Steven Schlansker <stevenschlansker_at_gmail.com> wrote:
>
>> Hi jax-rs users,
>>
>> I am curious why Response does not implement Closeable.
>> That would allow all sorts of neat uses, in particular
>> try-with-resources:
>>
>> try (Response resp = httpClient.target(Ö).get()) {
>> // use resp
>> } // resp closed!
>>
>> It may seem like a very small issue, but does impact
>> usability in a non-trivial way.
>>
>> I didnít see a clear answer on the mailing list.
>> Hopefully someone can clarify.
>>
>> Thanks!
>> Steven
>>
>