diff --git a/src/main/generated/io/vertx/core/dns/AddressResolverOptionsConverter.java b/src/main/generated/io/vertx/core/dns/AddressResolverOptionsConverter.java index c30585cdbac..d6b90a9a871 100644 --- a/src/main/generated/io/vertx/core/dns/AddressResolverOptionsConverter.java +++ b/src/main/generated/io/vertx/core/dns/AddressResolverOptionsConverter.java @@ -3,8 +3,6 @@ import io.vertx.core.json.JsonObject; import io.vertx.core.json.JsonArray; import io.vertx.core.json.impl.JsonUtil; -import java.time.Instant; -import java.time.format.DateTimeFormatter; import java.util.Base64; /** @@ -105,6 +103,11 @@ static void fromJson(Iterable> json, Address obj.setServers(list); } break; + case "retryWithTcpOnTimeout": + if (member.getValue() instanceof Boolean) { + obj.setRetryWithTcpOnTimeout((Boolean)member.getValue()); + } + break; } } } @@ -141,5 +144,6 @@ static void toJson(AddressResolverOptions obj, java.util.Map jso obj.getServers().forEach(item -> array.add(item)); json.put("servers", array); } + json.put("retryWithTcpOnTimeout", obj.isRetryWithTcpOnTimeout()); } } diff --git a/src/main/java/io/vertx/core/dns/AddressResolverOptions.java b/src/main/java/io/vertx/core/dns/AddressResolverOptions.java index 2bc35f5920b..2225fd8f364 100644 --- a/src/main/java/io/vertx/core/dns/AddressResolverOptions.java +++ b/src/main/java/io/vertx/core/dns/AddressResolverOptions.java @@ -103,6 +103,11 @@ public class AddressResolverOptions { */ public static final boolean DEFAULT_ROUND_ROBIN_INET_ADDRESS = false; + /** + * The default retry with TCP on timeout = false + */ + public static final boolean DEFAULT_RETRY_WITH_TCP_ON_TIMEOUT = false; + private String hostsPath; private Buffer hostsValue; private int hostsRefreshPeriod; @@ -118,6 +123,7 @@ public class AddressResolverOptions { private int ndots; private boolean rotateServers; private boolean roundRobinInetAddress; + private boolean retryWithTcpOnTimeout; public AddressResolverOptions() { servers = DEFAULT_SERVERS; @@ -133,6 +139,7 @@ public AddressResolverOptions() { rotateServers = DEFAULT_ROTATE_SERVERS; roundRobinInetAddress = DEFAULT_ROUND_ROBIN_INET_ADDRESS; hostsRefreshPeriod = DEFAULT_HOSTS_REFRESH_PERIOD; + retryWithTcpOnTimeout = DEFAULT_RETRY_WITH_TCP_ON_TIMEOUT; } public AddressResolverOptions(AddressResolverOptions other) { @@ -151,6 +158,7 @@ public AddressResolverOptions(AddressResolverOptions other) { this.ndots = other.ndots; this.rotateServers = other.rotateServers; this.roundRobinInetAddress = other.roundRobinInetAddress; + this.retryWithTcpOnTimeout = other.retryWithTcpOnTimeout; } public AddressResolverOptions(JsonObject json) { @@ -496,6 +504,23 @@ public AddressResolverOptions setRoundRobinInetAddress(boolean roundRobinInetAdd return this; } + /** + * @return the value of retry with TCP on timeout flag + */ + public boolean isRetryWithTcpOnTimeout() { + return retryWithTcpOnTimeout; + } + + /** + * Set retry with TCP on timeout flag. + * + * @return a reference to this, so the API can be used fluently + */ + public AddressResolverOptions setRetryWithTcpOnTimeout(boolean retryWithTcpOnTimeout) { + this.retryWithTcpOnTimeout = retryWithTcpOnTimeout; + return this; + } + public JsonObject toJson() { JsonObject json = new JsonObject(); AddressResolverOptionsConverter.toJson(this, json); diff --git a/src/main/java/io/vertx/core/impl/resolver/DnsResolverProvider.java b/src/main/java/io/vertx/core/impl/resolver/DnsResolverProvider.java index 5f2e092f05e..912bb426a26 100644 --- a/src/main/java/io/vertx/core/impl/resolver/DnsResolverProvider.java +++ b/src/main/java/io/vertx/core/impl/resolver/DnsResolverProvider.java @@ -105,7 +105,8 @@ private DnsResolverProvider(VertxInternal vertx, AddressResolverOptions options) DnsNameResolverBuilder builder = new DnsNameResolverBuilder(); builder.hostsFileEntriesResolver(this); builder.channelFactory(() -> vertx.transport().datagramChannel()); - builder.socketChannelFactory(() -> (SocketChannel) vertx.transport().channelFactory(false).newChannel()); + builder.socketChannelFactory(() -> + (SocketChannel) vertx.transport().channelFactory(false).newChannel(), options.isRetryWithTcpOnTimeout()); builder.nameServerProvider(nameServerAddressProvider); builder.optResourceEnabled(options.isOptResourceEnabled()); builder.resolveCache(resolveCache);