[ 
https://issues.apache.org/jira/browse/HTTPCLIENT-1941?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Marcelo Cenerino updated HTTPCLIENT-1941:
-----------------------------------------
    Description: 
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.

In fact, the classic HttpClient translates the "j.u.c.TimeoutException" into 
"o.a.h.c.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. However, this could break 
existing code relying on the current behavior.

  was:
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.


> 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
>            Priority: Major
>
> 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.
> In fact, the classic HttpClient translates the "j.u.c.TimeoutException" into 
> "o.a.h.c.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. However, this could break 
> existing code relying on the current behavior.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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

Reply via email to