apache/hadoop · error · IllegalArgumentException

Network Location is null

Error message

Network Location is null 

What it means

NodeBase.normalize(path) rejects null with IllegalArgumentException; only the empty string maps to ROOT. Because NodeBase construction and NetworkTopology location handling call normalize(), a null network location surfaces here rather than as an NPE later.

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NodeBase.java:159

    return getPath(this).hashCode();
  }

  /** @return this node's path as its string representation */
  @Override
  public String toString() {
    return getPath(this);
  }

  /** Normalize a path by stripping off any trailing {@link #PATH_SEPARATOR}
   * @param path path to normalize.
   * @return the normalised path
   * If <i>path</i>is null or empty {@link #ROOT} is returned
   * @throws IllegalArgumentException if the first character of a non empty path
   * is not {@link #PATH_SEPARATOR}
   */
  public static String normalize(String path) {
    if (path == null) {
      throw new IllegalArgumentException(
          "Network Location is null ");
    }

    if (path.length() == 0) {
      return ROOT;
    }

    if (path.charAt(0) != PATH_SEPARATOR) {
      throw new IllegalArgumentException(
                                         "Network Location path does not start with "
                                         +PATH_SEPARATOR_STR+ ": "+path);
    }

    // Remove duplicated slashes.
    path = SLASHES.matcher(path).replaceAll("/");
    
    int len = path.length();
    if (path.charAt(len-1) == PATH_SEPARATOR) {

View on GitHub (pinned to 2add963021)

Solutions

  1. Default null locations to '/default-rack' (or NodeBase.ROOT) before constructing nodes
  2. Fix the mapping script/implementation to never return null
  3. Null-check location strings at ingestion and substitute the default rack

Example fix

// before
Node n = new NodeBase(host, resolveLocation(host)); // may be null

// after
String loc = resolveLocation(host);
if (loc == null) loc = "/default-rack";
Node n = new NodeBase(host, loc);
Defensive patterns

Strategy: validation

Validate before calling

String loc = (location == null) ? "/default-rack" : location;
loc = NodeBase.normalize(loc);

Type guard

static boolean hasNonNullLocation(String loc) {
  return loc != null;
}

Prevention

When it happens

Trigger: new NodeBase(name, null), or any code path where the location string is null — e.g. a topology mapping implementation returning null for an unresolvable host.

Common situations: Script-based or table-based mapping returning null instead of '/default-rack' when DNS lookup fails or the host is absent from the table; custom DatanodeInfo/Node constructions that never set a location.

Related errors


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