{"record":{"id":"3d20ed4c3ebde291","repo":"apache/hadoop","slug":"no-data-in-path","errorCode":null,"errorMessage":"No data in ${path}","messagePattern":"No data in (.+?)","errorType":"exception","errorClass":"EOFException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/JsonSerialization.java","lineNumber":268,"sourceCode":"  }\n\n  /**\n   * Load from a Hadoop filesystem.\n   * If a file status is supplied, it's passed in to the openFile()\n   * call so that FS implementations can optimize their opening.\n   * @param fs filesystem\n   * @param path path\n   * @param status status of the file to open.\n   * @return a loaded object\n   * @throws PathIOException JSON parse problem\n   * @throws EOFException file status references an empty file\n   * @throws IOException IO problems\n   */\n  public T load(FileSystem fs, Path path, @Nullable FileStatus status)\n      throws IOException {\n\n    if (status != null && status.getLen() == 0) {\n      throw new EOFException(\"No data in \" + path);\n    }\n    FutureDataInputStreamBuilder builder = fs.openFile(path)\n        .opt(FS_OPTION_OPENFILE_READ_POLICY,\n            FS_OPTION_OPENFILE_READ_POLICY_WHOLE_FILE);\n    if (status != null) {\n      builder.withFileStatus(status);\n    }\n    try (FSDataInputStream dataInputStream =\n             awaitFuture(builder.build())) {\n      return fromJsonStream(dataInputStream);\n    } catch (JsonProcessingException e) {\n      throw new PathIOException(path.toString(),\n          \"Failed to read JSON file \" + e, e);\n    }\n  }\n\n  /**\n   * Save to a Hadoop filesystem.","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/JsonSerialization.java#L250-L286","documentation":"The cluster overload load(FileSystem, Path, FileStatus) trusts the caller-supplied FileStatus to skip a metadata call; when it reports getLen() == 0 the method throws EOFException(\"No data in <path>\") without opening the file. Passing a null status is legal and defers to the read path instead.","triggerScenarios":"Calling load(fs, path, status) where status reports zero length: a newly created HDFS/S3 object with no data written yet, an aborted write leaving an empty file, or a cached/stale status of a truncated file.","commonSituations":"Recovery code scanning state or journal objects where one is empty after an unclean failure; racing a writer between create and first flush; a listing-derived FileStatus reused after the file was rewritten empty.","solutions":["Check the object itself (hdfs dfs -ls or an object-store listing): a 0-byte object means the writer failed - regenerate or delete it.","Pass null instead of a possibly stale status; the reader then fails with the more precise Jackson error.","In recovery loops, treat zero-length state files as 'no state' and skip or quarantine them."],"exampleFix":"// before\nMyType t = serializer.load(fs, path, cachedStatus);\n\n// after\nif (cachedStatus == null) {\n  cachedStatus = fs.getFileStatus(path);\n}\nif (cachedStatus.getLen() == 0) {\n  return defaults(); // empty state file: writer failed, treat as absent\n}\nreturn serializer.load(fs, path, cachedStatus);","handlingStrategy":"validation","validationCode":"FileStatus st = (status != null) ? status : fs.getFileStatus(path);\nif (st.getLen() == 0) {\n  return defaults(); // or quarantine and continue recovery\n}\nreturn serializer.load(fs, path, st);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not cache FileStatus across writes; re-fetch before trusting getLen().","In recovery scans over many state files, handle zero-length entries explicitly instead of failing the whole scan."],"tags":["json","hdfs","hadoop-common","empty-file"],"backgroundTag":"empty-file","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}