Use AuthoritativeDnsServerCache for creating the new redirect stream. (#8316)
* Use AuthoritativeDnsServerCache for creating the new redirect stream. Motivation: At the moment if a user wants to provide custom sorting of the nameservers used for redirects it needs to be implemented in two places. This is more complicated as it needs to be. Modifications: - Just delegate to the AuthoritativeDnsServerCache always as we fill it before we call newRedirectDnsServerStream anyway. Result: Easier way for the user to implement custom sorting.
This commit is contained in:
parent
5650db5826
commit
b81c8ed55c
@ -450,8 +450,14 @@ public class DnsNameResolver extends InetNameResolver {
|
||||
*/
|
||||
protected DnsServerAddressStream newRedirectDnsServerStream(
|
||||
@SuppressWarnings("unused") String hostname, List<InetSocketAddress> nameservers) {
|
||||
Collections.sort(nameservers, nameServerComparator);
|
||||
return new SequentialDnsServerAddressStream(nameservers, 0);
|
||||
DnsServerAddressStream cached = authoritativeDnsServerCache().get(hostname);
|
||||
if (cached == null || cached.size() == 0) {
|
||||
// If there is no cache hit (which may be the case for example when a NoopAuthoritativeDnsServerCache
|
||||
// is used), we will just directly use the provided nameservers.
|
||||
Collections.sort(nameservers, nameServerComparator);
|
||||
return new SequentialDnsServerAddressStream(nameservers, 0);
|
||||
}
|
||||
return cached;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user