You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Mario Winterer <ma...@gmail.com> on 2010/05/15 18:56:09 UTC

Aborting requests via Thread.interrupt()?

Hi!

Is it possible to abort an ongoing HTTP request by calling
Thread.interrupt() on the thread currently
executing HttpClient.execute(...)?
The tutorial only mentions HttpUriRequest.abort(), which is nice but
proprietary (code that does not have access to the request object is not
able to abort it - this may happen if the request is executed behind some
[blocking] API).

Thanks,
  Mario

Re: Aborting requests via Thread.interrupt()?

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Sat, 2010-05-15 at 18:56 +0200, Mario Winterer wrote:
> Hi!
> 
> Is it possible to abort an ongoing HTTP request by calling
> Thread.interrupt() on the thread currently
> executing HttpClient.execute(...)?
> The tutorial only mentions HttpUriRequest.abort(), which is nice but
> proprietary (code that does not have access to the request object is not
> able to abort it - this may happen if the request is executed behind some
> [blocking] API).
> 
> Thanks,
>   Mario

Mario,

The trouble is Thread#interrupt() does not reliably interrupt blocking
I/O operations. The only truly reliable way to interrupt an I/O
operation is by shutting down the socket, which is what
HttpUriRequest#abort() does.

Oleg 



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