mirror of
https://github.com/square/okhttp.git
synced 2026-01-14 07:22:20 +03:00
Short circuit more aggressively when ExchangeFinder has routes.
This commit is contained in:
@@ -124,11 +124,15 @@ class ExchangeFinder(
|
||||
// Make sure we have some routes left to try. One example where we may exhaust all the routes
|
||||
// would happen if we made a new connection and it immediately is detected as unhealthy.
|
||||
synchronized(connectionPool) {
|
||||
if (nextRouteToTry != null) return@synchronized
|
||||
|
||||
val routesLeft = routeSelection?.hasNext() ?: true
|
||||
if (routesLeft) return@synchronized
|
||||
|
||||
val routesSelectionLeft = routeSelector?.hasNext() ?: true
|
||||
if (nextRouteToTry == null && !routesLeft && !routesSelectionLeft) {
|
||||
throw IOException("exhausted all routes")
|
||||
}
|
||||
if (routesSelectionLeft) return@synchronized
|
||||
|
||||
throw IOException("exhausted all routes")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3804,7 +3804,9 @@ public final class CallTest {
|
||||
.eventListener(listener)
|
||||
.build();
|
||||
|
||||
executeSynchronously("/").assertFailure(IOException.class);
|
||||
executeSynchronously("/")
|
||||
.assertFailure(IOException.class)
|
||||
.assertFailure("exhausted all routes");
|
||||
}
|
||||
|
||||
@Test public void requestBodyThrowsUnrelatedToNetwork() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user