Federico Mariani created CAMEL-24116:
----------------------------------------

             Summary: camel-rest-openapi: RestOpenApiProcessor doInit/doStop 
are dead code since the advice conversion (CAMEL-22742) - services never 
stopped, stale platform-http registrations on route reload
                 Key: CAMEL-24116
                 URL: https://issues.apache.org/jira/browse/CAMEL-24116
             Project: Camel
          Issue Type: Bug
          Components: camel-rest-openapi
    Affects Versions: 4.21.0
            Reporter: Federico Mariani


h3. Problem
Commit bd63a7eb8213 (CAMEL-22742) moved {{RestOpenApiProcessor}} out of the 
consumer's processor chain into {{RestOpenApiProcessorAdvice}} added via 
{{ip.addAdvice(...)}} (RestOpenApiEndpoint.java:233-246). Previously 
{{DefaultConsumer}} drove the processor's lifecycle; advices get no lifecycle 
management, and nothing else builds/inits/starts/stops the processor as a 
service (verified: no {{ServiceHelper}} call on it anywhere in the endpoint). 
Consequences:
* {{doInit()}} ({{trySetCamelContext(restOpenapiProcessorStrategy, ...)}}, 
RestOpenApiProcessor.java:146-149) never runs. The default strategy was 
compensated in the same commit ({{RestOpenApiComponent.doInit}}), but a 
*custom* {{restOpenapiProcessorStrategy=#myStrategy}} (documented advanced 
option) that is not context-injected by its registry NPEs in 
{{validateOpenApi}} at {{camelContext.getRoutes()}}.
* {{doStop()}} (RestOpenApiProcessor.java:258-268) never runs anywhere: the 
per-operation {{RestBindingAdvice}} services and the strategy are never stopped 
- {{DefaultRestOpenapiProcessorStrategy.doStop}} (producer-cache stop + 
{{PlatformHttpComponent.removeHttpEndpoint(uris)}}) is unreachable.

h3. Failure scenario
Stopping or removing a rest-openapi route leaks the producer cache and leaves 
stale HTTP endpoint registrations in {{PlatformHttpComponent}} (visible in the 
dev console/registry, re-registered as duplicates on each route reload, e.g. 
camel-jbang {{--dev}}).

h3. Fix direction
Have the endpoint/consumer own the processor as a child service 
({{ServiceHelper.initService/stopService}} wired from the consumer), or give 
{{RestOpenApiProcessorAdvice}} the advice-service pattern and register it with 
the consumer.

----
_This issue was researched and filed by Claude Code on behalf of [~croway] 
(GitHub: Croway), as part of a deep code review of camel-rest-openapi and 
camel-openapi-java on main (4.22.0-SNAPSHOT). Full findings document available 
on request._



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to