Uploaded image for project: 'Metron (Retired)'
  1. Metron (Retired)
  2. METRON-1299

MetronError tests fail if hostname isn't set

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Done
    • Major
    • Resolution: Done
    • 0.4.1
    • 0.5.0
    • None
    • openSUSE Tumbleweed 20171102, OpenJDK 1.8.0_144

    Description

      If I run "mvn package" in the root Metron directory then compilation fails because of a null reference in ./metron-platform/metron-common/src/test/java/org/apache/metron/common/error/MetronErrorTest.java. This happens in getJSONObjectShouldReturnBasicInformation on line 56 because errorJSON.get(Constants.ErrorFields.HOSTNAME.getName()) is assumed to return a string and the length() method is called on it. Because the assert doesn't use a message then no obvious reason why it fails is logged.

      The underlying problem is that metron-platform/metron-common/src/main/java/org/apache/metron/common/error/MetronError.java falls through to a catch block in addHostname() when netAddress.getLocalHost().getHostName() exceptions with Name or service not known for the host name.

      Setting a hostname that resolves is a build requirement that is out of Metron's control, but if the code specifically handles the fact that it won't always be retrieved then it seems problematic to have tests that assume it works and not make it clear what the failure is when it occurs.

      Attachments

        Issue Links

          Activity

            People

              otto Otto Fowler
              SJBertram Stuart Bertram
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: