hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Osipov (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HTTPCLIENT-1603) ClientProtocolException contradicts tutorial statement in chapter 1.4
Date Tue, 27 Jan 2015 21:25:35 GMT

    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1603?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14294213#comment-14294213

Michael Osipov commented on HTTPCLIENT-1603:

Checked changes. That looks better now.

One facts astounds me which I and probably many others were not aware of:

bq. Please note that <interfacename>HttpClient</interfacename> implementations
re-throw <exceptionname>HttpException</exceptionname>s as <exceptionname>ClientProtocolException</exceptionname>,
which is a subclass of <exceptionname>java.io.IOException</exceptionname>. This
enables the users of <interfacename>HttpClient</interfacename> to handle both
I/O errors and protocol violations from a single catch clause.</para>

Though, I do not see the bonus here if you use Java 7, moreover if {{ClientProtocolException}}
wraps a low-level {{HttpException}} which is not an {{IOException}}, I do not understand why
{{ClientProtocolException}} inherits from {{IOException}}. That is confusing. Convenience,

> ClientProtocolException contradicts tutorial statement in chapter 1.4
> ---------------------------------------------------------------------
>                 Key: HTTPCLIENT-1603
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1603
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: Documentation, HttpClient
>    Affects Versions: 4.3.6, 4.4 Beta1
>            Reporter: Michael Osipov
>            Priority: Minor
>             Fix For: 4.4 Final
> [Chapter 1.4|http://hc.apache.org/httpcomponents-client-ga/tutorial/html/fundamentals.html#d5e271]
says: "HttpClient can throw two types of exceptions: {{java.io.IOException}} in case of an
I/O failure such as socket timeout or an socket reset and {{HttpException}} that signals an
HTTP failure such as a violation of the HTTP protocol. Usually I/O errors are considered non-fatal
and recoverable, whereas HTTP protocol errors are considered fatal and cannot be automatically
recovered from."
> The [Javadoc|http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/ClientProtocolException.html]
of {{ClientProtocolException}} says: "Signals an error in the HTTP protocol." Given the definition
established in the tutorial, either one is incorrect. Either {{ClientProtocolException}} must
derive from {{HttpException}} or its documentation must be contrary to the latter.

This message was sent by Atlassian JIRA

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

View raw message