Copilot commented on code in PR #23934:
URL: https://github.com/apache/kafka/pull/23934#discussion_r4358982030


##########
clients/src/main/java/org/apache/kafka/clients/ClientUtils.java:
##########
@@ -85,19 +88,45 @@ private static List<InetSocketAddress> resolveAddress(
                 }
             }
         } else {
-            InetSocketAddress address = new InetSocketAddress(host, port);
-            if (address.isUnresolved()) {
+            // Preserve the pre-existing single-address-per-host contract of 
this lookup mode
+            // (equivalent to InetSocketAddress(host, port)'s implicit 
resolution): take only the
+            // first address the resolver returns, rather than all of them 
like the branch above.
+            try {
+                InetAddress[] resolved = hostResolver.resolve(host);

Review Comment:
   Validate the port range before calling the resolver. Previously, 
`InetSocketAddress(host, port)` rejected an out-of-range port before attempting 
DNS. Now, if resolution throws `UnknownHostException`, this branch catches it 
and skips the address without checking its port. For example, 
`parseAndValidateAddresses(["bad.invalid:70000", "127.0.0.1:9092"], 
USE_ALL_DNS_IPS)` accepts the configuration when the first hostname cannot be 
resolved, instead of throwing `ConfigException`. Restore the range check before 
resolution, and add a regression test with an injected resolver that fails for 
the invalid-port entry and succeeds for the valid entry.



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