You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2017/05/04 09:42:53 UTC

svn commit: r1793762 - /httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientBuilder.java

Author: olegk
Date: Thu May  4 09:42:53 2017
New Revision: 1793762

URL: http://svn.apache.org/viewvc?rev=1793762&view=rev
Log:
HTTPCLIENT-1826: HttpAsyncClientBuilder to accept ThreadFactory attribute

Modified:
    httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientBuilder.java

Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientBuilder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientBuilder.java?rev=1793762&r1=1793761&r2=1793762&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientBuilder.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientBuilder.java Thu May  4 09:42:53 2017
@@ -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() {
@@ -481,6 +484,14 @@ public class HttpAsyncClientBuilder {
     }
 
     /**
+     * Assigns {@link ThreadFactory} instance.
+     */
+    public final HttpAsyncClientBuilder setThreadFactory(final ThreadFactory threadFactory) {
+        this.threadFactory = threadFactory;
+        return this;
+    }
+
+    /**
      * Assigns {@code User-Agent} value.
      */
     public final HttpAsyncClientBuilder setUserAgent(final String userAgent) {
@@ -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,