Merge branch 'HTTPCLIENT-1958' into 4.5.x

This commit is contained in:
Oleg Kalnichevski 2019-01-10 09:52:55 +01:00
commit 024f692df3
2 changed files with 4 additions and 2 deletions

View File

@ -30,6 +30,7 @@ import java.io.Closeable;
import java.io.IOException; import java.io.IOException;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future; import java.util.concurrent.Future;
@ -302,7 +303,7 @@ public class PoolingHttpClientConnectionManager
try { try {
entry = future.get(timeout, timeUnit); entry = future.get(timeout, timeUnit);
if (entry == null || future.isCancelled()) { 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"); Asserts.check(entry.getConnection() != null, "Pool entry with no connection");
if (this.log.isDebugEnabled()) { if (this.log.isDebugEnabled()) {

View File

@ -30,6 +30,7 @@ package org.apache.http.impl.conn;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.Socket; import java.net.Socket;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
@ -147,7 +148,7 @@ public class TestPoolingHttpClientConnectionManager {
Mockito.verify(pool).release(entry, false); Mockito.verify(pool).release(entry, false);
} }
@Test(expected=InterruptedException.class) @Test(expected= ExecutionException.class)
public void testLeaseFutureCancelled() throws Exception { public void testLeaseFutureCancelled() throws Exception {
final HttpHost target = new HttpHost("localhost", 80); final HttpHost target = new HttpHost("localhost", 80);
final HttpRoute route = new HttpRoute(target); final HttpRoute route = new HttpRoute(target);