hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: API review request / HttpException subclass of IOException
Date Mon, 26 May 2008 21:12:40 GMT
Jens Wilke wrote:
> On Monday 26 May 2008, Oleg Kalnichevski wrote:
>> Exception handling has been discussed A LOT in the early days of
>> HttpClient redesign.
> Hmm, well sorry, you asked for review and I took the chance... ;)

Yes, I did, and I do appreciate your expressing your views on it.

However, there are subjects different people tend to have different, at 
times conflicting, opinions on. Exception handling is one of those. We 
cannot make everyone happy.

>> The point is I/O exceptions are generally 
>> recoverable, whereas protocol exceptions are not, so, in my opinion,
>> keeping those two classes distinct is important.
> The IO exceptions we get from java.net and the exceptions we
> get from the http client may both be recoverable or not. Some exemplars:
> - IOException "host unknown" => typo, recoverable
> - IOException "host not reachable" => may or may not be recoverable, it depends...
> - IOException "connection refused" => clearly recoverable, just call the snoring admin
on the other side ;)
> - HttpException / MethodNotSupported => not recoverable
> - HttpException / InvalidCredentionsException => recoverable, typo. how does this
rely to 403?
> - HttpException / UnsupportedHttpVersionException => recoverable, fallback to 1.0
> By writing this up the question arises, what means recoverable? Just retry? Retry after
> user interaction?

These problems simply cannot be adequately addressed on the transport 
level. They are clearly application specific. HttpCore enforces a clear 
separation between I/O and protocol exceptions, because they do have 
completely different recovery strategies. If both exception types are 
not recoverable from your application point of view you should re-throw 
them as runtime exceptions.


> I don't see a concept which makes a real difference here. Everything above is a "protocol
> just different layers.
> OTOH putting HttpException under IOException doesn't make you loose anything. You can
declare it
> and someone can react on it, seperately if need.
> Best,
> Jens

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

View raw message