Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8192817

DNSContext may replace several query types with ANY

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 8, 9
    • core-libs
    • 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.

            aefimov Aleksej Efimov
            chegar Chris Hegarty
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: