On 22 November 2012 15:57, Oleg Kalnichevski <[email protected]> wrote:
> On Thu, 2012-11-22 at 15:41 +0000, James Shaw wrote: > > On 22 November 2012 15:35, Oleg Kalnichevski <[email protected]> wrote: > > > > > On Thu, 2012-11-22 at 15:02 +0000, James Shaw wrote: > > > > I've been looking at making my HttpClient interruptible. To do > this, I'm > > > > creating my own SocketFactory and registering it in a SchemeRegistry. > > > But > > > > I'm now having an issue where the request is being retried three > times, > > > > each time catching ClosedByInterruptException. > > > > > > > > I see that InterruptedIOException is already caught by > > > > DefaultHttpRequestRetryHandler. Should ClosedByInterruptException be > > > > added, too? > > > > > > Hmm. As far as I understand ClosedByInterruptException can be thrown > > > only when using NIO channels, which HttpClient does not make use of per > > > default. Anyway, obviously in your particular case you should probably > > > be using a custom HttpRequestRetryHandler as well. > > > > > Yup, that's what I'm doing. Out of interest, does HttpClient have any > > support for interruptible sockets? Does what I'm doing sound sane? :-) > > This depends on your definition of what constitutes an interruptible > socket. HttpClient makes sure that a request can aborted at any point of > its execution using HttpUriRequest#abort method. This, however, achieved > by shutting down the underlying connection by closing its network > socket. > > So, what is exactly you are trying to accomplish through interruptible > sockets? I'm trying to interrupt an HTTP call if it takes longer than some timeout value. This timeout applies to the entire request-response cycle, rather than Java's read and connect timeouts. I came across HttpUriRequest#abort while reading the docs yesterday. I'm actually using HttpClient via Jersey, so I'm not sure if I can get access to this from the Jersey layer. I'll post to the Jersey list and see what they have to say.
