This is an automated email from the ASF dual-hosted git repository.
reta pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/main by this push:
new c1d7ebb83b CXF-9115: Race Condition in HttpClientHttpConduit Causes
Writing Thread to Hang Forever (#2323)
c1d7ebb83b is described below
commit c1d7ebb83b025481a789095caac8bdabd9555d5e
Author: Andriy Redko <[email protected]>
AuthorDate: Sun Mar 30 10:05:34 2025 -0400
CXF-9115: Race Condition in HttpClientHttpConduit Causes Writing Thread to
Hang Forever (#2323)
Signed-off-by: Andriy Redko <[email protected]>
---
.../cxf/transport/http/HttpClientHTTPConduit.java | 5 ++++
.../systest/http/jaxws/JAXWSAsyncClientTest.java | 30 +++++++++++++++++++++-
2 files changed, 34 insertions(+), 1 deletion(-)
diff --git
a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpClientHTTPConduit.java
b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpClientHTTPConduit.java
index 82d469e86e..1df103883a 100644
---
a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpClientHTTPConduit.java
+++
b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpClientHTTPConduit.java
@@ -1031,6 +1031,11 @@ public class HttpClientHTTPConduit extends
URLConnectionHTTPConduit {
pout.notifyAll();
}
}
+ try {
+ close();
+ } catch (IOException e) {
+ ex.addSuppressed(e);
+ }
return null;
});
}
diff --git
a/systests/transports/src/test/java/org/apache/cxf/systest/http/jaxws/JAXWSAsyncClientTest.java
b/systests/transports/src/test/java/org/apache/cxf/systest/http/jaxws/JAXWSAsyncClientTest.java
index 4e7843af22..b3f917a322 100644
---
a/systests/transports/src/test/java/org/apache/cxf/systest/http/jaxws/JAXWSAsyncClientTest.java
+++
b/systests/transports/src/test/java/org/apache/cxf/systest/http/jaxws/JAXWSAsyncClientTest.java
@@ -45,6 +45,7 @@ import jakarta.xml.soap.SOAPMessage;
import jakarta.xml.ws.Dispatch;
import jakarta.xml.ws.Response;
import jakarta.xml.ws.Service;
+import jakarta.xml.ws.WebServiceException;
import jakarta.xml.ws.soap.SOAPBinding;
import jakarta.xml.ws.soap.SOAPFaultException;
import org.apache.cxf.endpoint.Client;
@@ -68,6 +69,7 @@ import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class JAXWSAsyncClientTest extends AbstractBusClientServerTestBase {
static final String PORT = allocatePort(Server.class);
@@ -101,7 +103,7 @@ public class JAXWSAsyncClientTest extends
AbstractBusClientServerTestBase {
public class GreeterImpl extends AbstractGreeterImpl {
@Override
public String greetMe(String arg) {
- if ("timeout".equalsIgnoreCase(arg)) {
+ if ("timeout".equalsIgnoreCase(arg) ||
arg.startsWith("timeout")) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
@@ -207,6 +209,32 @@ public class JAXWSAsyncClientTest extends
AbstractBusClientServerTestBase {
}
}
+ @Test
+ public void testTimeoutWithChunking() throws Exception {
+ // setup the feature by using JAXWS front-end API
+ JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
+ factory.setAddress("http://localhost:" + PORT +
"/SoapContext/GreeterPort");
+ factory.setServiceClass(Greeter.class);
+ Greeter proxy = factory.create(Greeter.class);
+
+ // See please https://issues.apache.org/jira/browse/CXF-9115
+ HTTPConduit cond = (HTTPConduit)((Client)proxy).getConduit();
+ cond.getClient().setChunkingThreshold(8);
+ cond.getClient().setChunkLength(8);
+ cond.getClient().setConnectionTimeout(500);
+ cond.getClient().setReceiveTimeout(100);
+ cond.getClient().setAllowChunking(true);
+
+ final char[] bytes = new char [64 * 1024];
+ final Random random = new Random();
+ for (int i = 0; i < bytes.length; ++i) {
+ bytes[i] = (char)(random.nextInt(26) + 'a');
+ }
+
+ final String greeting = "timeout" + new String(bytes);
+ assertThrows(WebServiceException.class, () -> proxy.greetMe(greeting));
+ }
+
/**
* Not 100% reproducible but used to sporadically fail with:
*