apache/hadoop · error · IllegalArgumentException

address is null.

Error message

address is null.

What it means

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.

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/MachineList.java:172

    try {
      return includes(addressFactory.getByName(ipAddress));
    } catch (UnknownHostException e) {
      return false;
    }
  }

  /**
   * Accepts an inet address and return true if address is in the list.
   * @param address address.
   * @return true if address is part of the list
   */
  public boolean includes(InetAddress address) {
    if (all) {
      return true;
    }
    if (address == null) {
      throw new IllegalArgumentException("address is null.");
    }
    if (inetAddresses != null && inetAddresses.contains(address)) {
      return true;
    }
    // iterate through the ip ranges for inclusion
    if (cidrAddresses != null) {
      String ipAddress = address.getHostAddress();
      for(SubnetUtils.SubnetInfo cidrAddress : cidrAddresses) {
        if(cidrAddress.isInRange(ipAddress)) {
          return true;
        }
      }
    }
    return false;
  }
  /**
   * returns the contents of the MachineList as a Collection<String> .
   * This can be used for testing .

View on GitHub (pinned to 2add963021)

Solutions

  1. Guard address != null before calling, treating null as denied
  2. Make resolution helpers return Optional<InetAddress> or a loopback fallback instead of null
  3. Prefer the String overload inside try/catch UnknownHostException when resolution may legitimately fail

Example fix

// before
boolean ok = machineList.includes(resolved);

// after
boolean ok = resolved != null && machineList.includes(resolved);
Defensive patterns

Strategy: validation

Validate before calling

InetAddress addr = resolveQuietly(host); // returns null on failure
boolean allowed = addr != null && machineList.includes(addr);

Try / catch

try { allowed = machineList.includes(addr); } catch (IllegalArgumentException e) { allowed = false; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/d51af9671267a8c4. Report an issue: GitHub.