users@jax-rs-spec.java.net

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

From: Santiago Pericas-Geertsen <Santiago.PericasGeertsen_at_oracle.com>
Date: Thu, 2 Oct 2014 08:12:38 -0400

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
>