{"record":{"id":"de57d94234ea4230","repo":"apache/hadoop","slug":"network-location-is-null","errorCode":null,"errorMessage":"Network Location is null ","messagePattern":"Network Location is null ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NodeBase.java","lineNumber":159,"sourceCode":"    return getPath(this).hashCode();\n  }\n\n  /** @return this node's path as its string representation */\n  @Override\n  public String toString() {\n    return getPath(this);\n  }\n\n  /** Normalize a path by stripping off any trailing {@link #PATH_SEPARATOR}\n   * @param path path to normalize.\n   * @return the normalised path\n   * If <i>path</i>is null or empty {@link #ROOT} is returned\n   * @throws IllegalArgumentException if the first character of a non empty path\n   * is not {@link #PATH_SEPARATOR}\n   */\n  public static String normalize(String path) {\n    if (path == null) {\n      throw new IllegalArgumentException(\n          \"Network Location is null \");\n    }\n\n    if (path.length() == 0) {\n      return ROOT;\n    }\n\n    if (path.charAt(0) != PATH_SEPARATOR) {\n      throw new IllegalArgumentException(\n                                         \"Network Location path does not start with \"\n                                         +PATH_SEPARATOR_STR+ \": \"+path);\n    }\n\n    // Remove duplicated slashes.\n    path = SLASHES.matcher(path).replaceAll(\"/\");\n    \n    int len = path.length();\n    if (path.charAt(len-1) == PATH_SEPARATOR) {","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NodeBase.java#L141-L177","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Default null locations to '/default-rack' (or NodeBase.ROOT) before constructing nodes","Fix the mapping script/implementation to never return null","Null-check location strings at ingestion and substitute the default rack"],"exampleFix":"// before\nNode n = new NodeBase(host, resolveLocation(host)); // may be null\n\n// after\nString loc = resolveLocation(host);\nif (loc == null) loc = \"/default-rack\";\nNode n = new NodeBase(host, loc);","handlingStrategy":"validation","validationCode":"String loc = (location == null) ? \"/default-rack\" : location;\nloc = NodeBase.normalize(loc);","typeGuard":"static boolean hasNonNullLocation(String loc) {\n  return loc != null;\n}","tryCatchPattern":null,"preventionTips":["Make mapping implementations return '/default-rack' instead of null for unknown hosts","Centralize the null-substitution at ingestion so normalize() never sees null"],"tags":["hadoop-common","network-topology","null-pointer","configuration"],"backgroundTag":"missing-network-location","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}