[java-support] branch master updated: JSPT-70: HttpClientBuilder should support maxTotal and defaultMaxPerRoute properties

Brent Putman putmanb at georgetown.edu
Mon Oct 17 19:19:24 EDT 2016


This is an automated email from the git hooks/post-receive script.

putmanb pushed a commit to branch master
in repository java-support.

View the commit online:
http://git.shibboleth.net/view/?p=java-support.git;a=commit;h=dcda1354aaf92777053d41876178d59ad01a4a3a

The following commit(s) were added to refs/heads/master by this push:
       new  dcda135   JSPT-70: HttpClientBuilder should support maxTotal and defaultMaxPerRoute properties
dcda135 is described below

commit dcda1354aaf92777053d41876178d59ad01a4a3a
Author: Brent Putman <putmanb at georgetown.edu>
AuthorDate: Mon Oct 17 19:19:23 2016 -0400

    JSPT-70: HttpClientBuilder should support maxTotal and
    defaultMaxPerRoute properties
---
 .../java/support/httpclient/HttpClientBuilder.java | 59 ++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/src/main/java/net/shibboleth/utilities/java/support/httpclient/HttpClientBuilder.java b/src/main/java/net/shibboleth/utilities/java/support/httpclient/HttpClientBuilder.java
index 1447b84..8c5d728 100644
--- a/src/main/java/net/shibboleth/utilities/java/support/httpclient/HttpClientBuilder.java
+++ b/src/main/java/net/shibboleth/utilities/java/support/httpclient/HttpClientBuilder.java
@@ -110,9 +110,12 @@ import net.shibboleth.utilities.java.support.primitive.StringSupport;
  * </p>
  * 
  * <ul>
+ * <li>{@link #setTLSSocketFactory(LayeredConnectionSocketFactory)}</li>
  * <li>{@link #setConnectionDisregardTLSCertificate(boolean)}</li>
  * <li>{@link #setSocketBufferSize(int)}</li>
  * <li>{@link #setHttpContentCharSet(String)}</li>
+ * <li>{@link #setMaxConnectionsTotal(int)}</li>
+ * <li>{@link #setMaxConnectionsPerRoute(int)}</li>
  * </ul>
  * 
  * <p>
@@ -161,6 +164,16 @@ public class HttpClientBuilder {
      * manager. Default value: TBD;
      */
     private int connectionRequestTimeout;
+    
+    /**
+     * Max total simultaneous connections allowed by the pooling connection manager.
+     */
+    private int maxConnectionsTotal;
+    
+    /**
+     * Max simultaneous connections per route allowed by the pooling connection manager.
+     */
+    private int maxConnectionsPerRoute;
 
     /** Whether the SSL/TLS certificates used by the responder should be ignored. Default value: false */
     private boolean connectionDisregardTLSCertificate;
@@ -258,6 +271,8 @@ public class HttpClientBuilder {
 
     /** Resets all builder parameters to their defaults. */
     public void resetDefaults() {
+        maxConnectionsTotal = -1;
+        maxConnectionsPerRoute = -1;
         socketLocalAddress = null;
         socketBufferSize = 8192;
         socketTimeout = -1;
@@ -276,6 +291,42 @@ public class HttpClientBuilder {
     }
 
     /**
+     * Gets the max total simultaneous connections allowed by the pooling connection manager.
+     * 
+     * @return the max total connections
+     */
+    public int getMaxConnectionsTotal() {
+        return maxConnectionsTotal;
+    }
+
+    /**
+     * Sets the max total simultaneous connections allowed by the pooling connection manager.
+     * 
+     * @param max the max total connection
+     */
+    public void setMaxConnectionsTotal(int max) {
+        maxConnectionsTotal = max;
+    }
+
+    /**
+     * Gets the max simultaneous connections per route allowed by the pooling connection manager.
+     * 
+     * @return the max connections per route
+     */
+    public int getMaxConnectionsPerRoute() {
+        return maxConnectionsPerRoute;
+    }
+
+    /**
+     * Sets the max simultaneous connections per route allowed by the pooling connection manager.
+     * 
+     * @param max the max connections per route
+     */
+    public void setMaxConnectionsPerRoute(int max) {
+        maxConnectionsPerRoute = max;
+    }
+
+    /**
      * Gets the local IP address used when making requests.
      * 
      * @return local IP address used when making requests
@@ -913,6 +964,14 @@ public class HttpClientBuilder {
             }
         }
         
+        if (maxConnectionsTotal > 0) {
+            builder.setMaxConnTotal(maxConnectionsTotal);
+        }
+        
+        if (maxConnectionsPerRoute > 0) {
+            builder.setMaxConnPerRoute(maxConnectionsPerRoute);
+        }
+        
         if (retryHandler != null) {
             builder.setRetryHandler(retryHandler);
         }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list