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 d7bb069222ac fix(components): change AsyncProcessor to AsyncProducer
d7bb069222ac is described below

commit d7bb069222ac2f23a6968e98bb468a0a48975b75
Author: Pasquale Congiusti <[email protected]>
AuthorDate: Mon Dec 1 10:05:27 2025 +0100

    fix(components): change AsyncProcessor to AsyncProducer
    
    We don't hide the Closable interface, allowing the producer to close the 
wrapped resource accordingly
---
 .../java/org/apache/camel/component/rest/DefaultRestRegistry.java     | 3 +--
 .../src/main/java/org/apache/camel/component/rest/RestEndpoint.java   | 3 ++-
 .../src/main/java/org/apache/camel/component/rest/RestProducer.java   | 4 +++-
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git 
a/components/camel-rest/src/main/java/org/apache/camel/component/rest/DefaultRestRegistry.java
 
b/components/camel-rest/src/main/java/org/apache/camel/component/rest/DefaultRestRegistry.java
index b0827bf4c383..ac219ca61d4a 100644
--- 
a/components/camel-rest/src/main/java/org/apache/camel/component/rest/DefaultRestRegistry.java
+++ 
b/components/camel-rest/src/main/java/org/apache/camel/component/rest/DefaultRestRegistry.java
@@ -32,7 +32,6 @@ import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.Service;
 import org.apache.camel.ServiceStatus;
 import org.apache.camel.StatefulService;
-import org.apache.camel.StaticService;
 import org.apache.camel.spi.NormalizedEndpointUri;
 import org.apache.camel.spi.RestConfiguration;
 import org.apache.camel.spi.RestRegistry;
@@ -40,7 +39,7 @@ import org.apache.camel.support.LifecycleStrategySupport;
 import org.apache.camel.support.service.ServiceSupport;
 import org.apache.camel.util.ObjectHelper;
 
-public class DefaultRestRegistry extends ServiceSupport implements 
StaticService, RestRegistry, CamelContextAware {
+public class DefaultRestRegistry extends ServiceSupport implements 
RestRegistry, CamelContextAware {
 
     private CamelContext camelContext;
     private final Map<Consumer, List<RestService>> registry = new 
LinkedHashMap<>();
diff --git 
a/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestEndpoint.java
 
b/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestEndpoint.java
index 86a6ff3cf261..2e1338bcea06 100644
--- 
a/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestEndpoint.java
+++ 
b/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestEndpoint.java
@@ -431,8 +431,9 @@ public class RestEndpoint extends DefaultEndpoint {
                 producer = apiDocFactory.createProducer(getCamelContext(), 
host, method, path, uriTemplate, queryParameters,
                         consumes, produces, config, parameters);
             } else {
+                // NOTE: the stream must be closed by the client.
                 producer = factory.createProducer(getCamelContext(), host, 
method, path, uriTemplate, queryParameters, consumes,
-                        produces, config, parameters);
+                        produces, config, parameters); // NOSONAR
             }
 
             RestProducer answer = new RestProducer(this, producer, config);
diff --git 
a/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestProducer.java
 
b/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestProducer.java
index c588433ca5f9..8b8abd47c963 100644
--- 
a/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestProducer.java
+++ 
b/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestProducer.java
@@ -27,6 +27,7 @@ import java.util.StringJoiner;
 
 import org.apache.camel.AsyncCallback;
 import org.apache.camel.AsyncProcessor;
+import org.apache.camel.AsyncProducer;
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
@@ -60,7 +61,7 @@ public class RestProducer extends DefaultAsyncProducer {
     private String outType;
 
     // the producer of the Camel component that is used as the HTTP client to 
call the REST service
-    private AsyncProcessor producer;
+    private AsyncProducer producer;
     // if binding is enabled then this processor should be used to wrap the 
call with binding before/after
     private AsyncProcessor binding;
 
@@ -265,6 +266,7 @@ public class RestProducer extends DefaultAsyncProducer {
     protected void doStop() throws Exception {
         super.doStop();
         ServiceHelper.stopService(producer, binding);
+        producer.close();
     }
 
     protected AsyncProcessor createBindingProcessor() throws Exception {

Reply via email to