diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/server/dns/RegistryDNS.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/server/dns/RegistryDNS.java index c322023682..5e994fb776 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/server/dns/RegistryDNS.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/server/dns/RegistryDNS.java @@ -1106,7 +1106,7 @@ byte[] generateReply(Message query, Socket s) LOG.debug("calling addAnswer"); byte rcode = addAnswer(response, name, type, dclass, 0, flags); if (rcode != Rcode.NOERROR) { - rcode = remoteLookup(response, name, 0); + rcode = remoteLookup(response, name, type, 0); response.getHeader().setRcode(rcode); } addAdditional(response, flags); @@ -1124,9 +1124,10 @@ byte[] generateReply(Message query, Socket s) /** * Lookup record from upstream DNS servers. */ - private byte remoteLookup(Message response, Name name, int iterations) { + private byte remoteLookup(Message response, Name name, int type, + int iterations) { // Forward lookup to primary DNS servers - Record[] answers = getRecords(name, Type.ANY); + Record[] answers = getRecords(name, type); try { for (Record r : answers) { if (r.getType() == Type.SOA) { @@ -1137,7 +1138,7 @@ private byte remoteLookup(Message response, Name name, int iterations) { if (r.getType() == Type.CNAME) { Name cname = ((CNAMERecord) r).getAlias(); if (iterations < 6) { - remoteLookup(response, cname, iterations + 1); + remoteLookup(response, cname, Type.CNAME, iterations + 1); } } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/test/java/org/apache/hadoop/registry/server/dns/TestRegistryDNS.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/test/java/org/apache/hadoop/registry/server/dns/TestRegistryDNS.java index 01adc45f72..6ba58dd99d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/test/java/org/apache/hadoop/registry/server/dns/TestRegistryDNS.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/test/java/org/apache/hadoop/registry/server/dns/TestRegistryDNS.java @@ -424,13 +424,8 @@ Record[] assertDNSQueryNotNull(String lookup, int type) assertEquals("Questions do not match", query.getQuestion(), response.getQuestion()); Record[] recs = response.getSectionArray(Section.ANSWER); - boolean found = false; - for (Record r : recs) { - if (r.getType()==Type.A) { - found = true; - } - } - assertTrue("No A records in answer", found); + assertEquals(1, recs.length); + assertEquals(recs[0].getType(), type); return recs; }