[
https://issues.apache.org/jira/browse/CAMEL-25908?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Work on CAMEL-25908 started by shashank.
----------------------------------------
> camel-knative-http - a consumer stopped and started again by a route policy
> (circuit breaker, throttling) answers 404 for good
> ------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-25908
> URL: https://issues.apache.org/jira/browse/CAMEL-25908
> Project: Camel
> Issue Type: Bug
> Components: camel-knative-http
> Reporter: shashank
> Assignee: shashank
> Priority: Major
>
> {{KnativeHttpConsumer}} (main 74ee085f7d64) registers a Vert.x route on the
> shared platform HTTP router in {{doStart}}, only when it has none yet, and
> removes it in {{doStop}} without clearing the field:
> {code:java}
> protected void doStart() throws Exception {
> if (route == null) {
> ...
> route = router.get().route(HttpMethod.POST, path);
> ... handlers ...
> }
> super.doStart();
> }
> protected void doStop() throws Exception {
> if (route != null) {
> route.remove();
> }
> super.doStop();
> }
> {code}
> So when the same consumer instance is stopped and started again, the start
> skips the registration: the consumer and its route report Started, but no
> handler serves its path, and every event POSTed to it is answered with 404
> (the Knative broker or channel retries and then drops or dead-letters the
> events). It lasts until the route is restarted through the route controller
> (which creates a new consumer) or the application restarts.
> The consumer is not {{Suspendable}}, so the route policies that suspend and
> resume a route stop and start this same instance
> ({{RoutePolicySupport.suspendOrStopConsumer}} / {{resumeOrStartConsumer}}):
> the circuit breaker {{ThrottlingExceptionRoutePolicy}} (half open after
> {{halfOpenAfter}}), {{ThrottlingInflightRoutePolicy}}, and, with CAMEL-25848,
> the suspend/resume of the scheduled route policies. With the circuit breaker
> the circuit never closes again, since no request reaches the route. A route
> stop/start through the route controller is not affected (a new consumer is
> created), nor is a CamelContext suspend/resume. The sibling
> {{VertxPlatformHttpConsumer}} clears its routes in {{doStop}}.
> *Fix*: clear {{route}} after removing it in {{doStop}}, so a start registers
> a new route.
> *Tests*: two new parameterized tests in {{KnativeHttpTest}} (3 CloudEvents
> versions each, the module's platform HTTP server and two filtered sources).
> {{testConsumerStartedAgainByCircuitBreakerRoutePolicy}} (route with
> {{ThrottlingExceptionRoutePolicy(1, 60000, 1000, null)}}, one failing request
> opens the circuit and stops the consumer, the half-open task starts it again)
> and {{testConsumerStoppedAndStartedAgain}} (consumer stopped and started with
> {{ServiceHelper}}, as the policies do) fail on main:
> {{HttpOperationFailedException ... statusCode: 404}} on the request after the
> start; they pass with the fix. camel-knative-http unit tests with the fix:
> 200 run, 0 failures.
> *How it was found*: variant analysis of CAMEL-25872 and CAMEL-25848 (a
> consumer that is not Suspendable, started again through a path that assumes a
> first start), then the JUnit tests above.
> *Affected*: main, camel-4.23.x, camel-4.22.x and camel-4.18.x (the same
> {{doStart}} guard and {{doStop}}; read, not run).
> _Filed with Claude Code on behalf of allthingssecurity._
--
This message was sent by Atlassian Jira
(v8.20.10#820010)