{"record":{"id":"00db5d6cc3f99c73","repo":"apache/hadoop","slug":"path-is-null","errorCode":null,"errorMessage":"Path is null","messagePattern":"Path is null","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/nativeio/NativeIO.java","lineNumber":613,"sourceCode":"          }\n        }\n      }\n      return stat;\n    }\n\n    /**\n     * Return the file stat for a file path.\n     *\n     * @param path  file path\n     * @return  the file stat\n     * @throws IOException  thrown if there is an IO error while obtaining the\n     * file stat\n     */\n    public static Stat getStat(String path) throws IOException {\n      if (path == null) {\n        String errMessage = \"Path is null\";\n        LOG.warn(errMessage);\n        throw new IOException(errMessage);\n      }\n      Stat stat = null;\n      try {\n        if (!Shell.WINDOWS) {\n          stat = stat(path);\n          stat.owner = getName(IdCache.USER, stat.ownerId);\n          stat.group = getName(IdCache.GROUP, stat.groupId);\n        } else {\n          stat = stat(path);\n        }\n      } catch (NativeIOException nioe) {\n        LOG.warn(\"NativeIO.getStat error ({}): {} -- file path: {}\",\n            nioe.getErrorCode(), nioe.getMessage(), path);\n        throw new PathIOException(path, nioe);\n      }\n      return stat;\n    }\n","sourceCodeStart":595,"sourceCodeEnd":631,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/nativeio/NativeIO.java#L595-L631","documentation":"NativeIO.getStat(String path) refuses a null argument up front: it logs 'Path is null' and throws IOException. It is a precondition guard so the JNI layer never receives a null pointer, which would produce a crash or an opaque native error. The real bug is upstream — wherever the null path originated.","triggerScenarios":"Calling NativeIO.getStat(null), typically with a null produced earlier: File.getParent() at a root path returning null, a missing config property, Map.get() returning null, or Optional-style access on an absent value.","commonSituations":"Path derivation like file.getParent() on root-relative files; typo'd configuration keys yielding null; data structures populated conditionally so the key is sometimes absent.","solutions":["Null-check the path at its source and fail with context naming the config key or field that was null.","Use Objects.requireNonNull(path, \"path\") to fail fast at the caller with a better message than the IO guard.","Trace the producer: log the variable right before passing it so the null's origin is visible."],"exampleFix":"// before\nStat st = NativeIO.getStat(maybeNullPath);\n\n// after\nStat st = NativeIO.getStat(\n    Objects.requireNonNull(path, \"path must be set (source: config 'data.dir')\"));","handlingStrategy":"validation","validationCode":"if (path == null) {\n  throw new IllegalArgumentException(\"path required (source: \" + sourceName + \")\");\n}\nStat st = NativeIO.getStat(path);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use Objects.requireNonNull with a descriptive label at API edges.","Never let Map.get()/Optional-style access flow directly into IO calls.","Check path producers (getParent, config lookups) for documented null returns."],"tags":["native-io","null-check","stat","precondition"],"backgroundTag":"null-argument","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}