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