-
Bug
-
Resolution: Unresolved
-
P4
-
8, 9
-
None
Some modern DNS servers (e.g. CloudFare) reject DNS requests of type "ANY". The JDK 8 implementation (which used com.sun.jndi.dns.DNSContext) tries to squash queries for several DNS types into a single ANY query (e.g. a lookup which queries "A", "AAAA" and "CNAME" were mapped to a single "ANY" query). This is still done in the latest version of DNSContext in JDK 9 and 10:
/*
* Returns the most restrictive resource record class and type
* that may be used to query for records matching cts.
* See classAndTypeMatch() for matching rules.
*/
private static CT getClassAndTypeToQuery(CT[] cts) {
int rrclass;
int rrtype;
if (cts == null) {
// Query all records.
rrclass = ANY;
rrtype = ANY;
} else if (cts.length == 0) {
// No records are requested, but we need to ask for something.
rrclass = ResourceRecord.CLASS_INTERNET;
rrtype = ANY;
} else {
rrclass = cts[0].rrclass;
rrtype = cts[0].rrtype;
for (int i = 1; i < cts.length; i++) {
if (rrclass != cts[i].rrclass) {
rrclass = ANY;
}
if (rrtype != cts[i].rrtype) {
rrtype = ANY;
}
}
}
return new CT(rrclass, rrtype);
DNSNameService.lookupAllHostAddr() wants to query the three record types "A", "AAAA", "CNAME", but in the end this results into a query of "ANY" which fails for some DNS servers. Notice that the OS-implementations do single requests.
/*
* Returns the most restrictive resource record class and type
* that may be used to query for records matching cts.
* See classAndTypeMatch() for matching rules.
*/
private static CT getClassAndTypeToQuery(CT[] cts) {
int rrclass;
int rrtype;
if (cts == null) {
// Query all records.
rrclass = ANY;
rrtype = ANY;
} else if (cts.length == 0) {
// No records are requested, but we need to ask for something.
rrclass = ResourceRecord.CLASS_INTERNET;
rrtype = ANY;
} else {
rrclass = cts[0].rrclass;
rrtype = cts[0].rrtype;
for (int i = 1; i < cts.length; i++) {
if (rrclass != cts[i].rrclass) {
rrclass = ANY;
}
if (rrtype != cts[i].rrtype) {
rrtype = ANY;
}
}
}
return new CT(rrclass, rrtype);
DNSNameService.lookupAllHostAddr() wants to query the three record types "A", "AAAA", "CNAME", but in the end this results into a query of "ANY" which fails for some DNS servers. Notice that the OS-implementations do single requests.