hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1793762 - /httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientBuilder.java
Date Thu, 04 May 2017 09:42:53 GMT
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,



Mime
View raw message