Skip to content

Commit

Permalink
Fix an environment-specific bug in RouteFailureTest (#8409)
Browse files Browse the repository at this point in the history
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().
  • Loading branch information
ean5533 committed May 14, 2024
1 parent 62031cd commit bd61108
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion okhttp/src/test/java/okhttp3/RouteFailureTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit bd61108

Please sign in to comment.