Use higher maxQueriesPerResolve and make exception message more clear.
Motivation: We use a default of 3 for maxQueriesPerResolve when using the DnsNameResolverBuilder, which is too low if you want to resolve a hostname that uses a lot of CNAME records. Modifications: - Use higher default (16) - Make exception message more clear why it failed. Result: Be able to resolve more domains by default and be able to better trouble shoot why a resolver failed.
This commit is contained in:
parent
584fbac6ed
commit
ee5969edfd
@ -48,7 +48,7 @@ public final class DnsNameResolverBuilder {
|
|||||||
private long queryTimeoutMillis = 5000;
|
private long queryTimeoutMillis = 5000;
|
||||||
private InternetProtocolFamily[] resolvedAddressTypes = DnsNameResolver.DEFAULT_RESOLVE_ADDRESS_TYPES;
|
private InternetProtocolFamily[] resolvedAddressTypes = DnsNameResolver.DEFAULT_RESOLVE_ADDRESS_TYPES;
|
||||||
private boolean recursionDesired = true;
|
private boolean recursionDesired = true;
|
||||||
private int maxQueriesPerResolve = 3;
|
private int maxQueriesPerResolve = 16;
|
||||||
private boolean traceEnabled;
|
private boolean traceEnabled;
|
||||||
private int maxPayloadSize = 4096;
|
private int maxPayloadSize = 4096;
|
||||||
private boolean optResourceEnabled = true;
|
private boolean optResourceEnabled = true;
|
||||||
|
@ -412,25 +412,23 @@ abstract class DnsNameResolverContext<T> {
|
|||||||
final int tries = maxAllowedQueries - allowedQueries;
|
final int tries = maxAllowedQueries - allowedQueries;
|
||||||
final StringBuilder buf = new StringBuilder(64);
|
final StringBuilder buf = new StringBuilder(64);
|
||||||
|
|
||||||
buf.append("failed to resolve ");
|
buf.append("failed to resolve '")
|
||||||
buf.append(hostname);
|
.append(hostname).append('\'');
|
||||||
|
|
||||||
if (tries > 1) {
|
if (tries > 1) {
|
||||||
buf.append(" after ");
|
if (tries < maxAllowedQueries) {
|
||||||
buf.append(tries);
|
buf.append(" after ")
|
||||||
if (trace != null) {
|
.append(tries)
|
||||||
buf.append(" queries:");
|
.append(" queries ");
|
||||||
buf.append(trace);
|
|
||||||
} else {
|
} else {
|
||||||
buf.append(" queries");
|
buf.append(". Exceeded max queries per resolve ")
|
||||||
}
|
.append(maxAllowedQueries)
|
||||||
} else {
|
.append(' ');
|
||||||
if (trace != null) {
|
|
||||||
buf.append(':');
|
|
||||||
buf.append(trace);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (trace != null) {
|
||||||
|
buf.append(':')
|
||||||
|
.append(trace);
|
||||||
|
}
|
||||||
final UnknownHostException cause = new UnknownHostException(buf.toString());
|
final UnknownHostException cause = new UnknownHostException(buf.toString());
|
||||||
|
|
||||||
resolveCache.cache(hostname, cause, parent.ch.eventLoop());
|
resolveCache.cache(hostname, cause, parent.ch.eventLoop());
|
||||||
|
Loading…
Reference in New Issue
Block a user