tcp.close();
}
Header hdr2 = new Header(msg2, msg2.length);
if (hdr2.query)
{
throw new CommunicationException(
"DNS error: expecting response");
}
checkResponseCode(hdr2);
if (!auth || hdr2.authoritative)
{
// Got a valid response
hdr = hdr2;
msg = msg2;
break;
}
else
{
doNotRetry[ij] = true;
}
}
catch (Exception e)
{
// Try next server, or use UDP response
}
} // servers
}
return new ResourceRecords(msg, msg.length, hdr, false);
}
catch (IOException e)
{
if (debug)
{
dprint("Caught IOException:" + e);
}
if (caughtException == null)
{
caughtException = e;
}
// Use reflection to allow pre-1.4 compilation.
// This won't be needed much longer.
if (e.getClass().getName()
.equals("java.net.PortUnreachableException"))
{
doNotRetry[i] = true;
}
}
catch (NameNotFoundException e)
{
throw e;
}
catch (CommunicationException e)
{
if (caughtException == null)
{
caughtException = e;
}
}
catch (NamingException e)
{
if (caughtException == null)
{
caughtException = e;
}
doNotRetry[i] = true;
}
} // servers
} // retries
reqs.remove(xid);
if (caughtException instanceof NamingException)
{
throw (NamingException) caughtException;
}
// A network timeout or other error occurred.
NamingException ne = new CommunicationException("DNS error");
ne.setRootCause(caughtException);
throw ne;
}