Croway opened a new pull request, #27668: URL: https://github.com/apache/camel/pull/27668
## Description Backport of #27667 to camel-4.22.x. The commit applies cleanly; `MainHttpServerFactoryTest` passes on this branch, and with the class built from this branch `camel run` 4.22.1 binds 9090 for an `application.properties` containing only `camel.server.port=9090`. [CAMEL-25533](https://issues.apache.org/jira/browse/CAMEL-25533) Under `camel run`, a route that uses `platform-http` starts an embedded HTTP server even when `camel.server.enabled` is not set: when the component is resolved, `MainHttpServerFactory.setupHttpServer` (camel-kamelet-main) creates the server from a new `HttpServerConfigurationProperties` and only reads the port from the run settings (written for `--port`). camel-main binds the `camel.server.*` properties onto its own configuration, but `BaseMainSupport.setHttpServerProperties` returns early when `camel.server.enabled` is not true, so that configuration is never used. The result: `camel.server.port=9090` in `application.properties` is ignored without any message, the server listens on 8080, and the auto-configuration summary still lists `[application.properties] camel.server.port = 9090`. The same goes for `host`, `path`, `maxBodySize` and the rest. We hit this while evaluating AI coding agents on migrations to Camel: they spent many tool calls looking for the port, some concluded t hat placeholders are not supported for `camel.server.port`, and 5 of 10 trials ended up on the wrong port. Change: the implicitly started server binds the `camel.server.*` properties (properties files, initial and override properties, JVM system properties) with `MainHelper.setPropertiesOnTarget`, as camel-main does for `camel.server.enabled=true`, so placeholders are resolved. `--port` keeps precedence, and the run settings now record the port actually used (so `camel export` and the other commands see it). `camel.server.enabled` is not bound, the server is started because platform-http is in use, as before. Why not make `camel.server.port` imply `camel.server.enabled=true`: that would be in camel-main and change plain Camel Main applications, where the property alone does not start a server today, while the implicit server exists only under `camel run`. Applying the settings to the server that is actually started is the least surprising, and keeps `camel run` with and without `camel.server.enabled=true` consistent. Tests: - `MainHttpServerFactoryTest` (new): default port without properties, `camel.server.port`/`host`/`path`/`max-body-size` applied, placeholder in the port, nothing started in silent mode. The two property tests fail without the change (8080). - Manually, with `hello.camel.yaml` (`from: platform-http:/hello`) and an `application.properties` containing only `camel.server.port=9090`, `camel run hello.camel.yaml application.properties` with 4.22.1 logs `Vert.x HttpServer started on 0.0.0.0:8080`; with the patched class it logs `0.0.0.0:9090` and only 9090 answers. `camel.server.port={{app.port}}` with `app.port=9092` binds 9092. ## Target - [x] I checked that the commit is targeting the correct branch (backport to `camel-4.22.x`) ## 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). ## Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. - [x] I built the affected module (`camel-kamelet-main`) and ran its tests; the build changes no generated or formatted files. -- 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]
