allthingssecurity opened a new pull request, #28432:
URL: https://github.com/apache/camel/pull/28432

   # Description
   
   [CAMEL-25908](https://issues.apache.org/jira/browse/CAMEL-25908)
   
   `KnativeHttpConsumer` registers its Vert.x route on the platform HTTP router 
in `doStart` only when it has none yet (`if (route == null)`), and `doStop` 
removed the route from the router without clearing the field. When the same 
consumer instance is stopped and started again, the start skipped the 
registration: the consumer reported Started, but nothing served its path and 
every event was answered with 404.
   
   The consumer is not `Suspendable`, so this is what happens when a route 
policy suspends and resumes the route (`suspendOrStopConsumer` / 
`resumeOrStartConsumer` stop and start the same consumer): the circuit breaker 
`ThrottlingExceptionRoutePolicy` after `halfOpenAfter` (its circuit then never 
closes, as no request reaches the route), `ThrottlingInflightRoutePolicy`, and, 
with CAMEL-25848, the suspend/resume of the scheduled route policies. A route 
stop and start through the route controller creates a new consumer and was not 
affected.
   
   Changes:
   - `KnativeHttpConsumer.doStop` clears `route` after removing it, so a start 
registers a new route, as `VertxPlatformHttpConsumer` does with its routes.
   
   Not changed: the consumer is still not `Suspendable` (its 
`doSuspend`/`doResume` stay unused by the route controller).
   
   Route order: the new route is added at the end of the router. Vert.x matches 
routes in the order they were added, so if another route of the router can take 
the same request (a second knative consumer of the same path without a filter, 
or a platform-http consumer on `/*` added later), a consumer stopped and 
started by a route policy now comes after it. Keeping the route and using 
`route.disable()`/`route.enable()` (as `doSuspend`/`doResume` do) would keep 
its place, but a route stop and start through the route controller creates a 
new consumer (`DefaultRoute.gatherRootServices`) without shutting the old one 
down, so the old consumer's disabled route would then stay in the router for 
good, with the old consumer behind it. Removing the route on stop, as 
`VertxPlatformHttpConsumer` does, avoids that; the order change only matters 
for overlapping routes, and the consumer is now served instead of answering 404.
   
   Tests (`KnativeHttpTest`, both parameterized over the 3 CloudEvents 
versions, with the two filtered sources of `testRemoveConsumer`):
   - `testConsumerStartedAgainByCircuitBreakerRoutePolicy`: a route with 
`ThrottlingExceptionRoutePolicy(1, 60000, 1000, null)`; a failing request opens 
the circuit, which stops the consumer, the half-open task starts it again, and 
the next request must reach the route. Fails on main with 
`HttpOperationFailedException ... statusCode: 404`.
   - `testConsumerStoppedAndStartedAgain`: the consumer stopped and started 
with `ServiceHelper`, as the policies do. Fails on main the same way.
   - `configureTwoConsumersAndStart` sets up both tests.
   - camel-knative-http unit tests with the change: 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.
   
   What was not run: the full root build. The local Maven repository lacked 
`io.vertx:vertx-codegen-api:5.2.1` (offline build), so the module was compiled 
with the annotations of `vertx-codegen` 4.5.35 in its place for the test runs; 
the committed pom is unchanged.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [x] If this is a large change, bug fix, or code improvement, I checked 
there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for 
the change (usually before you start working on it): 
[CAMEL-25908](https://issues.apache.org/jira/browse/CAMEL-25908).
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   - [ ] I have run `mvn clean install -DskipTests` locally from root folder 
and I have committed all auto-generated changes.
     (I built and tested camel-knative-http. No option changed. I did not run 
the full root build.)
   
   # AI-assisted contributions
   
   - [x] If this PR includes AI-generated code, commits have proper 
co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR 
description identifies the AI tool used.
     This PR was prepared with Claude Code (Claude Opus 5.5). The commit 
carries a `Co-Authored-By` trailer.
   
   _Claude Code on behalf of allthingssecurity_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to