Added static method to close idle connections used by the fluent executor

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1603444 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2014-06-18 13:07:11 +00:00
parent 2ebd820284
commit 48c22cc202
2 changed files with 11 additions and 5 deletions

View File

@ -29,6 +29,7 @@ package org.apache.http.client.fluent;
import java.io.IOException; import java.io.IOException;
import java.security.KeyManagementException; import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLContext; import javax.net.ssl.SSLContext;
@ -220,4 +221,12 @@ public class Executor {
public static void unregisterScheme(final String name) { 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);
}
} }

View File

@ -29,7 +29,6 @@ package org.apache.http.client.fluent;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.util.concurrent.TimeUnit;
import org.apache.http.HttpEntity; import org.apache.http.HttpEntity;
import org.apache.http.HttpEntityEnclosingRequest; import org.apache.http.HttpEntityEnclosingRequest;
@ -95,10 +94,8 @@ public class TestFluent extends LocalServerTestBase {
@After @Override @After @Override
public void shutDown() throws Exception { public void shutDown() throws Exception {
if (this.server != null) { Executor.closeIdleConnections();
this.server.shutdown(100, TimeUnit.MILLISECONDS); super.shutDown();
this.server = null;
}
} }
@Test @Test