List<Proxy> (@Nullable URI uri) { isInstalledAssertion(); if (uri == null) { return NO_PROXY_LIST; } LOG.debug("CommonProxy.select called for " + uri); if (Boolean.TRUE.equals(ourReenterDefence.get())) { return NO_PROXY_LIST; } try { ourReenterDefence.set(Boolean.TRUE); String host = Strings.notNullize(uri.getHost()); if (isLocalhost(host)) { return NO_PROXY_LIST; } final HostInfo info = new HostInfo(uri.getScheme(), host, correctPortByProtocol(uri)); final Map<String, ProxySelector> copy; synchronized (myLock) { if (myNoProxy.contains(Pair.create(info, Thread.currentThread()))) { LOG.debug("CommonProxy.select returns no proxy (in no proxy list) for " + uri); return NO_PROXY_LIST; } copy = Map.copyOf(myCustom); } for (Map.Entry<String, ProxySelector> entry : copy.entrySet()) { List<Proxy> proxies = entry.getValue().select(uri); if (proxies != null && !proxies.isEmpty()) { LOG.debug("CommonProxy.select returns custom proxy for " + uri + ", " + proxies); return proxies; } } return NO_PROXY_LIST; } finally { ourReenterDefence.remove(); } }