Can you please provide a real-worl use case where an application does not know from ist very own state that the response is closed? I mean, responses do not get closed just by incident. Typically an application does not have any need to fear that a just received response instance may become closed unless it tends to store them somewhere.
-Markus
From: jaxrs-dev-bounces@xxxxxxxxxxx [mailto:jaxrs-dev-bounces@xxxxxxxxxxx] On Behalf Of Ron Sigal
Sent: Mittwoch, 28. November 2018 01:31
To: jaxrs-dev@xxxxxxxxxxx
Subject: [jaxrs-dev] Request for extension to Response
A number of javax.ws.rs.core.Response methods, e.g., getEntity() and hasEntity(), include a line in the javadoc like
* @throws IllegalStateException in case the response has been {@link #close() closed}.
However, in the absence of a method like isClosed(), we end up writing code like
try {
if (response.getEntity() != null) return response;
}
catch(IllegalStateException ise) {
// IllegalStateException from ClientResponse.getEntity() means the response is closed and got no entity
}
instead of
if (!response.isClosed() && response.getEntity() != null) {
return response;
}
The implementation of isClosed() should be simple, and it leads to nicer code.
-Ron
--
My company's smarter than your company (unless you work for Red Hat)