public Route next() throws IOException { if (!hasNextInetSocketAddress()) { if (hasNextProxy()) { this.lastProxy = nextProxy(); } else if (hasNextPostponed()) { return nextPostponed(); } else { throw new NoSuchElementException(); } } this.lastInetSocketAddress = nextInetSocketAddress(); Route route = new Route(this.address, this.lastProxy, this.lastInetSocketAddress); if (!this.routeDatabase.shouldPostpone(route)) { return route; } this.postponedRoutes.add(route); return next(); }
public final void connectFailed(Connection paramConnection, IOException paramIOException) { if (Internal.instance.recycleCount(paramConnection) > 0) {} for (;;) { return; Route localRoute1 = paramConnection.route; if ((localRoute1.proxy.type() != Proxy.Type.DIRECT) && (this.address.proxySelector != null)) { this.address.proxySelector.connectFailed(this.uri, localRoute1.proxy.address(), paramIOException); } this.routeDatabase.failed(localRoute1); if ((!(paramIOException instanceof SSLHandshakeException)) && (!(paramIOException instanceof SSLProtocolException))) { while (this.nextSpecIndex < this.connectionSpecs.size()) { List localList = this.connectionSpecs; int i = this.nextSpecIndex; this.nextSpecIndex = (i + 1); ConnectionSpec localConnectionSpec = (ConnectionSpec)localList.get(i); boolean bool = shouldSendTlsFallbackIndicator(localConnectionSpec); Route localRoute2 = new Route(this.address, this.lastProxy, this.lastInetSocketAddress, localConnectionSpec, bool); this.routeDatabase.failed(localRoute2); } } } }
public void connectFailed(Route failedRoute, IOException failure) { if (!(failedRoute.getProxy().type() == Type.DIRECT || this.address.getProxySelector() == null)) { this.address.getProxySelector().connectFailed(this.address.url().uri(), failedRoute .getProxy().address(), failure); } this.routeDatabase.failed(failedRoute); }
public RouteSelector(Address address, URI uri, ProxySelector proxySelector, ConnectionPool pool, Dns dns, RouteDatabase routeDatabase) { this.address = address; this.uri = uri; this.proxySelector = proxySelector; this.pool = pool; this.dns = dns; this.routeDatabase = routeDatabase; this.postponedRoutes = new LinkedList<Route>(); resetNextProxy(uri, address.getProxy()); }
/** * Returns the next route address to attempt. * * @throws NoSuchElementException if there are no more routes to attempt. */ public Connection next(String method) throws IOException { // Always prefer pooled connections over new connections. for (Connection pooled; (pooled = pool.get(address)) != null; ) { if (method.equals("GET") || pooled.isReadable()) return pooled; pooled.close(); } // Compute the next route to attempt. if (!hasNextTlsMode()) { if (!hasNextInetSocketAddress()) { if (!hasNextProxy()) { if (!hasNextPostponed()) { throw new NoSuchElementException(); } return new Connection(nextPostponed()); } lastProxy = nextProxy(); resetNextInetSocketAddress(lastProxy); } lastInetSocketAddress = nextInetSocketAddress(); resetNextTlsMode(); } boolean modernTls = nextTlsMode() == TLS_MODE_MODERN; Route route = new Route(address, lastProxy, lastInetSocketAddress, modernTls); if (routeDatabase.shouldPostpone(route)) { postponedRoutes.add(route); // We will only recurse in order to skip previously failed routes. They will be // tried last. return next(method); } return new Connection(route); }
/** * Clients should invoke this method when they encounter a connectivity * failure on a connection returned by this route selector. */ public void connectFailed(Connection connection, IOException failure) { Route failedRoute = connection.getRoute(); if (failedRoute.getProxy().type() != Proxy.Type.DIRECT && proxySelector != null) { // Tell the proxy selector when we fail to connect on a fresh connection. proxySelector.connectFailed(uri, failedRoute.getProxy().address(), failure); } routeDatabase.failed(failedRoute, failure); }
public final void connected(Route paramRoute) { try { this.failedRoutes.remove(paramRoute); return; } finally { localObject = finally; throw localObject; } }
public final void failed(Route paramRoute) { try { this.failedRoutes.add(paramRoute); return; } finally { localObject = finally; throw localObject; } }
public final boolean shouldPostpone(Route paramRoute) { try { boolean bool = this.failedRoutes.contains(paramRoute); return bool; } finally { localObject = finally; throw localObject; } }