@Test public void testNegativeTtl() throws Exception { final DnsNameResolver resolver = newResolver().negativeTtl(10).build(); try { resolveNonExistentDomain(resolver); final int size = 10000; final List<UnknownHostException> exceptions = new ArrayList<UnknownHostException>(); final Thread negativeLookupThread = new Thread() { @Override public void run() { for (int i = 0; i < size; i++) { exceptions.add(resolveNonExistentDomain(resolver)); if (isInterrupted()) { break; } } } }; negativeLookupThread.start(); negativeLookupThread.join(DEFAULT_TEST_TIMEOUT_MS); if (negativeLookupThread.isAlive()) { negativeLookupThread.interrupt(); fail("Cached negative lookups did not finish quickly."); } assertThat(exceptions, hasSize(size)); } finally { resolver.close(); } }
@Override public void close() { if (ch.isOpen()) { ch.close(); } }
DnsNameResolver extends InetNameResolver { @Override public void close() { if (ch.isOpen()) { ch.close(); } } }
DnsNameResolver extends InetNameResolver { @Override public void close() { if (ch.isOpen()) { ch.close(); } } DnsNameResolver(
            EventLoop eventLoop,
            ChannelFactory<? extends DatagramChannel> channelFactory,
            final DnsCache resolveCache,
            DnsCache authoritativeDnsServerCache,
            DnsQueryLifecycleObserverFactory dnsQueryLifecycleObserverFactory,
            long queryTimeoutMillis,
            ResolvedAddressTypes resolvedAddressTypes,
            boolean recursionDesired,
            int maxQueriesPerResolve,
            boolean traceEnabled,
            int maxPayloadSize,
            boolean optResourceEnabled,
            HostsFileEntriesResolver hostsFileEntriesResolver,
            DnsServerAddressStreamProvider dnsServerAddressStreamProvider,
            String[] searchDomains,
            int ndots,
            boolean decodeIdn); }
DnsNameResolver extends InetNameResolver { @Override public void close() { if (ch.isOpen()) { ch.close(); } } DnsNameResolver(
            EventLoop eventLoop,
            ChannelFactory<? extends DatagramChannel> channelFactory,
            final DnsCache resolveCache,
            DnsCache authoritativeDnsServerCache,
            DnsQueryLifecycleObserverFactory dnsQueryLifecycleObserverFactory,
            long queryTimeoutMillis,
            ResolvedAddressTypes resolvedAddressTypes,
            boolean recursionDesired,
            int maxQueriesPerResolve,
            boolean traceEnabled,
            int maxPayloadSize,
            boolean optResourceEnabled,
            HostsFileEntriesResolver hostsFileEntriesResolver,
            DnsServerAddressStreamProvider dnsServerAddressStreamProvider,
            String[] searchDomains,
            int ndots,
            boolean decodeIdn); DnsCache resolveCache(); DnsCache authoritativeDnsServerCache(); long queryTimeoutMillis(); ResolvedAddressTypes resolvedAddressTypes(); boolean isRecursionDesired(); int maxQueriesPerResolve(); int maxPayloadSize(); boolean isOptResourceEnabled(); HostsFileEntriesResolver hostsFileEntriesResolver(); @Override void close(); final Future<InetAddress> resolve(String inetHost, Iterable<DnsRecord> additionals); final Future<InetAddress> resolve(String inetHost, Iterable<DnsRecord> additionals,
                                             Promise<InetAddress> promise); final Future<List<InetAddress>> resolveAll(String inetHost, Iterable<DnsRecord> additionals); final Future<List<InetAddress>> resolveAll(String inetHost, Iterable<DnsRecord> additionals,
                                                Promise<List<InetAddress>> promise); final Future<List<DnsRecord>> resolveAll(DnsQuestion question); final Future<List<DnsRecord>> resolveAll(DnsQuestion question, Iterable<DnsRecord> additionals); final Future<List<DnsRecord>> resolveAll(DnsQuestion question, Iterable<DnsRecord> additionals,
                                                    Promise<List<DnsRecord>> promise); Future<AddressedEnvelope<DnsResponse, InetSocketAddress>> query(DnsQuestion question); Future<AddressedEnvelope<DnsResponse, InetSocketAddress>> query(
            DnsQuestion question, Iterable<DnsRecord> additionals); Future<AddressedEnvelope<DnsResponse, InetSocketAddress>> query(
            DnsQuestion question, Promise<AddressedEnvelope<? extends DnsResponse, InetSocketAddress>> promise); Future<AddressedEnvelope<DnsResponse, InetSocketAddress>> query(
            InetSocketAddress nameServerAddr, DnsQuestion question); Future<AddressedEnvelope<DnsResponse, InetSocketAddress>> query(
            InetSocketAddress nameServerAddr, DnsQuestion question, Iterable<DnsRecord> additionals); Future<AddressedEnvelope<DnsResponse, InetSocketAddress>> query(
            InetSocketAddress nameServerAddr, DnsQuestion question,
            Promise<AddressedEnvelope<? extends DnsResponse, InetSocketAddress>> promise); Future<AddressedEnvelope<DnsResponse, InetSocketAddress>> query(
            InetSocketAddress nameServerAddr, DnsQuestion question,
            Iterable<DnsRecord> additionals,
            Promise<AddressedEnvelope<? extends DnsResponse, InetSocketAddress>> promise); static boolean isTransportOrTimeoutError(Throwable cause); static boolean isTimeoutError(Throwable cause); }
DnsNameResolver extends InetNameResolver { @Override public void close() { if (ch.isOpen()) { ch.close(); } } DnsNameResolver(
            EventLoop eventLoop,
            ChannelFactory<? extends DatagramChannel> channelFactory,
            final DnsCache resolveCache,
            DnsCache authoritativeDnsServerCache,
            DnsQueryLifecycleObserverFactory dnsQueryLifecycleObserverFactory,
            long queryTimeoutMillis,
            ResolvedAddressTypes resolvedAddressTypes,
            boolean recursionDesired,
            int maxQueriesPerResolve,
            boolean traceEnabled,
            int maxPayloadSize,
            boolean optResourceEnabled,
            HostsFileEntriesResolver hostsFileEntriesResolver,
            DnsServerAddressStreamProvider dnsServerAddressStreamProvider,
            String[] searchDomains,
            int ndots,
            boolean decodeIdn); DnsCache resolveCache(); DnsCache authoritativeDnsServerCache(); long queryTimeoutMillis(); ResolvedAddressTypes resolvedAddressTypes(); boolean isRecursionDesired(); int maxQueriesPerResolve(); int maxPayloadSize(); boolean isOptResourceEnabled(); HostsFileEntriesResolver hostsFileEntriesResolver(); @Override void close(); final Future<InetAddress> resolve(String inetHost, Iterable<DnsRecord> additionals); final Future<InetAddress> resolve(String inetHost, Iterable<DnsRecord> additionals,
                                             Promise<InetAddress> promise); final Future<List<InetAddress>> resolveAll(String inetHost, Iterable<DnsRecord> additionals); final Future<List<InetAddress>> resolveAll(String inetHost, Iterable<DnsRecord> additionals,
                                                Promise<List<InetAddress>> promise); final Future<List<DnsRecord>> resolveAll(DnsQuestion question); final Future<List<DnsRecord>> resolveAll(DnsQuestion question, Iterable<DnsRecord> additionals); final Future<List<DnsRecord>> resolveAll(DnsQuestion question, Iterable<DnsRecord> additionals,
                                                    Promise<List<DnsRecord>> promise); Future<AddressedEnvelope<DnsResponse, InetSocketAddress>> query(DnsQuestion question); Future<AddressedEnvelope<DnsResponse, InetSocketAddress>> query(
            DnsQuestion question, Iterable<DnsRecord> additionals); Future<AddressedEnvelope<DnsResponse, InetSocketAddress>> query(
            DnsQuestion question, Promise<AddressedEnvelope<? extends DnsResponse, InetSocketAddress>> promise); Future<AddressedEnvelope<DnsResponse, InetSocketAddress>> query(
            InetSocketAddress nameServerAddr, DnsQuestion question); Future<AddressedEnvelope<DnsResponse, InetSocketAddress>> query(
            InetSocketAddress nameServerAddr, DnsQuestion question, Iterable<DnsRecord> additionals); Future<AddressedEnvelope<DnsResponse, InetSocketAddress>> query(
            InetSocketAddress nameServerAddr, DnsQuestion question,
            Promise<AddressedEnvelope<? extends DnsResponse, InetSocketAddress>> promise); Future<AddressedEnvelope<DnsResponse, InetSocketAddress>> query(
            InetSocketAddress nameServerAddr, DnsQuestion question,
            Iterable<DnsRecord> additionals,
            Promise<AddressedEnvelope<? extends DnsResponse, InetSocketAddress>> promise); static boolean isTransportOrTimeoutError(Throwable cause); static boolean isTimeoutError(Throwable cause);  }