Many thanks Sergey this makes it clear.. We will ensure we close both the response and client explicitly.
Sent from a mobile device > On 26 Aug 2014, at 10:42, Sergey Beryozkin <[email protected]> wrote: > > Hi Mandy, > good to hear from you again, > >> On 25/08/14 22:29, Mandy Warren wrote: >> Hi, >> >> We are currently using the jax rs WebClient class to call Rest URLs from >> services we are developing. Up until now we haven't been explicitly calling >> "close" on the Response or the WebClient objects as none of the examples I >> have seen showed this but after looking more closely at the APIs I see the >> close() methods exist. >> >> The javadoc implies close() is called on the response when you use the >> readEntity() method but should I assume that if I just checked the response >> status code and didn't consume the entity then I should do an explicit close? > > Response is auto-closed if we have Response.readEntity where the class type > is not InputStream. I guess calling Response.close() if no entity is expected > back is not strictly required, all Response.close does (in CXF case) is it > tries to close response InputStream if it is not null. > I'm not 100% sure but I believe that in some cases the response InputStream > is not null even if no entity is provided, so calling close() might help > recycling the transport resources faster even in such cases. >> >> org.apache.cxf.jaxrs.client.AbstractClient (which WebClient inherits) has a >> close() method, again should I call this explicitly? Currently we create a >> new WebClient for every call rather than reuse a single instance. > Doing WebClient.close primarily helps to clean up various state associated > with a given client, I've copied the code from the CXF JAX-WS client, > example, CXF ClientLifeCycleManager is notified. > At some point, in 3.0.0 I think, closing WebClient was also closing the > associated Response, but it's no longer the case > > Thanks, Sergey >> Pls note I am using cxf 2.7.12 >> >> Many thanks >> Mandy >
