@@ -68,12 +68,15 @@ public static ManagedChannelBuilder<?> forPath(String path, Namespace namespace)
|
68 | 68 | throw new UnsupportedOperationException("OkHttpChannelBuilder not found on the classpath"); |
69 | 69 | } |
70 | 70 | try { |
71 | | -// Target 'dns:///localhost' is unused, but necessary as an argument for OkHttpChannelBuilder. |
| 71 | +// Target 'dns:///127.0.0.1' is unused, but necessary as an argument for OkHttpChannelBuilder. |
| 72 | +// An IP address is used instead of localhost to avoid a DNS lookup (see #11442). This should |
| 73 | +// work even if IPv4 is unavailable, as the DNS resolver doesn't need working IPv4 to parse an |
| 74 | +// IPv4 address. Unavailable IPv4 fails when we connect(), not at resolution time. |
72 | 75 | // TLS is unsupported because Conscrypt assumes the platform Socket implementation to improve |
73 | 76 | // performance by using the file descriptor directly. |
74 | 77 | Object o = OKHTTP_CHANNEL_BUILDER_CLASS |
75 | 78 | .getMethod("forTarget", String.class, ChannelCredentials.class) |
76 | | - .invoke(null, "dns:///localhost", InsecureChannelCredentials.create()); |
| 79 | + .invoke(null, "dns:///127.0.0.1", InsecureChannelCredentials.create()); |
77 | 80 | ManagedChannelBuilder<?> builder = OKHTTP_CHANNEL_BUILDER_CLASS.cast(o); |
78 | 81 | OKHTTP_CHANNEL_BUILDER_CLASS |
79 | 82 | .getMethod("socketFactory", SocketFactory.class) |
|