Hi all-

We've started using Restlet's HttpClient extension (along with Apache
HttpClient 4.01).

We've hit what seems like a pretty big bug: when we make a client
request using the ClientResource API, if we GET a resource that does
not exist, that process seems to consume and never release an
HttpClient connection object.  After GETing a few times with 404
responses, all subsequent requests to that host will block forever.
Since the connection objects are pooled, and the default is 2, we are
seeing a hung system reproducibly on the 3rd attempt.

I believe something like the following code will trigger this condition:

ClientResource resource = new
ClientResource("http://www.restlet.org/DoesNotExist.html";);
Representation entity = null;

// first time
try {
  entity = resource.get();
} catch (ResourceException re) {
  re.printStackTrace(); // <---- this will show a 404 Status
}
//second time
try {
  entity = resource.get();
} catch (ResourceException re) {
  re.printStackTrace(); // <---- this will show a 404 Status
}
// third time
try {
  entity = resource.get(); // <---- this will hang forever!
} catch (ResourceException re) {
  re.printStackTrace();
}

(Obviously our code is not actually like this- we would have these
multiple client GET requests triggered by use of our web app's
resources, which are in turn fetching some (often absent) data from
another server.)

Since we don't have an entity in a response, we can't call
representation.exhaust() on it, and when we add finally() clauses to
the above which call resource.release(), nothing is different. (I'm
not clear at all under what circumstances we're supposed to call
ClientResource.release(), but it didn't help.)

The problem goes away when we turn off the org.restlet.ext.httpclient
extension and use the built-in client connectors.  We'd prefer to use
HttpClient, since we have a dependency on it anyhow from other code in
our system.  (Is the built-in client connector production-ready?  Will
it scale up to many concurrent requests?)

Any suggestions?

Thanks,
  -Dave Fogel

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2632432

Reply via email to