diff options
author | Evan Nelson <enelson@squareup.com> | 2024-05-14 10:48:07 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-14 10:48:07 -0700 |
commit | bd611089c2f07ab0d9a7eae610d9f7383139a5a3 (patch) | |
tree | 456aa6ccc6633f073d8fecf5080f4c97a794f58b | |
parent | 62031cd8f4a04600c11a4b294a6f786581ff6069 (diff) | |
download | okhttp4-upstream-master.tar.gz |
Fix an environment-specific bug in RouteFailureTest (#8409)upstream-master
InetSocketAddress's constructor will try to resolve the host to an IP address. As a result, if you're on a network that happens to have a resolvable `myproxy` host, this test would fail -- and as it turns out, my home network does.
Instead, use InetSocketAddress.createUnresolved().
-rw-r--r-- | okhttp/src/test/java/okhttp3/RouteFailureTest.kt | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/okhttp/src/test/java/okhttp3/RouteFailureTest.kt b/okhttp/src/test/java/okhttp3/RouteFailureTest.kt index 4ced61578..c0884a454 100644 --- a/okhttp/src/test/java/okhttp3/RouteFailureTest.kt +++ b/okhttp/src/test/java/okhttp3/RouteFailureTest.kt @@ -316,7 +316,8 @@ class RouteFailureTest { fun proxyMoveTest(cleanShutdown: Boolean) { // Define a single Proxy at myproxy:8008 that will artificially move during the test val proxySelector = RecordingProxySelector() - proxySelector.proxies.add(Proxy(Proxy.Type.HTTP, InetSocketAddress("myproxy", 8008))) + val socketAddress = InetSocketAddress.createUnresolved("myproxy", 8008) + proxySelector.proxies.add(Proxy(Proxy.Type.HTTP, socketAddress)) // Define two host names for the DNS routing of fake proxy servers val proxyServer1 = InetAddress.getByAddress("proxyServer1", byteArrayOf(127, 0, 0, 2)) |