diff --git a/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java b/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java index 6ce9927d2..e393db2ff 100644 --- a/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java +++ b/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java @@ -29,6 +29,7 @@ package org.apache.http.client.fluent; import java.io.IOException; import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; +import java.util.concurrent.TimeUnit; import javax.net.ssl.SSLContext; @@ -220,4 +221,12 @@ public class Executor { public static void unregisterScheme(final String name) { } + /** + * Closes all idle persistent connections used by the internal pool. + * @since 4.4 + */ + public static void closeIdleConnections() { + CONNMGR.closeIdleConnections(0, TimeUnit.MICROSECONDS); + } + } diff --git a/fluent-hc/src/test/java/org/apache/http/client/fluent/TestFluent.java b/fluent-hc/src/test/java/org/apache/http/client/fluent/TestFluent.java index cb6f10853..1a1d86df4 100644 --- a/fluent-hc/src/test/java/org/apache/http/client/fluent/TestFluent.java +++ b/fluent-hc/src/test/java/org/apache/http/client/fluent/TestFluent.java @@ -29,7 +29,6 @@ package org.apache.http.client.fluent; import java.io.File; import java.io.IOException; import java.nio.charset.Charset; -import java.util.concurrent.TimeUnit; import org.apache.http.HttpEntity; import org.apache.http.HttpEntityEnclosingRequest; @@ -95,10 +94,8 @@ public class TestFluent extends LocalServerTestBase { @After @Override public void shutDown() throws Exception { - if (this.server != null) { - this.server.shutdown(100, TimeUnit.MILLISECONDS); - this.server = null; - } + Executor.closeIdleConnections(); + super.shutDown(); } @Test