Github user cestella commented on a diff in the pull request:

    https://github.com/apache/metron/pull/924#discussion_r165982935
  
    --- Diff: 
metron-platform/metron-common/src/test/java/org/apache/metron/common/error/MetronErrorTest.java
 ---
    @@ -53,7 +52,14 @@ public void getJSONObjectShouldReturnBasicInformation() {
         assertEquals(Constants.ErrorType.PARSER_ERROR.getType(), 
errorJSON.get(Constants.ErrorFields.ERROR_TYPE.getName()));
         assertEquals("error", errorJSON.get(Constants.SENSOR_TYPE));
         assertEquals("sensorType", 
errorJSON.get(Constants.ErrorFields.FAILED_SENSOR_TYPE.getName()));
    -    assertTrue(((String) 
errorJSON.get(Constants.ErrorFields.HOSTNAME.getName())).length() > 0);
    +
    +    try {
    +      String hostName = InetAddress.getLocalHost().getHostName();
    --- End diff --
    
    So, in the instance where this happens, is hostName is null or is it that 
there's an Exception thrown?  If it's null, can't we do a:
    ```
    if(hostName == null) {
      LOG.warn("Unable to resolve local hostname, skipping validation."
    }
    else {
      assertTrue(((String) 
errorJSON.get(Constants.ErrorFields.HOSTNAME.getName())).length() > 0);
      assertEquals(hostName, (String) 
errorJSON.get(Constants.ErrorFields.HOSTNAME.getName()));
    }
    ```
    
    I ask because I worry about extraneous *other* exceptions cropping up and 
us ignoring them.  It's a very small nit, let me know what you think. :)


---

Reply via email to