Permalink
Browse files

Add code comments to DnsClient

  • Loading branch information...
Flowdalic committed Dec 14, 2018
1 parent 6ed6c7b commit 6c076e180cfcba275fad6a8ef32999b4ebf58718
Showing with 3 additions and 0 deletions.
  1. +3 −0 minidns-client/src/main/java/org/minidns/DnsClient.java
@@ -234,6 +234,8 @@ public DnsQueryResult query(DnsMessage.Builder queryBuilder) throws IOException
List<MiniDnsFuture<DnsQueryResult, IOException>> futures = new ArrayList<>(dnsServerAddresses.size());
// "Main" loop.
for (InetAddress dns : dnsServerAddresses) {
// Note that we deliberatly use Future.isDone(), since a few lines below, we only set a negative exception
// result, if all sub-futures signaled an exception.
if (future.isDone()) {
for (MiniDnsFuture<DnsQueryResult, IOException> futureToCancel : futures) {
futureToCancel.cancel(true);
@@ -252,6 +254,7 @@ public void onSuccess(DnsQueryResult result) {
@Override
public void processException(IOException exception) {
exceptions.add(exception);
// Signal the main future about the exceptions, but only if all sub-futures returned an exception.
if (exceptions.size() == dnsServerAddresses.size()) {
future.setException(MultipleIoException.toIOException(exceptions));
}

0 comments on commit 6c076e1

Please sign in to comment.