oscerd commented on code in PR #28352: URL: https://github.com/apache/camel/pull/28352#discussion_r4375301307
########## components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpDifferentHostSamePortTest.java: ########## @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.netty.http; + +import org.apache.camel.Exchange; +import org.apache.camel.builder.RouteBuilder; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotSame; + +public class NettyHttpDifferentHostSamePortTest extends BaseNettyTestSupport { Review Comment: Good catch — fixed in f9aa2d20. Applied your suggestion: the class is now annotated `@DisabledOnOs(value = OS.MAC, disabledReason = "macOS only configures 127.0.0.1 on the loopback interface")` (with the two `org.junit.jupiter.api.condition` imports), so `mvn test` no longer fails for contributors on a Mac while CI on Linux still exercises it. _Claude Code on behalf of oscerd_ ########## components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java: ########## @@ -333,8 +333,26 @@ public void setMuteException(boolean muteException) { getConfiguration().setMuteException(muteException); } + public HttpServerConsumerChannelFactory getMultiplexChannelHandler(String address) { Review Comment: Agreed — removed in f9aa2d20. The single-arg `getMultiplexChannelHandler(String)` had no callers, and its silent `port = 0` fallback was a foot-gun. Both call sites use the two-arg `(String, int)` form, so dropping it keeps the address parsing out of the public API entirely. _Claude Code on behalf of oscerd_ ########## components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java: ########## @@ -333,8 +333,26 @@ public void setMuteException(boolean muteException) { getConfiguration().setMuteException(muteException); } + public HttpServerConsumerChannelFactory getMultiplexChannelHandler(String address) { + int port = 0; + int idx = address.lastIndexOf(':'); + if (idx > -1) { + try { + port = Integer.parseInt(address.substring(idx + 1)); + } catch (NumberFormatException e) { + // ignore + } + } + return getMultiplexChannelHandler(address, port); + } + + public HttpServerConsumerChannelFactory getMultiplexChannelHandler(String address, int port) { + return multiplexChannelHandlers.computeIfAbsent(address, s -> newHttpServerConsumerChannelFactory(port)); + } + + @Deprecated Review Comment: Applied your suggested `@deprecated` Javadoc verbatim in f9aa2d20, documenting that `getMultiplexChannelHandler(int)` only returns the handler of the `0.0.0.0` listener for the given port. _Claude Code on behalf of oscerd_ ########## components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java: ########## @@ -333,8 +333,26 @@ public void setMuteException(boolean muteException) { getConfiguration().setMuteException(muteException); } + public HttpServerConsumerChannelFactory getMultiplexChannelHandler(String address) { + int port = 0; + int idx = address.lastIndexOf(':'); + if (idx > -1) { + try { + port = Integer.parseInt(address.substring(idx + 1)); + } catch (NumberFormatException e) { + // ignore + } Review Comment: Dropped the single-arg `getMultiplexChannelHandler(String)` entirely in f9aa2d20 — it had no callers and both call sites use the two-arg `(String, int)` form, so the public surface stays minimal. _Claude Code on behalf of oscerd_ ########## components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java: ########## @@ -333,8 +333,26 @@ public void setMuteException(boolean muteException) { getConfiguration().setMuteException(muteException); } + public HttpServerConsumerChannelFactory getMultiplexChannelHandler(String address) { + int port = 0; + int idx = address.lastIndexOf(':'); + if (idx > -1) { + try { + port = Integer.parseInt(address.substring(idx + 1)); + } catch (NumberFormatException e) { + // ignore + } + } + return getMultiplexChannelHandler(address, port); + } + + public HttpServerConsumerChannelFactory getMultiplexChannelHandler(String address, int port) { + return multiplexChannelHandlers.computeIfAbsent(address, s -> newHttpServerConsumerChannelFactory(port)); + } + + @Deprecated public HttpServerConsumerChannelFactory getMultiplexChannelHandler(int port) { - return multiplexChannelHandlers.computeIfAbsent(port, s -> newHttpServerConsumerChannelFactory(port)); + return getMultiplexChannelHandler("0.0.0.0:" + port, port); Review Comment: Documented in f9aa2d20: the `@deprecated` Javadoc on `getMultiplexChannelHandler(int)` now states it only returns the handler of the `0.0.0.0` listener for the port. All internal call sites were migrated to the address-aware `(String, int)` form, so only external callers can reach the deprecated path (and they get a visible deprecation warning). _Claude Code on behalf of oscerd_ ########## components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java: ########## @@ -333,8 +333,26 @@ public void setMuteException(boolean muteException) { getConfiguration().setMuteException(muteException); } + public HttpServerConsumerChannelFactory getMultiplexChannelHandler(String address) { + int port = 0; + int idx = address.lastIndexOf(':'); + if (idx > -1) { + try { + port = Integer.parseInt(address.substring(idx + 1)); + } catch (NumberFormatException e) { + // ignore + } + } + return getMultiplexChannelHandler(address, port); + } + + public HttpServerConsumerChannelFactory getMultiplexChannelHandler(String address, int port) { Review Comment: Added Javadoc to `getMultiplexChannelHandler(String, int)` in f9aa2d20, explaining that `address` is the `host:port` key (so consumers on different interfaces stay isolated) and that `port` is used only to initialise a newly created handler for that address. _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]
