Skip to content

CAMEL-25533: camel-jbang - apply camel.server.* settings to the HTTP server started for platform-http - #27667

Merged
Croway merged 3 commits into
apache:mainfrom
Croway:CAMEL-25533-server-port-implicit
Oct 11, 2026
Merged

Croway merged 3 commits into
apache:mainfrom
Croway:CAMEL-25533-server-port-implicit

Conversation

@Croway

@Croway Croway commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Description

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 that 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, then CAMEL_SERVER_* OS environment variables and JVM system properties overriding them, as in camel-main) 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, a JVM system property overriding application.properties. The property tests fail without the change (8080). The environment variables were checked by running the test with CAMEL_SERVER_PATH=/env (the default-path test then fails with /env), as the module has no way to set an environment variable in a test.
  • 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

  • I checked that the commit is targeting the correct branch (Camel 4 uses the main branch)

Tracking

  • If this is a large change, bug fix, or code improvement, I checked there is a JIRA issue filed for the change (usually before you start working on it).

Apache Camel coding standards and style

  • I checked that each commit in the pull request has a meaningful subject line and body.
  • I built the affected module (camel-kamelet-main) and ran its tests; the build changes no generated or formatted files.

…server started for platform-http

camel run starts an embedded HTTP server when a route uses platform-http, also when camel.server.enabled is not
set, but created it with the default configuration: only --port was taken (from the run settings), so
camel.server.port, host, path and the other camel.server.* settings of application.properties were ignored without
any message, while the auto-configuration summary listed them. camel-main binds them only on the server it starts
itself, when camel.server.enabled=true.

The implicit server now binds the camel.server.* properties the same way, with placeholders resolved; --port keeps
precedence, and the run settings record the port actually used.
@github-actions

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solid bug fix that correctly mirrors the property-binding pattern from BaseMainSupport into the implicit platform-http server path. The property loading and binding logic looks correct — loadProperties with MainHelper::optionKey as the key mapper, followed by setPropertiesOnTarget, matches what camel-main does when the server is explicitly enabled.

One minor cleanup item below.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

OrderedLocationProperties options = new OrderedLocationProperties();
for (Object k : prop.keySet()) {
String key = k.toString();
if (startsWithIgnoreCase(key, PREFIX_SERVER)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Suggestion (minor): The startsWithIgnoreCase(key, PREFIX_SERVER) guard inside this loop appears to be dead code.

Both sources of keys in prop start with camel.server.:

  • loadProperties(name -> startsWithIgnoreCase(name, PREFIX_SERVER), MainHelper::optionKey) — the filter ensures it, and optionKey (dash-to-camelCase) preserves the camel.server. prefix
  • The JVM property merge just above also filters on PREFIX_SERVER before inserting into prop

The if is never false, so it and its outer } can be removed — simplifying the loop to just the inner if (!"enabled"...) guard.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in e19f3db: every source is already filtered on camel.server., so the loop now only skips enabled.

Claude Code on behalf of Croway

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • dsl/camel-kamelet-main

🔁 1 test passed only after a retry on JDK 25 (1 retried attempt)

Recovered flaky tests on JDK 25 (1)
Module Test Failed attempts First failure
dsl/camel-jbang/camel-jbang-plugin-tui AiPanelAcpTest.laterPromptsSkipThePreamble 1 Assertion condition defined as a Lambda expression in org.apache.camel.dsl.jbang.core.commands.tui.AiPanelAcpTest expected: <2> but was: <1> within 5 seconds.

ℹ️ These tests did not fail the build. Surefire retried them and they passed.
Retries are enabled project-wide by surefire.rerunFailingTestsCount in parent/pom.xml.


🔬 Scalpel shadow comparison — Scalpel: 6 of 704 tested, 9 compile-only — current: 6 all tested

Maveniverse Scalpel detected 6 affected modules (current approach: 6).

Skip-tests mode would test 6 modules (1 direct + 6 downstream), skip tests for 9 (generated code, meta-modules)

Modules Scalpel would test (6)
  • camel-jbang-mcp ← downstream of org.apache.camel:camel-jbang-core
  • camel-jbang-plugin-mcp ← downstream of org.apache.camel:camel-jbang-core
  • camel-jbang-plugin-route-parser ← downstream of org.apache.camel:camel-jbang-core
  • camel-jbang-plugin-tui ← downstream of org.apache.camel:camel-jbang-core
  • camel-jbang-plugin-validate ← downstream of org.apache.camel:camel-jbang-core
  • camel-launcher-container ← downstream of org.apache.camel:camel-launcher
Modules with tests skipped (9)
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-launcher
  • coverage

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

All tested modules (16 modules, 2m 35s total)

Total reactor time: 2m 35s

Module Duration Status
Camel :: Launcher 37.3s SUCCESS
Camel :: JBang :: Plugin :: Kubernetes 30.1s SUCCESS
Camel :: JBang :: MCP 27.4s SUCCESS
Camel :: JBang :: Plugin :: Validate 21.6s SUCCESS
Camel :: Kamelet Main 13.5s SUCCESS
Camel :: JBang :: Plugin :: Testing 11.4s SUCCESS
Camel :: Coverage 4.5s SUCCESS
Camel :: JBang :: Plugin :: Generate 1.6s SUCCESS
Camel :: JBang :: Plugin :: MCP 1.6s SUCCESS
Camel :: JBang :: Plugin :: Edit 1.5s SUCCESS
Camel :: JBang :: Integration tests 1.2s SUCCESS
Camel :: JBang :: Plugin :: Route Parser 1.0s SUCCESS
Camel :: JBang :: Main 0.9s SUCCESS
Camel :: Launcher :: Container 0.8s SUCCESS
Camel :: JBang :: Core n/a
Camel :: JBang :: Plugin :: TUI n/a

Top 20 slowest modules:

  • Camel :: Launcher (37.3s)
  • Camel :: JBang :: Plugin :: Kubernetes (30.1s)
  • Camel :: JBang :: MCP (27.4s)
  • Camel :: JBang :: Plugin :: Validate (21.6s)
  • Camel :: Kamelet Main (13.5s)
  • Camel :: JBang :: Plugin :: Testing (11.4s)
  • Camel :: Coverage (4.5s)
  • Camel :: JBang :: Plugin :: Generate (1.6s)
  • Camel :: JBang :: Plugin :: MCP (1.6s)
  • Camel :: JBang :: Plugin :: Edit (1.5s)
  • Camel :: JBang :: Integration tests (1.2s)
  • Camel :: JBang :: Plugin :: Route Parser (1.0s)
  • Camel :: JBang :: Main (0.9s)
  • Camel :: Launcher :: Container (0.8s)

⚙️ View full build and test results

@davsclaus davsclaus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the fix is correct and safe: only explicit user settings are honoured, --port still wins, and no default is relaxed.

  • +1 to gnodet-bot's open thread on the startsWithIgnoreCase(key, PREFIX_SERVER) guard: both sources are already filtered by the prefix, so it's dead code and the thread should be resolved before merge.
  • Env vars gap (inline).
  • Optional design idea: camel-main already binds all camel.server.* onto mainConfigurationProperties.httpServer() before returning early when enabled is false (BaseMainSupport.setHttpServerProperties), covering env, JVM props, placeholders and fail-fast. KameletMain could hand that already bound object to MainHttpServerFactory instead of re-binding here.
  • Question: with camel.server.enabled=true, camel-main sets useGlobalSslContextParameters=true automatically when a global SSL context exists. The implicit server doesn't. Intended? (Not a regression.)

Remember to sync any follow-up commit into the 4.22.x backport #27668.


Claude Code on behalf of davsclaus. This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying. It is a static review against the project conventions and does not replace static analysis or specialized review tools.

@davsclaus

Copy link
Copy Markdown
Contributor

@Croway would be good to fix this so we can have it in 4.23.0

@Croway

Croway commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

@davsclaus on it

Croway and others added 2 commits October 11, 2026 09:43
…nt variables to the HTTP server started for platform-http

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Croway
Croway merged commit 38474ed into apache:main Oct 11, 2026
5 checks passed
@Croway Croway added the bug Something isn't working label Oct 11, 2026
@Croway Croway self-assigned this Oct 11, 2026
@Croway Croway added this to the 4.23.0 milestone Oct 11, 2026
@Croway
Croway deleted the CAMEL-25533-server-port-implicit branch October 11, 2026 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working dsl

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants