This is an automated email from the ASF dual-hosted git repository.
Aias00 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 1f35b42098 fix(sdk): read the httpclient connection request timeout
key (#7445)
1f35b42098 is described below
commit 1f35b4209882278a23fdf5fe3cc3490bbdb99ba5
Author: Burak Kalaycı <[email protected]>
AuthorDate: Thu Oct 8 09:45:59 2026 +0300
fix(sdk): read the httpclient connection request timeout key (#7445)
The property lookup included a trailing space, so
http.connectionRequestTimeOut was ignored and the client always used the 2000
ms default.
Fixes #7443
---
.../shenyu/sdk/httpclient/HttpShenyuSdkClient.java | 2 +-
.../sdk/httpclient/HttpShenyuSdkClientTest.java | 33 ++++++++++++++++++++++
2 files changed, 34 insertions(+), 1 deletion(-)
diff --git
a/shenyu-sdk/shenyu-sdk-httpclient/src/main/java/org/apache/shenyu/sdk/httpclient/HttpShenyuSdkClient.java
b/shenyu-sdk/shenyu-sdk-httpclient/src/main/java/org/apache/shenyu/sdk/httpclient/HttpShenyuSdkClient.java
index 384000a0d3..01c21413c1 100644
---
a/shenyu-sdk/shenyu-sdk-httpclient/src/main/java/org/apache/shenyu/sdk/httpclient/HttpShenyuSdkClient.java
+++
b/shenyu-sdk/shenyu-sdk-httpclient/src/main/java/org/apache/shenyu/sdk/httpclient/HttpShenyuSdkClient.java
@@ -78,7 +78,7 @@ public class HttpShenyuSdkClient extends
AbstractShenyuSdkClient {
final String maxPerRoute = props.getProperty("http.maxPerRoute",
"200");
final String serverRequestTimeOut =
props.getProperty("http.serverRequestTimeOut", "2000");
final String serverResponseTimeOut =
props.getProperty("http.serverResponseTimeOut", "2000");
- final String connectionRequestTimeOut =
props.getProperty("http.connectionRequestTimeOut ", "2000");
+ final String connectionRequestTimeOut =
props.getProperty("http.connectionRequestTimeOut", "2000");
Registry<SchemeIOSessionStrategy> sessionStrategyRegistry =
RegistryBuilder.<SchemeIOSessionStrategy>create()
.register("https",
SSLIOSessionStrategy.getDefaultStrategy())
.register("http", NoopIOSessionStrategy.INSTANCE)
diff --git
a/shenyu-sdk/shenyu-sdk-httpclient/src/test/java/org/apache/shenyu/sdk/httpclient/HttpShenyuSdkClientTest.java
b/shenyu-sdk/shenyu-sdk-httpclient/src/test/java/org/apache/shenyu/sdk/httpclient/HttpShenyuSdkClientTest.java
index 0f3d5f16be..98f713b472 100644
---
a/shenyu-sdk/shenyu-sdk-httpclient/src/test/java/org/apache/shenyu/sdk/httpclient/HttpShenyuSdkClientTest.java
+++
b/shenyu-sdk/shenyu-sdk-httpclient/src/test/java/org/apache/shenyu/sdk/httpclient/HttpShenyuSdkClientTest.java
@@ -23,6 +23,7 @@ import org.apache.shenyu.sdk.core.ShenyuRequest;
import org.apache.shenyu.sdk.core.client.ShenyuSdkClient;
import org.apache.shenyu.sdk.core.client.ShenyuSdkClientFactory;
import org.apache.http.HttpResponse;
+import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.concurrent.FutureCallback;
import org.junit.Assert;
@@ -76,6 +77,32 @@ public class HttpShenyuSdkClientTest {
verify(connectionManager).shutdown();
}
+ @Test
+ public void testConnectionRequestTimeoutHonorsConfiguredProperty() throws
Exception {
+ HttpShenyuSdkClient client = new HttpShenyuSdkClient();
+ Properties props = new Properties();
+ props.setProperty("http.connectionRequestTimeOut", "50");
+ try {
+ client.initClient(props);
+ RequestConfig requestConfig = (RequestConfig) getField(client,
"requestConfig");
+ Assert.assertEquals(50,
requestConfig.getConnectionRequestTimeout());
+ } finally {
+ client.close();
+ }
+ }
+
+ @Test
+ public void testConnectionRequestTimeoutDefaultsWhenUnset() throws
Exception {
+ HttpShenyuSdkClient client = new HttpShenyuSdkClient();
+ try {
+ client.initClient(new Properties());
+ RequestConfig requestConfig = (RequestConfig) getField(client,
"requestConfig");
+ Assert.assertEquals(2000,
requestConfig.getConnectionRequestTimeout());
+ } finally {
+ client.close();
+ }
+ }
+
@Test
public void testFactoryCreatesIndependentClients() {
ShenyuSdkClient firstClient =
ShenyuSdkClientFactory.newInstance("httpclient");
@@ -84,6 +111,12 @@ public class HttpShenyuSdkClientTest {
assertNotSame(firstClient, secondClient);
}
+ private Object getField(final HttpShenyuSdkClient client, final String
name) throws Exception {
+ Field field = HttpShenyuSdkClient.class.getDeclaredField(name);
+ field.setAccessible(true);
+ return field.get(client);
+ }
+
private void setField(final HttpShenyuSdkClient client, final String name,
final Object value) throws Exception {
Field field = HttpShenyuSdkClient.class.getDeclaredField(name);
field.setAccessible(true);