HTTPCLIENT-1826: HttpAsyncClientBuilder to accept ThreadFactory attribute

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1793762 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2017-05-04 09:42:53 +00:00
parent fed4b907eb
commit 196ee3363e
1 changed files with 13 additions and 2 deletions

View File

@ -34,6 +34,7 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.ThreadFactory;
import org.apache.hc.client5.http.ConnectionKeepAliveStrategy; import org.apache.hc.client5.http.ConnectionKeepAliveStrategy;
import org.apache.hc.client5.http.SchemePortResolver; import org.apache.hc.client5.http.SchemePortResolver;
@ -236,6 +237,8 @@ public class HttpAsyncClientBuilder {
private boolean authCachingDisabled; private boolean authCachingDisabled;
private boolean connectionStateDisabled; private boolean connectionStateDisabled;
private ThreadFactory threadFactory;
private List<Closeable> closeables; private List<Closeable> closeables;
public static HttpAsyncClientBuilder create() { public static HttpAsyncClientBuilder create() {
@ -480,6 +483,14 @@ public class HttpAsyncClientBuilder {
return this; return this;
} }
/**
* Assigns {@link ThreadFactory} instance.
*/
public final HttpAsyncClientBuilder setThreadFactory(final ThreadFactory threadFactory) {
this.threadFactory = threadFactory;
return this;
}
/** /**
* Assigns {@code User-Agent} value. * Assigns {@code User-Agent} value.
*/ */
@ -875,7 +886,7 @@ public class HttpAsyncClientBuilder {
ioReactor = new DefaultConnectingIOReactor( ioReactor = new DefaultConnectingIOReactor(
ioEventHandlerFactory, ioEventHandlerFactory,
ioReactorConfig != null ? ioReactorConfig : IOReactorConfig.DEFAULT, ioReactorConfig != null ? ioReactorConfig : IOReactorConfig.DEFAULT,
new DefaultThreadFactory("httpclient-dispatch", true), threadFactory != null ? threadFactory : new DefaultThreadFactory("httpclient-dispatch", true),
new Callback<IOSession>() { new Callback<IOSession>() {
@Override @Override
@ -944,7 +955,7 @@ public class HttpAsyncClientBuilder {
ioReactor, ioReactor,
execChain, execChain,
pushConsumerRegistry, pushConsumerRegistry,
new DefaultThreadFactory("httpclient-main", true), threadFactory != null ? threadFactory : new DefaultThreadFactory("httpclient-main", true),
connManagerCopy, connManagerCopy,
routePlannerCopy, routePlannerCopy,
versionPolicy != null ? versionPolicy : HttpVersionPolicy.NEGOTIATE, versionPolicy != null ? versionPolicy : HttpVersionPolicy.NEGOTIATE,