jackjlli commented on code in PR #13805:
URL: https://github.com/apache/pinot/pull/13805#discussion_r1714328651


##########
pinot-spi/pom.xml:
##########
@@ -131,6 +131,10 @@
       <groupId>org.reflections</groupId>
       <artifactId>reflections</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-core</artifactId>
+    </dependency>

Review Comment:
   put the `<scope>test</scope>` here?



##########
pinot-spi/src/main/java/org/apache/pinot/spi/utils/NetUtils.java:
##########
@@ -20,32 +20,73 @@
 
 import java.io.IOException;
 import java.net.DatagramSocket;
+import java.net.Inet4Address;
+import java.net.Inet6Address;
 import java.net.InetAddress;
 import java.net.ServerSocket;
 import java.net.SocketException;
 import java.net.UnknownHostException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 public class NetUtils {
   private NetUtils() {
   }
 
-  private static final String DUMMY_OUT_IP = "74.125.224.0";
+  private static final Logger LOGGER = LoggerFactory.getLogger(NetUtils.class);
+  // Google Public DNS IPs dns.google
+  private static final int HTTP_PORT = 80;
+  private static final String DUMMY_OUT_IPV4 = "8.8.8.8";
+  private static final String DUMMY_OUT_IPV6 = "2001:4860:4860::8888";
 
   /**
    * Get the ip address of local host.
+   *
+   * @return IP address {@link String}, either IPv4 or IPv6 format depending 
on java.net.preferIPv6Addresses property.
    */
   public static String getHostAddress()
       throws SocketException, UnknownHostException {
+    boolean isIPv6Preferred = 
Boolean.parseBoolean(System.getProperty("java.net.preferIPv6Addresses"));
     DatagramSocket ds = new DatagramSocket();
-    ds.connect(InetAddress.getByName(DUMMY_OUT_IP), 80);
+    try {
+      ds.connect(isIPv6Preferred ? Inet6Address.getByName(DUMMY_OUT_IPV6) : 
Inet4Address.getByName(DUMMY_OUT_IPV4),
+          HTTP_PORT);
+    } catch (java.io.UncheckedIOException e) {

Review Comment:
   nit: should we log the exception message here for better understanding of 
the issue?



-- 
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: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to