You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Marcelo Cenerino (JIRA)" <ji...@apache.org> on 2018/08/11 15:23:00 UTC
[jira] [Created] (HTTPCLIENT-1941) HttpAsyncClient throws generic
exception when connection lease request times out
Marcelo Cenerino created HTTPCLIENT-1941:
--------------------------------------------
Summary: HttpAsyncClient throws generic exception when connection lease request times out
Key: HTTPCLIENT-1941
URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1941
Project: HttpComponents HttpClient
Issue Type: Improvement
Components: HttpClient (async)
Reporter: Marcelo Cenerino
The classic HttpClient throws a "org.apache.http.conn.ConnectionPoolTimeoutException" when a connection cannot be obtained within a given timeout. The async HttpClient, on the other hand, throws a generic "java.util.concurrent.TimeoutException":
- org.apache.http.nio.pool.AbstractNIOConnPool:
{code:java}
final long deadline = request.getDeadline();
final long now = System.currentTimeMillis();
if (now > deadline) {
request.failed(new TimeoutException());
return false;
}
{code}
The specific "ConnectionPoolTimeoutException" was handier, both to catch and handle it in the code as well as to analise stack traces.
The classic HttpClient translates the "java.util.concurrent.TimeoutException" into "org.apache.http.conn.ConnectionPoolTimeoutException":
- org.apache.http.impl.conn.PoolingHttpClientConnectionManager:
{code:java}
protected HttpClientConnection leaseConnection(
final Future<CPoolEntry> future,
final long timeout,
final TimeUnit tunit) throws InterruptedException, ExecutionException, ConnectionPoolTimeoutException {
final CPoolEntry entry;
try {
// omitted
} catch (final TimeoutException ex) {
throw new ConnectionPoolTimeoutException("Timeout waiting for connection from pool");
}
}
{code}
It would be nice if the async client did the same.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org