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

pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 1f8d5204be20 fix(components): spring-ws stream closure
1f8d5204be20 is described below

commit 1f8d5204be2044d2d9893ed91a5eb84a70860cc1
Author: Pasquale Congiusti <[email protected]>
AuthorDate: Tue Dec 2 11:19:56 2025 +0100

    fix(components): spring-ws stream closure
---
 .../camel/component/spring/ws/SpringWebserviceProducer.java   |  3 ++-
 .../camel/component/spring/ws/bean/CamelDirectConnection.java | 11 ++++++++---
 .../camel/component/spring/ws/bean/CamelDirectSender.java     |  3 ++-
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git 
a/components/camel-spring-parent/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceProducer.java
 
b/components/camel-spring-parent/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceProducer.java
index 0c210e330b4f..112ac4812130 100644
--- 
a/components/camel-spring-parent/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceProducer.java
+++ 
b/components/camel-spring-parent/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceProducer.java
@@ -229,7 +229,8 @@ public class SpringWebserviceProducer extends 
DefaultProducer {
 
         @Override
         public WebServiceConnection createConnection(URI uri) throws 
IOException {
-            WebServiceConnection wsc = delegate.createConnection(uri);
+            // NOTE: factory method, the client must close the connection.
+            WebServiceConnection wsc = delegate.createConnection(uri); // 
NOSONAR
             if (wsc instanceof HttpUrlConnection) {
                 HttpURLConnection connection = ((HttpUrlConnection) 
wsc).getConnection();
 
diff --git 
a/components/camel-spring-parent/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelDirectConnection.java
 
b/components/camel-spring-parent/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelDirectConnection.java
index df8371c222a8..ef83edb1dcaf 100644
--- 
a/components/camel-spring-parent/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelDirectConnection.java
+++ 
b/components/camel-spring-parent/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelDirectConnection.java
@@ -22,6 +22,7 @@ import java.net.URISyntaxException;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.CamelExecutionException;
+import org.apache.camel.ProducerTemplate;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.ws.WebServiceMessage;
@@ -38,13 +39,17 @@ public class CamelDirectConnection implements 
WebServiceConnection {
 
     public CamelDirectConnection(CamelContext camelContext, URI uri) throws 
URISyntaxException {
         this.camelContext = camelContext;
-        destination = new URI("direct:" + uri + "?block=false");
+        destination = CamelDirectConnection.destination(uri);
+    }
+
+    public static URI destination(URI uri) throws URISyntaxException {
+        return new URI("direct:" + uri + "?block=false");
     }
 
     @Override
     public void send(WebServiceMessage message) throws IOException {
-        try {
-            
camelContext.createProducerTemplate().sendBody(destination.toString(), message);
+        try (ProducerTemplate producer = 
camelContext.createProducerTemplate()) {
+            producer.sendBody(destination.toString(), message);
         } catch (CamelExecutionException e) {
             // simply discard replyTo message
             LOG.warn("Could not found any camel endpoint [{}] for wsa:ReplyTo 
camel mapping.", destination);
diff --git 
a/components/camel-spring-parent/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelDirectSender.java
 
b/components/camel-spring-parent/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelDirectSender.java
index beee6ff2d97c..96ff6c640096 100644
--- 
a/components/camel-spring-parent/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelDirectSender.java
+++ 
b/components/camel-spring-parent/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelDirectSender.java
@@ -44,7 +44,8 @@ public class CamelDirectSender implements 
WebServiceMessageSender {
     @Override
     public boolean supports(URI uri) {
         try {
-            new CamelDirectConnection(camelContext, uri);
+            // Just check if it throws an exception on parsing the destination
+            CamelDirectConnection.destination(uri);
             return true;
         } catch (URISyntaxException e) {
             return false;

Reply via email to