We recently have been hitting some issues with our use of Restlet
2.1/HTTPClient hanging and have tracked them down to not fully consuming the
response. This is well documented
(http://wiki.restlet.org/docs_2.0/13-restlet/27-restlet/328-restlet/285-restlet.html)
that it can happen and that we should do it, but what is still a bit of
mystery to me is what are the best practices here.
For instance, on the link above, the Java example uses the wrap method and then
just does the retrieve. Nowhere in the code does it show calling
exhaust/release afterwards. I realize that is a toy example, but it would be
good to know what proper code should look like. If you are using the wrap()
functionality, how and when should one call exhaust/release afterwards? For
now, we seem to find the best approach (at least it fixes our issue) is:
ClientResource cr = ...
try{
WrappedResource = cr.wrap(...)
...
catch(){
//
}
finally{
cr.getResponseEntity().exhaust()
cr.getResponseEntity().release()
}
Is that right? Is the wrap() method supposed to fully consume the response?
If not, how do we know the resulting return object (e.g. the Customer object in
the link) is properly populated?
Also, what are best practices for reusing, from within the same thread, the
same ClientResource/Wrapped Resource? For instance, I have two post calls that
create two different things at same endpoint. Can I reuse the
ClientResource/Wrapped Resource or do I need to fully consume the first one,
release it and then create it a second time?
Thanks,
Grant
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2964082