Hi Francesco, I reverted a WebClient.close() -> Response.close() code
sequence for now anyway, see [1]. It is unlikely JAX-RS 2.0
Client.close() would be requested to track all of the Responses to make
sure it auto closes them too and I'd like WebClient.close be consistent
with the standard approach.
Thanks, Sergey
[1] https://issues.apache.org/jira/browse/CXF-5865
On 09/07/14 10:32, Sergey Beryozkin wrote:
Hi Francesco
On 09/07/14 10:16, Francesco Chicchiriccò wrote:
On 09/07/2014 10:45, Francesco Chicchiriccò wrote:
iI all,
this snippet
WebClient client = ...;
Response response = client.invoke(method, inputStream);
response.getEntity();
fails with
java.lang.IllegalStateException: Entity is not available
at
org.apache.cxf.jaxrs.impl.ResponseImpl.checkEntityIsClosed(ResponseImpl.java:475)
at
org.apache.cxf.jaxrs.impl.ResponseImpl.getActualEntity(ResponseImpl.java:137)
at
org.apache.cxf.jaxrs.impl.ResponseImpl.getEntity(ResponseImpl.java:142)
I am using CXF 3.0.0 (the same code works fine with CXF 2.7.11): any
idea?
It seems I've over-simplified the snippet above: it should have been,
actually
WebClient client = ...;
Response response = client.invoke(method, inputStream);
client.close();
response.getEntity();
It seems that with CXF 3.0.0 closing a client implies also closing the
response object, thus causing the exception above: correct?
Yes. I did it for the code to stay in sync with
https://jax-rs-spec.java.net/nonav/2.0/apidocs/javax/ws/rs/client/Client.html#close()
"Close client instance and all it's associated resources" implied to me
that a Response Input Stream also needs to be closed due to it being a
'production' of the client activity.
However now I'm not exactly sure a Response needs to be closed if the
client is closed. There's no any guidance right now in JAX-RS 2.0 docs
so I'll ask and get back
Thanks, Sergey
Regards.
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com