hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HTTPCLIENT-1485) Wrong type of exception raised because of hardcoded string-compare
Date Sat, 22 Mar 2014 14:08:38 GMT

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

Sebb commented on HTTPCLIENT-1485:

I'm not sure what defines the OS timeout.

But the point is that most other errors that generate a ConnectException will happen immediately
or at least within a few seconds.

So if the connect takes significantly longer, it is most likely going to be a connect timeout
rather than some other error.
As it stands, some timeouts are currently reported incorrectly because the text matching is
not generic.
(AFAICT does not work on FreeBSD or WindowsXP)

The worst that could happen with opton 3 is that some other error is reported as a timeout.
But given that the connect has taken a long time to reach the exception, timeout seems a reasonable
In any case, the orginal exception is passed to the timeout exception.

> Wrong type of exception raised because of hardcoded string-compare
> ------------------------------------------------------------------
>                 Key: HTTPCLIENT-1485
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1485
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient
>    Affects Versions: 4.3.2, 4.3.3
>            Reporter: Dominik Bennersdorfer
> In the lines org.apache.http.impl.conn.HttpClientConnectionOperator.java:134-143 we found
that the message of the ConnectException is compared to the hardcoded string "Connection timed
> This can causes wrong break down to the http-client own Exception-types on Systems with
other languages.
> } catch (final ConnectException ex) {
> 	if (last) {
> 		final String msg = ex.getMessage();
> 		if ("Connection timed out".equals(msg)) {
> 			throw new ConnectTimeoutException(ex, host, addresses);
> 		} else {
> 			throw new HttpHostConnectException(ex, host, addresses);
> 		}
> 	}
> }
> To illustrate the Problem see the following Example:
> On our server the locale is set to "de_AT.ISO-8859-15@euro" 
> with a simple wget i get this (see the message in last line)
> root@MRW-MJA-vml1:/tmp# wget http://www.google.at:81
> --2014-03-14 12:46:44--  http://www.google.at:81/
> Auflösen des Hostnamen www.google.at...
> Verbindungsaufbau zu www.google.at||:81... fehlgeschlagen: Die Wartezeit
für die Verbindung ist abgelaufen.
> after changing the locale to "en_US.ISO-8859-15" i get the following:
> root@MRW-MJA-vml1:/tmp# wget http://www.google.at:81
> --2014-03-14 12:43:33--  http://www.google.at:81/
> Resolving www.google.at...
> Connecting to www.google.at||:81... failed: Connection timed out.
> Example with httpclient 4.3.3 (parts from our tracing):
> Exception<org.apache.http.conn.HttpHostConnectException> Message<Connect to
**** failed: Die Wartezeit für die Verbindung ist abgelaufen> 
> Cause<java.net.ConnectException: Die Wartezeit für die Verbindung ist abgelaufen>

> 	at org.apache.http.impl.conn.HttpClientConnectionOperator.connect(HttpClientConnectionOperator.java:138)
> 	at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:314)
> 	at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:357)
> 	at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:218)
> 	at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:194)
> 	at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:85)
> 	at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:108)
> 	at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:186)
> 	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
> 	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:106)
> We excpected to get a ConnectTimeoutException rather than a HttpHostConnectException

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