Federico Mariani created CAMEL-25533:
----------------------------------------

             Summary: camel-jbang - camel run ignores camel.server.port (and 
the other camel.server.* settings) for the HTTP server started for 
platform-http unless camel.server.enabled=true
                 Key: CAMEL-25533
                 URL: https://issues.apache.org/jira/browse/CAMEL-25533
             Project: Camel
          Issue Type: Bug
          Components: camel-jbang
    Affects Versions: 4.22.1
            Reporter: Federico Mariani
            Assignee: Federico Mariani
             Fix For: 4.23.0, 4.22.2


*Problem*

Under {{camel run}}, a route that uses {{platform-http}} starts an embedded 
HTTP server even when {{camel.server.enabled}} is not set: when the 
{{platform-http}} component is resolved, 
{{MainHttpServerFactory.setupHttpServer}} (camel-kamelet-main) creates the 
server with a new {{HttpServerConfigurationProperties}}, and only reads the 
port from the run settings file, which {{camel run}} writes only for 
{{--port}}. The {{camel.server.*}} settings of {{application.properties}} are 
applied by camel-main only to the server it starts itself, as 
{{BaseMainSupport.setHttpServerProperties}} binds them and then returns when 
{{camel.server.enabled}} is not true.

So {{camel.server.port=9090}} (or {{host}}, {{path}}, {{maxBodySize}}...) is 
silently ignored and the server listens on 8080, while the auto-configuration 
summary at startup lists {{[application.properties] camel.server.port = 9090}} 
as applied. Adding {{camel.server.enabled=true}} makes it work.

We found this while evaluating AI coding agents on legacy-to-Camel migrations: 
the agents spent many tool calls looking for why the port was not taken, some 
concluded that "placeholders are not supported for camel.server.port", and in 5 
of 10 trials the application ended up on the wrong port.

*Reproduction*

{{hello.camel.yaml}}:
{code:yaml}
- route:
    from:
      uri: platform-http:/hello
      steps:
        - setBody:
            constant: Hello
{code}

{{application.properties}}:
{code}
camel.server.port=9090
{code}

{code}
camel run hello.camel.yaml application.properties
{code}

*Expected:* the server listens on 9090.
*Actual:*
{code}
BaseMainSupport :     [application.properties]       camel.server.port = 9090
VertxPlatformHttpServer : Vert.x HttpServer started on 0.0.0.0:8080
MainHttpServerUtil :     http://0.0.0.0:8080/hello
{code}
{{curl localhost:8080/hello}} answers, {{curl localhost:9090/hello}} does not. 
With {{camel.server.enabled=true}} added to the same file the server starts on 
9090.

*Proposal*

When the HTTP server is started implicitly for {{platform-http}}, apply the 
{{camel.server.*}} properties to it (port, host, path, max body size, static 
content, authentication...), binding them the same way camel-main does when 
{{camel.server.enabled=true}}, with placeholders resolved. The {{--port}} 
option keeps precedence. The run settings file then records the actual port, so 
{{camel export}} and the other commands see it.

Making {{camel.server.port}} imply {{camel.server.enabled=true}} was 
considered, but it would change plain Camel Main applications, where the 
property alone does not start a server today, while the implicit server is 
specific to {{camel run}}.




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to