This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch fix/CAMEL-24116 in repository https://gitbox.apache.org/repos/asf/camel.git
commit 2cb6ef3fc7d5e92abcd80fa6b0f727a2ce633fcc Author: Claus Ibsen <[email protected]> AuthorDate: Thu Jul 16 12:24:45 2026 +0200 CAMEL-24116: camel-rest-openapi - Fix RestOpenApiProcessor lifecycle so services are properly stopped Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: Claus Ibsen <[email protected]> --- .../camel/component/rest/openapi/RestOpenApiComponent.java | 7 +++++++ .../camel/component/rest/openapi/RestOpenApiEndpoint.java | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiComponent.java b/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiComponent.java index c6d391e2cd9b..21922e53641a 100644 --- a/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiComponent.java +++ b/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiComponent.java @@ -27,6 +27,7 @@ import org.apache.camel.spi.RestProducerFactory; import org.apache.camel.spi.annotations.Component; import org.apache.camel.support.DefaultComponent; import org.apache.camel.support.jsse.SSLContextParameters; +import org.apache.camel.support.service.ServiceHelper; import static org.apache.camel.component.rest.openapi.RestOpenApiHelper.isHostParam; import static org.apache.camel.component.rest.openapi.RestOpenApiHelper.isMediaRange; @@ -202,6 +203,12 @@ public final class RestOpenApiComponent extends DefaultComponent implements SSLC } } + @Override + protected void doStop() throws Exception { + super.doStop(); + ServiceHelper.stopService(restOpenapiProcessorStrategy); + } + public String getBasePath() { return basePath; } diff --git a/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java b/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java index 11f5b98a5fd4..761ca925126c 100644 --- a/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java +++ b/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java @@ -75,6 +75,7 @@ import org.apache.camel.support.CamelContextHelper; import org.apache.camel.support.DefaultEndpoint; import org.apache.camel.support.ResourceHelper; import org.apache.camel.support.processor.RestBindingAdvice; +import org.apache.camel.support.service.ServiceHelper; import org.apache.camel.util.IOHelper; import org.apache.camel.util.ObjectHelper; import org.apache.camel.util.UnsafeUriCharactersEncoder; @@ -183,6 +184,8 @@ public final class RestOpenApiEndpoint extends DefaultEndpoint { + " endpoint protection.") private String oauthProfile; + private volatile RestOpenApiProcessor openApiProcessor; + public RestOpenApiEndpoint() { // help tooling instantiate endpoint } @@ -226,6 +229,7 @@ public final class RestOpenApiEndpoint extends DefaultEndpoint { RestOpenApiProcessor openApiProcessor = new RestOpenApiProcessor(this, doc, path, apiContextPath, restOpenapiProcessorStrategy); CamelContextAware.trySetCamelContext(openApiProcessor, getCamelContext()); + this.openApiProcessor = openApiProcessor; // use an advice to call the processor that is responsible for routing to the route that matches the // operation id, and also do validation of the incoming request @@ -396,6 +400,13 @@ public final class RestOpenApiEndpoint extends DefaultEndpoint { + "`. Operations defined in the specification are: " + supportedOperations); } + @Override + protected void doStop() throws Exception { + super.doStop(); + ServiceHelper.stopService(openApiProcessor); + openApiProcessor = null; + } + public String getBasePath() { return basePath; }
