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

   Jira: https://issues.apache.org/jira/browse/CAMEL-26065
   
   ### Problem
   
   `NettyHttpComponent` maintains a registry of `HttpServerBootstrapFactory` 
instances keyed by the listener address (`host:port`). However, 
`multiplexChannelHandlers` was indexed solely by port number (`Integer`). When 
configuring the pipeline in `HttpServerInitializerFactory`, the multiplex 
handler was retrieved using only the port number.
   
   As a consequence, when multiple consumers bound to distinct host interfaces 
or IP addresses (for example, `127.0.0.1` and `127.0.0.2`) while sharing the 
same port number:
   - All listeners shared a single `HttpServerConsumerChannelFactory` instance.
   - Consumers on one address registered their routes in the same multiplex 
handler as consumers on other addresses.
   - Incoming HTTP requests on any listener were matched against the shared 
path table, allowing requests sent to one interface to reach route handlers 
intended only for another interface.
   
   ### Solution
   
   - Key the `multiplexChannelHandlers` map by listener address (`host:port`) 
instead of port alone.
   - Add `getMultiplexChannelHandler(String address)` and 
`getMultiplexChannelHandler(String address, int port)` in `NettyHttpComponent`.
   - Deprecate `getMultiplexChannelHandler(int port)` in `NettyHttpComponent` 
for backwards compatibility, delegating to `"0.0.0.0:" + port`.
   - In `HttpServerInitializerFactory`, look up the multiplex handler using 
both the consumer's configured address and port.
   - In `NettyHttpComponent.newHttpServerBootstrapFactory`, obtain the 
multiplex handler by consumer address and port.
   
   ### Tests
   
   - Added `NettyHttpDifferentHostSamePortTest`:
     - Verifies that `getMultiplexChannelHandler` returns distinct instances 
for separate addresses on the same port (`127.0.0.1:port` vs `127.0.0.2:port`).
     - Verifies end-to-end routing with two routes bound to 
`127.0.0.1:{{port}}/foo` and `127.0.0.2:{{port}}/bar`: requests to matching 
host and path succeed with HTTP 200, while cross-requests to the other host's 
path return HTTP 404 (Not Found).
   - Verified existing `camel-netty-http` test suite remains green.
   
   _Claude Code on behalf of oscerd_
   


-- 
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