davsclaus commented on code in PR #28352:
URL: https://github.com/apache/camel/pull/28352#discussion_r4359596112


##########
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:
   **Non-blocking:** `getMultiplexChannelHandler(port)` used to return the 
handler that the consumers on that port use. Now it returns the handler of 
`0.0.0.0:port`, which only consumers bound to `0.0.0.0` use; for a consumer 
bound to any other host it creates a new, unused factory. Nothing in Camel 
calls it any more, so only external code is affected, but a javadoc line would 
make the change visible:
   
   ```suggestion
       /**
        * @deprecated use {@link #getMultiplexChannelHandler(String, int)}. 
This method only returns the handler of the
        *             listener on {@code 0.0.0.0} for the given port.
        */
       @Deprecated
   ```



##########
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:
   **macOS cannot bind `127.0.0.2`.** Linux and Windows route all of 
`127.0.0.0/8` to the loopback interface, but macOS only configures `127.0.0.1` 
on `lo0`, so the bind fails there with `Can't assign requested address` 
(checked with a plain socket bind on macOS 15). CI runs on Linux and stays 
green, but `mvn test` in this module would fail for every contributor on a Mac. 
Skipping the class there keeps it simple:
   
   ```suggestion
   @DisabledOnOs(value = OS.MAC, disabledReason = "macOS only configures 
127.0.0.1 on the loopback interface")
   public class NettyHttpDifferentHostSamePortTest extends BaseNettyTestSupport 
{
   ```
   
   (with `import org.junit.jupiter.api.condition.DisabledOnOs;` and `import 
org.junit.jupiter.api.condition.OS;`)



##########
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:
   **Non-blocking:** nothing calls this overload. It adds public API whose port 
parsing silently falls back to `0` when the address has no `:port` or a 
malformed one. Both callers use `getMultiplexChannelHandler(address, port)`, so 
this overload could be dropped.



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