On Wed, 2014-03-05 at 14:57 +0200, Jose Dillet wrote:
> I have observed some differences between httpasyncclient 4.0-beta3 and
> 4.0.1 when the client is closed / shutdown and there are still pending
> requests.
> This can be observed by running AsyncClientHttpExchange and closing the
> client while the request is not yet completed.
> 
> a) httpasyncclient-4.0-beta3.jar, httpclient-4.2.3.jar, httpcore-4.2.3.jar,
> uses DefaultHttpAsyncClient implementation:
> HttpAsyncClient httpclient = new DefaultHttpAsyncClient();
> httpclient.start();
> final HttpGet request = new HttpGet("http://www.apache.org/";);
> Future<HttpResponse> future = httpclient.execute(request, myCallback);
> httpclient.shutdown();    // maybe done by some other thread
> HttpResponse response = future.get();
> 
> b) httpasyncclient-4.0.1.jar, httpclient-4.3.2.jar, httpcore-4.3.2.jar,
> uses InternalHttpAsyncClient implementation:
> CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault();
> httpclient.start();
> final HttpGet request = new HttpGet("http://www.apache.org/";);
> Future<HttpResponse> future = httpclient.execute(request, myCallback);
> httpclient.close();      // maybe done by some other thread
> HttpResponse response = future.get();
> 
> Generally it makes no sense to close the client in the same thread before
> getting the response, but that might happen in our application on a
> different thread.
> 
> In case a) cancelled is invoked on myCallback. In case b) cancelled is not
> invoked, and the request hangs in future.get()
> 
> Is this change in the behavior expected, a bug or just some not documented
> behavior in a corner case?
> 

Jose

It was a conscious decision to remove this feature from 4.0 GA. Keeping
track of all pending requests required a non-trivial amount of code and
a non-negligible performance overhead due to having to maintain an extra
queue with synchronized access. I was not sure it was worth it for what
was essentially a fringe case.

We could re-visit this issue for 4.1, though.

Oleg



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
For additional commands, e-mail: httpclient-users-h...@hc.apache.org

Reply via email to