private void nextConnection(URI uri) { final int port = getSchemePort(uri); String key = getConnectionKey(uri.getScheme(), uri.getHost(), port); ConnectionInfo info = connectionInfo.get(key); if (info == null) return; --info.openCount; while (info.openCount < maxConnectionCount && info.queue.size() > 0) { AsyncHttpClientMiddleware.GetSocketData gsd = info.queue.remove(); SimpleCancellable socketCancellable = (SimpleCancellable) gsd.socketCancellable; if (socketCancellable.isCancelled()) continue; Cancellable connect = getSocket(gsd); socketCancellable.setParent(connect); } if (info.queue.size() == 0 && info.openCount == 0) connectionInfo.remove(key); }