[java-shib-shared] branch main updated: JSSH-56: Implement HttpClient support for an overall request timeout

Brent Putman putmanb at georgetown.edu
Fri Dec 6 04:45:36 UTC 2024


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

putmanb pushed a commit to branch main
in repository java-shib-shared.

View the commit online:
http://git.shibboleth.net/view/?p=java-shib-shared.git;a=commit;h=7b2a23026a9991b5c768825af92add0d8d3745fd

The following commit(s) were added to refs/heads/main by this push:
     new 7b2a2302 JSSH-56: Implement HttpClient support for an overall request timeout
7b2a2302 is described below

commit 7b2a23026a9991b5c768825af92add0d8d3745fd
Author: Brent Putman <putmanb at georgetown.edu>
AuthorDate: Thu Dec 5 23:14:21 2024 -0500

    JSSH-56: Implement HttpClient support for an overall request timeout
    
    Change property to requestTimeoutCorePoolSize. Change its default to 20.
    Update docs to clarify what this property does.
---
 .../shared/httpclient/HttpClientBuilder.java       | 40 ++++++++++++++--------
 1 file changed, 25 insertions(+), 15 deletions(-)

diff --git a/shib-networking/src/main/java/net/shibboleth/shared/httpclient/HttpClientBuilder.java b/shib-networking/src/main/java/net/shibboleth/shared/httpclient/HttpClientBuilder.java
index a2bb076a..0d9c9e59 100644
--- a/shib-networking/src/main/java/net/shibboleth/shared/httpclient/HttpClientBuilder.java
+++ b/shib-networking/src/main/java/net/shibboleth/shared/httpclient/HttpClientBuilder.java
@@ -120,9 +120,9 @@ public class HttpClientBuilder {
      *  Default value: null */
     @Nullable private Duration requestTimeout;
 
-    /** Size of the {@link ScheduledExecutorService} used to implement requestTimeout handling. 
-     *  Default value: 100 */
-    private int requestTimeoutThreadPoolSize;
+    /** Core pool size of the {@link ScheduledExecutorService} used to implement requestTimeout handling. 
+     *  Default value: 20 */
+    private int requestTimeoutCorePoolSize;
 
     /**
      * Max total simultaneous connections allowed by the pooling connection manager.
@@ -259,7 +259,7 @@ public class HttpClientBuilder {
         schemePortResolver = null;
         
         requestTimeout = null;
-        requestTimeoutThreadPoolSize = 100;
+        requestTimeoutCorePoolSize = 20;
         
         disableAuthCaching = false;
         disableAutomaticRetries = false;
@@ -307,7 +307,7 @@ public class HttpClientBuilder {
         schemePortResolver = null;
         
         requestTimeout = null;
-        requestTimeoutThreadPoolSize = 100;
+        requestTimeoutCorePoolSize = 20;
         
         disableAuthCaching = false;
         disableAutomaticRetries = false;
@@ -449,23 +449,33 @@ public class HttpClientBuilder {
     }
 
     /**
-     * Gets the size of the {@link ScheduledExecutorService} used to implement requestTimeout handling. 
+     * Gets the core pool size of the {@link ScheduledExecutorService} used to implement requestTimeout handling. 
      * 
-     * @return the request timeout
+     * <p>
+     * This is the number of threads to keep in the pool, even if they are idle. The total number of threads in the
+     * pool is allowed to grow up to {@link Integer#MAX_VALUE}.
+     * </p>
+     * 
+     * @return the core pool size
      */
-    public int getRequestTimeoutThreadPoolSize() {
-        return requestTimeoutThreadPoolSize;
+    public int getRequestTimeoutCorePoolSize() {
+        return requestTimeoutCorePoolSize;
     }
 
     /**
-     * Sets the size of the {@link ScheduledExecutorService} used to implement requestTimeout handling. 
+     * Sets the core pool size of the {@link ScheduledExecutorService} used to implement requestTimeout handling. 
+     * 
+     * <p>
+     * This is the number of threads to keep in the pool, even if they are idle. The total number of threads in the
+     * pool is allowed to grow up to {@link Integer#MAX_VALUE}.
+     * </p>
      * 
-     * @param size the request timeout
+     * @param size the core pool size
      */
-    public void setRequestTimeoutThreadPoolSize(final int size) {
-        Constraint.isGreaterThanOrEqual(1, size, "Thread pool size is too small");
+    public void setRequestTimeoutCorePoolSize(final int size) {
+        Constraint.isGreaterThanOrEqual(1, size, "Core pool size is too small");
 
-        requestTimeoutThreadPoolSize = size;
+        requestTimeoutCorePoolSize = size;
     }
 
     /**
@@ -1114,7 +1124,7 @@ public class HttpClientBuilder {
                 getStaticContextHandlers());
 
         final ScheduledExecutorService executorService =
-                Executors.newScheduledThreadPool(getRequestTimeoutThreadPoolSize());
+                Executors.newScheduledThreadPool(getRequestTimeoutCorePoolSize());
         assert executorService != null;
         return new RequestTimeLimitingHttpClient(contextHandlingClient, executorService, getRequestTimeout());
     }

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


More information about the commits mailing list