Refactor getSocks5Proxy method: Return early, make flow more clear

This commit is contained in:
chimp1984 2020-12-13 14:54:28 -05:00
parent 3a2e4f1d69
commit 7f85fd9b7d
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3

View File

@ -115,18 +115,23 @@ public class HttpClientImpl implements HttpClient {
}
}
@Nullable
private Socks5Proxy getSocks5Proxy(Socks5ProxyProvider socks5ProxyProvider) {
Socks5Proxy socks5Proxy = null;
if (socks5ProxyProvider != null) {
// We use the custom socks5ProxyHttp. If not set we request socks5ProxyProvider.getSocks5ProxyBtc()
// which delivers the btc proxy if set, otherwise the internal proxy.
socks5Proxy = socks5ProxyProvider.getSocks5ProxyHttp();
if (socks5Proxy == null)
socks5Proxy = socks5ProxyProvider.getSocks5Proxy();
if (socks5ProxyProvider == null) {
return null;
}
// We use the custom socks5ProxyHttp.
Socks5Proxy socks5Proxy = socks5ProxyProvider.getSocks5ProxyHttp();
if (socks5Proxy != null) {
return socks5Proxy;
}
// If not set we request socks5ProxyProvider.getSocks5Proxy()
// which delivers the btc proxy if set, otherwise the internal proxy.
return socks5ProxyProvider.getSocks5Proxy();
}
/**
* Make an HTTP Get request directly (not routed over socks5 proxy).
*/