{"record":{"id":"d51af9671267a8c4","repo":"apache/hadoop","slug":"address-is-null","errorCode":null,"errorMessage":"address is null.","messagePattern":"address is null\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/MachineList.java","lineNumber":172,"sourceCode":"\n    try {\n      return includes(addressFactory.getByName(ipAddress));\n    } catch (UnknownHostException e) {\n      return false;\n    }\n  }\n\n  /**\n   * Accepts an inet address and return true if address is in the list.\n   * @param address address.\n   * @return true if address is part of the list\n   */\n  public boolean includes(InetAddress address) {\n    if (all) {\n      return true;\n    }\n    if (address == null) {\n      throw new IllegalArgumentException(\"address is null.\");\n    }\n    if (inetAddresses != null && inetAddresses.contains(address)) {\n      return true;\n    }\n    // iterate through the ip ranges for inclusion\n    if (cidrAddresses != null) {\n      String ipAddress = address.getHostAddress();\n      for(SubnetUtils.SubnetInfo cidrAddress : cidrAddresses) {\n        if(cidrAddress.isInRange(ipAddress)) {\n          return true;\n        }\n      }\n    }\n    return false;\n  }\n  /**\n   * returns the contents of the MachineList as a Collection&lt;String&gt; .\n   * This can be used for testing .","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/MachineList.java#L154-L190","documentation":"The InetAddress overload includes(InetAddress) applies the same contract: for a non-'*' list, a null address throws IllegalArgumentException(\"address is null.\") before consulting inetAddresses or the cidrAddresses ranges. The String overload tolerates failed resolution (it catches UnknownHostException and returns false), so pre-resolving callers bypass that and must null-check themselves.","triggerScenarios":"includes((InetAddress) null) with a concrete configured list; passing a pre-resolved address field that was never assigned along an error path; caching resolution results and losing the value on a miss.","commonSituations":"Code pre-resolving addresses to avoid repeated DNS lookups per request; test harnesses constructing MachineList with explicit InetAddress values; refactors moving resolution into a helper that can return null.","solutions":["Guard address != null before calling, treating null as denied","Make resolution helpers return Optional<InetAddress> or a loopback fallback instead of null","Prefer the String overload inside try/catch UnknownHostException when resolution may legitimately fail"],"exampleFix":"// before\nboolean ok = machineList.includes(resolved);\n\n// after\nboolean ok = resolved != null && machineList.includes(resolved);","handlingStrategy":"validation","validationCode":"InetAddress addr = resolveQuietly(host); // returns null on failure\nboolean allowed = addr != null && machineList.includes(addr);","typeGuard":null,"tryCatchPattern":"try { allowed = machineList.includes(addr); } catch (IllegalArgumentException e) { allowed = false; }","preventionTips":["Make resolution helpers return Optional or a documented fallback instead of null","Treat unresolved hosts as denied in allow-list logic","Prefer the String overload with its built-in UnknownHostException handling where possible"],"tags":["hadoop","java","acl","null-check","host-filter"],"backgroundTag":"null-argument-validation","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}