[ 
https://issues.apache.org/jira/browse/ARTEMIS-4189?focusedWorklogId=848325&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-848325
 ]

ASF GitHub Bot logged work on ARTEMIS-4189:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 01/Mar/23 13:18
            Start Date: 01/Mar/23 13:18
    Worklog Time Spent: 10m 
      Work Description: gaohoward commented on code in PR #4385:
URL: https://github.com/apache/activemq-artemis/pull/4385#discussion_r1121714725


##########
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/NetworkUtil.java:
##########
@@ -0,0 +1,84 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.activemq.artemis.utils;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+/**
+ * This is a wrapper class of some InetAddress methods
+ * so we can mock them with static values in test environment
+ */
+public class NetworkUtil {
+
+   public static final InetAddressWrapper[] EMPTY_ADDRESSES = {};
+   public static TestMode testMode = null;

Review Comment:
   > well... another concern is that test is not actually testing the new code. 
How can you guarantee the codebase of NetworkUtil itself?
   
   Well kinda testing the logics of the new code. I've difficulty in testing 
the new code itself mainly because I couldn't find a good way to simulate 
InetAddress methods. So I do a wrapper just to mock those methods but the logic 
is real. 





Issue Time Tracking
-------------------

    Worklog Id:     (was: 848325)
    Time Spent: 1h 10m  (was: 1h)

> NettyConnection.isSameTarget() should compare host names by IPs
> ---------------------------------------------------------------
>
>                 Key: ARTEMIS-4189
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-4189
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 2.28.0
>            Reporter: Howard Gao
>            Assignee: Howard Gao
>            Priority: Major
>          Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> The method just compares the host names using string equals. However when one 
> host name is in IP form (like "10.7.2.2") it should try to resolve the 
> addresses of the host name and make sure they are equal if one of the IP 
> addresses matches. Otherwise it may return wrong comparison result.
> Also when comparing localhost it should take care of the case where the host 
> is absent from the transport configuration.



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

Reply via email to