Hadoop Common
  1. Hadoop Common
  2. HADOOP-10011

NPE if the system can't determine its own name and you go DNS.getDefaultHost(null)

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Implemented
    • Affects Version/s: 3.0.0, 2.1.1-beta
    • Fix Version/s: 2.2.0
    • Component/s: None
    • Labels:
      None
    • Release Note:
      Looking at the source this has been fixed: checks for null trigger {{UnknownHostException}}

      Description

      In a test case that I am newly writing, on my infamous "home machine with broken DNS", I cant call getByName(null) without seeing a stack trace:
      Testcase: testNullInterface took 0.014 sec
      Caused an ERROR
      null
      java.lang.NullPointerException
      at java.net.NetworkInterface.getByName(NetworkInterface.java:226)
      at org.apache.hadoop.net.DNS.getIPs(DNS.java:94)
      at org.apache.hadoop.net.DNS.getHosts(DNS.java:141)
      at org.apache.hadoop.net.DNS.getDefaultHost(DNS.java:218)
      at org.apache.hadoop.net.DNS.getDefaultHost(DNS.java:235)
      at org.apache.hadoop.net.TestDNS.testNullInterface(TestDNS.java:62)

        Issue Links

          Activity

          Hide
          Steve Loughran added a comment -

          doing a review of the code, the issue is still there -DNS.getHosts assumes that netAddress.getByName() never returns null, which is the official failure state of the method according to the JDK:

                  hosts.add(reverseDns(InetAddress.getByName(ips[ctr]),
                                       nameserver));
          
          Show
          Steve Loughran added a comment - doing a review of the code, the issue is still there -DNS.getHosts assumes that netAddress.getByName() never returns null, which is the official failure state of the method according to the JDK: hosts.add(reverseDns(InetAddress.getByName(ips[ctr]), nameserver));
          Hide
          Eli Collins added a comment -

          +1 That sounds great.

          Show
          Eli Collins added a comment - +1 That sounds great.
          Hide
          steve_l added a comment -

          May be better to have this fail with a meaningful error "we don't know our own hostname, please fix your underlying system configuration"

          Show
          steve_l added a comment - May be better to have this fail with a meaningful error "we don't know our own hostname, please fix your underlying system configuration"
          Hide
          steve_l added a comment -

          This is probably the correct behaviour; needs documenting though

          Show
          steve_l added a comment - This is probably the correct behaviour; needs documenting though

            People

            • Assignee:
              Steve Loughran
              Reporter:
              Steve Loughran
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development