ok2c commented on code in PR #418:
URL: 
https://github.com/apache/httpcomponents-client/pull/418#discussion_r1124684449


##########
httpclient5/src/main/java/org/apache/hc/client5/http/SystemDefaultDnsResolver.java:
##########
@@ -40,7 +40,23 @@ public class SystemDefaultDnsResolver implements DnsResolver 
{
 
     @Override
     public InetAddress[] resolve(final String host) throws 
UnknownHostException {
-        return InetAddress.getAllByName(host);
+        try {
+            // Try resolving using the default resolver
+            return InetAddress.getAllByName(host);
+        } catch (final UnknownHostException e) {
+            // If default resolver fails, try stripping the IPv6 zone ID and 
resolving again
+            String strippedHost = host;
+            if (host.charAt(0) == '[') {
+                final int i = host.lastIndexOf('%');
+                if (i != -1) {
+                    strippedHost = host.substring(0, i) + "]";
+                }
+            }
+            if (!strippedHost.equals(host)) {

Review Comment:
   @arturobernalg The whole point of inlining the method was to avoid this 
extra comparison! Please use a boolean variable instead or set `strippedHost` 
by default.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to