nva commented on code in PR #7031:
URL: https://github.com/apache/ignite-3/pull/7031#discussion_r2570821119


##########
modules/client/src/main/java/org/apache/ignite/internal/client/ReliableChannel.java:
##########
@@ -414,20 +423,46 @@ public CompletableFuture<ClientChannel> 
getChannelAsync(@Nullable String preferr
      * @return host:port_range address lines parsed as {@link 
InetSocketAddress} as a key. Value is the amount of appearences of an address
      *         in {@code addrs} parameter.
      */
-    private static Map<InetSocketAddress, Integer> parsedAddresses(String[] 
addrs) {
+    private static Map<InetSocketAddress, Integer> 
parsedAddresses(InetAddressResolver addressResolver, String[] addrs) {
         if (addrs == null || addrs.length == 0) {
             throw new IgniteException(CONFIGURATION_ERR, "Empty addresses");
         }
 
-        Collection<HostAndPort> ranges = new ArrayList<>(addrs.length);
+        Collection<HostAndPort> parsedAddrs = new ArrayList<>(addrs.length);
 
         for (String a : addrs) {
-            ranges.add(HostAndPort.parse(a, 
IgniteClientConfiguration.DFLT_PORT, "Failed to parse Ignite server address"));
+            parsedAddrs.add(HostAndPort.parse(a, 
IgniteClientConfiguration.DFLT_PORT, "Failed to parse Ignite server address"));
         }
 
-        return ranges.stream()
-                .map(p -> InetSocketAddress.createUnresolved(p.host(), 
p.port()))
-                .collect(Collectors.toMap(a -> a, a -> 1, Integer::sum));
+        var map = new HashMap<InetSocketAddress, Integer>(parsedAddrs.size());
+
+        for (HostAndPort addr : parsedAddrs) {
+            try {
+                // Special handling for "localhost" to avoid unnecessary DNS 
resolution.
+                if ("localhost".equalsIgnoreCase(addr.host())) {
+                    map.merge(InetSocketAddress.createUnresolved(addr.host(), 
addr.port()), 1, Integer::sum);
+
+                    continue;

Review Comment:
   Looks like you're right. Potentially, we have more than one name (localhost, 
InetAddress.getLocalHost().getHostName()) for the loopback interface.
   It might be a problem since the client will try to connect to all loopback 
addresses (127.0.0.1, 0:0:0:0:0:0:0:1) if you set "localhost".



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