This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch backport/22355-to-camel-4.18.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit d9f0ae6742acadbea6a00b52195ace1069242016
Author: Andrea Cosentino <[email protected]>
AuthorDate: Tue Mar 31 14:11:08 2026 +0200

    CAMEL-23272: Enable main HTTP server when --port is explicitly specified 
(#22355)
    
    When using camel run with --port and --management-port together, the REST
    endpoints were incorrectly served on the management port because the main
    HTTP server was never enabled. The --port option wrote camel.server.port
    but not camel.server.enabled=true, so BaseMainSupport skipped creating
    the main server.
    
    This is consistent with how ExportCamelMain already handles port
    configuration.
    
    Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
---
 .../main/java/org/apache/camel/dsl/jbang/core/commands/Run.java   | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
index 8ba6b5dff370..0d74d2cbda17 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
@@ -733,8 +733,12 @@ public class Run extends CamelCommand {
                 () -> maxSeconds > 0 ? String.valueOf(maxSeconds) : null);
         writeSetting(main, profileProperties, 
"camel.main.durationMaxIdleSeconds",
                 () -> maxIdleSeconds > 0 ? String.valueOf(maxIdleSeconds) : 
null);
-        if (port != -1 && port != 8080) {
-            writeSetting(main, profileProperties, "camel.server.port", () -> 
String.valueOf(port));
+        if (port != -1) {
+            // enable the main HTTP server when --port is explicitly specified
+            writeSetting(main, profileProperties, "camel.server.enabled", 
"true");
+            if (port != 8080) {
+                writeSetting(main, profileProperties, "camel.server.port", () 
-> String.valueOf(port));
+            }
         }
         if (port == 0 && managementPort == -1) {
             // use same port for management

Reply via email to