don't retry if it is taking too long

(cherry picked from commit 8c264ea0441567ca9063dde4ee89c9e8719d69f1)
This commit is contained in:
Stephen Paul Weber 2024-12-09 10:46:10 -05:00 committed by Arne
parent e10b34bd6f
commit 8d29f71c92

View file

@ -486,11 +486,13 @@ public class Resolver {
private static <D extends Data> ListenableFuture<ResolverResult<D>> resolveAsFuture( private static <D extends Data> ListenableFuture<ResolverResult<D>> resolveAsFuture(
final DnsName dnsName, final Class<D> type) { final DnsName dnsName, final Class<D> type) {
final var start = System.currentTimeMillis();
return Futures.submit( return Futures.submit(
() -> { () -> {
final Question question = new Question(dnsName, Record.TYPE.getType(type)); final Question question = new Question(dnsName, Record.TYPE.getType(type));
if (!DNSSECLESS_TLDS.contains(dnsName.getLabels()[0].toString())) { if (!DNSSECLESS_TLDS.contains(dnsName.getLabels()[0].toString())) {
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
if (System.currentTimeMillis() - start > 5000) break;
try { try {
ResolverResult<D> result = DnssecResolverApi.INSTANCE.resolve(question); ResolverResult<D> result = DnssecResolverApi.INSTANCE.resolve(question);
if (result.wasSuccessful() && !result.isAuthenticData()) { if (result.wasSuccessful() && !result.isAuthenticData()) {