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

   [CAMEL-26606](https://issues.apache.org/jira/browse/CAMEL-26606)
   
   ### Problem
   
   `VertxPlatformHttpServer.startServer()` handled the result of 
`HttpServer.listen(...)` in an `onComplete` callback on a Vert.x thread. When 
the bind failed (for example with `Address already in use`), the callback 
logged a WARN and threw a `RuntimeException`. That exception never reached the 
thread waiting on the latch, so `startServer()` returned normally. The 
`CamelContext` then started and reported its platform-http routes as started, 
with nothing listening on the port.
   
   The same code is behind:
   - the `camel.server.*` and `camel.management.*` servers of 
camel-platform-http-main, and so `camel run`;
   - the Camel Kafka Connector webhook source, where a second task on a worker, 
or a quickly restarted one, stays RUNNING but never receives a request.
   
   ### Change
   
   - **Rethrow the bind failure.** The listen failure is now kept and thrown 
from `startServer()` after the latch, as a `RuntimeCamelException` ("Failed to 
start Vert.x HttpServer on host:port, reason: ...") with the bind error as the 
cause.
   - **Clean up after a failed start.** The failed start stops the service 
again, which closes the HTTP server and the Vert.x instance it created, and 
shuts down the executor.
   - **Test.** `VertxPlatformHttpServerPortInUseTest` holds a free port with a 
`ServerSocket` and checks that `CamelContext.start()` fails with a 
`BindException` as the cause, and that the server is stopped again. It fails 
without the fix.
   - **Upgrade guide 4.24.** New entry: Camel now fails to start when the 
platform-http server cannot listen on its port.
   
   `VertxWebsocketHost` (camel-vertx-websocket) already propagates a failed 
bind, and camel-vertx-http has no server.
   
   ### Tests
   
   - camel-platform-http-vertx: 172 tests, 0 failures. The only skipped test is 
the performance test.
   - camel-platform-http-main: 44 tests, 0 failures.
   
   The change does not cherry-pick cleanly onto camel-4.22.x, because the 
`listen(...).onComplete` form came with CAMEL-23647. The backport will be a 
small manual port of the same change.
   
   _Claude Code on behalf of Andrea Cosentino_
   
   🤖 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