diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java b/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java index 4c38bd88c..af97d8afe 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java @@ -30,6 +30,7 @@ import java.io.Closeable; import java.io.IOException; import java.util.Map; import java.util.Set; +import java.util.concurrent.CancellationException; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; @@ -302,7 +303,7 @@ public class PoolingHttpClientConnectionManager try { entry = future.get(timeout, timeUnit); if (entry == null || future.isCancelled()) { - throw new InterruptedException(); + throw new ExecutionException(new CancellationException("Operation cancelled")); } Asserts.check(entry.getConnection() != null, "Pool entry with no connection"); if (this.log.isDebugEnabled()) { diff --git a/httpclient/src/test/java/org/apache/http/impl/conn/TestPoolingHttpClientConnectionManager.java b/httpclient/src/test/java/org/apache/http/impl/conn/TestPoolingHttpClientConnectionManager.java index 5b379d3a3..51bc2ef1b 100644 --- a/httpclient/src/test/java/org/apache/http/impl/conn/TestPoolingHttpClientConnectionManager.java +++ b/httpclient/src/test/java/org/apache/http/impl/conn/TestPoolingHttpClientConnectionManager.java @@ -30,6 +30,7 @@ package org.apache.http.impl.conn; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.Socket; +import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -147,7 +148,7 @@ public class TestPoolingHttpClientConnectionManager { Mockito.verify(pool).release(entry, false); } - @Test(expected=InterruptedException.class) + @Test(expected= ExecutionException.class) public void testLeaseFutureCancelled() throws Exception { final HttpHost target = new HttpHost("localhost", 80); final HttpRoute route = new HttpRoute(target);