You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by bu...@apache.org on 2004/07/15 15:48:39 UTC
DO NOT REPLY [Bug 30122] New: -
HttpRecoverableException should store cause exception
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=30122>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=30122
HttpRecoverableException should store cause exception
Summary: HttpRecoverableException should store cause exception
Product: Commons
Version: 2.0 Final
Platform: All
URL: http://jakarta.apache.org/commons/httpclient/apidocs/org
/apache/commons/httpclient/HttpRecoverableException.html
OS/Version: Other
Status: NEW
Severity: Enhancement
Priority: Other
Component: HttpClient
AssignedTo: commons-httpclient-dev@jakarta.apache.org
ReportedBy: znerd@FreeBSD.org
We are using the HttpClient library in XINS, a next-generation framework for
web-based services. A call to a XINS API is made over HTTP, using either GET or
POST. This call may fail due to a number of causes, for example:
1. connection refused
2. connection time-out
3. socket time-out
4. total call time-out
5. HTTP error code (5xx)
etc.
All these conditions need to be distinguished in the XINS client-side code, in
order to make the proper decision on whether or not fail-over should be attempted.
Cases 1, 2, 4 and 5 can be properly detected with HttpClient 2.0. However, case
3 can not be detected in a proper manner. If there is a socket time-out, then a
java.net.SocketTimeoutException is thrown. However, this exception is hidden
with the code like this:
} catch (IOException e) {
throw new HttpRecoverableException(e.toString());
}
Since Java 1.4, a cause can be associated with an exception instance. See the
class description of class Throwable:
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Throwable.html
Suggestion: Change the code as follows:
} catch (IOException e) {
throw new HttpRecoverableException(e.toString()).initCause(e);
}
If you don't want to make the code Java 1.4-specific, you could change the
HttpRecoverableException constructor to add a 'Throwable cause' or 'IOException
cause' argument, along with a getCauseException() method.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org