You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ab...@apache.org on 2026/09/21 11:45:15 UTC

(httpcomponents-client) branch master updated: Preserve idle timeout when copying connection configuration

This is an automated email from the ASF dual-hosted git repository.

arturobernalg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git


The following commit(s) were added to refs/heads/master by this push:
     new 636993fbe Preserve idle timeout when copying connection configuration
636993fbe is described below

commit 636993fbe9db26f9a1c4aab31480768e263d7197
Author: Arturo Bernal <ab...@apache.org>
AuthorDate: Sat Sep 19 11:55:19 2026 +0200

    Preserve idle timeout when copying connection configuration
---
 .../hc/client5/http/config/ConnectionConfig.java   |  1 +
 .../http/config/TestConnectionConfigCopy.java      | 48 ++++++++++++++++++++++
 2 files changed, 49 insertions(+)

diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/config/ConnectionConfig.java b/httpclient5/src/main/java/org/apache/hc/client5/http/config/ConnectionConfig.java
index d69949f1a..16b36f766 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/config/ConnectionConfig.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/config/ConnectionConfig.java
@@ -181,6 +181,7 @@ public static ConnectionConfig.Builder copy(final ConnectionConfig config) {
         return new Builder()
                 .setConnectTimeout(config.getConnectTimeout())
                 .setSocketTimeout(config.getSocketTimeout())
+                .setIdleTimeout(config.getIdleTimeout())
                 .setValidateAfterInactivity(config.getValidateAfterInactivity())
                 .setTimeToLive(config.getTimeToLive());
     }
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/config/TestConnectionConfigCopy.java b/httpclient5/src/test/java/org/apache/hc/client5/http/config/TestConnectionConfigCopy.java
new file mode 100644
index 000000000..c0f25b5a6
--- /dev/null
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/config/TestConnectionConfigCopy.java
@@ -0,0 +1,48 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+package org.apache.hc.client5.http.config;
+
+import org.apache.hc.core5.util.Timeout;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+class TestConnectionConfigCopy {
+
+    @Test
+    void testCopyPreservesIdleTimeout() {
+        final Timeout idleTimeout = Timeout.ofSeconds(42);
+
+        final ConnectionConfig original = ConnectionConfig.custom()
+                .setIdleTimeout(idleTimeout)
+                .build();
+
+        final ConnectionConfig copy = ConnectionConfig.copy(original).build();
+
+        Assertions.assertEquals(idleTimeout, copy.getIdleTimeout());
+    }
+
+}