{"record":{"id":"f375668c34c669b2","repo":"apache/hadoop","slug":"unexpected-empty-line","errorCode":null,"errorMessage":"Unexpected empty line","messagePattern":"Unexpected empty line","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DF.java","lineNumber":180,"sourceCode":"  \n  @VisibleForTesting\n  protected void parseOutput() throws IOException {\n    if (output.size() < 2) {\n      StringBuilder sb = new StringBuilder(\"Fewer lines of output than expected\");\n      if (output.size() > 0) {\n        sb.append(\": \" + output.get(0));\n      }\n      throw new IOException(sb.toString());\n    }\n    \n    String line = output.get(1);\n    StringTokenizer tokens =\n      new StringTokenizer(line, \" \\t\\n\\r\\f%\");\n    \n    try {\n      this.filesystem = tokens.nextToken();\n    } catch (NoSuchElementException e) {\n      throw new IOException(\"Unexpected empty line\");\n    }\n    if (!tokens.hasMoreTokens()) {            // for long filesystem name\n      if (output.size() > 2) {\n        line = output.get(2);\n      } else {\n        throw new IOException(\"Expecting additional output after line: \"\n            + line);\n      }\n      tokens = new StringTokenizer(line, \" \\t\\n\\r\\f%\");\n    }\n\n    try {\n      Long.parseLong(tokens.nextToken()); // capacity\n      Long.parseLong(tokens.nextToken()); // used\n      Long.parseLong(tokens.nextToken()); // available\n      Integer.parseInt(tokens.nextToken()); // pct used\n      this.mount = tokens.nextToken();\n    } catch (NoSuchElementException e) {","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DF.java#L162-L198","documentation":"While parsing the second line of 'df' output, DF found no tokens at all (StringTokenizer.nextToken() threw NoSuchElementException, converted to IOException 'Unexpected empty line'). The data row DF picked was blank, so fields like filesystem/capacity/mount could not be extracted.","triggerScenarios":"DF.parseOutput() when output line index 1 is empty or whitespace-only: df emitting a blank line (some locales/plugins), interleaved stderr captured into stdout, or odd filesystems making df print a placeholder empty row.","commonSituations":"Non-POSIX locales or custom df wrappers in the image; FUSE/network mounts on old OSes whose df output has irregular blank lines; site-specific /usr/bin/df shim scripts.","solutions":["Run sudo -u <daemon> df -k <dir> and inspect the exact bytes (pipe through cat -A) to see the blank line.","Set a standard locale for the daemon (LC_ALL=C in the systemd unit / container env) so df output formatting is stable.","Replace any df shim/wrapper on the host with the stock coreutils binary; upgrade Hadoop for hardened DF parsing."],"exampleFix":"# before\n# DF.parseOutput(): IOException: Unexpected empty line\n\n# after: pin locale for the daemon process\n# systemd unit:\n[Service]\nEnvironment=LC_ALL=C\n# verify: sudo -u hdfs df -k /grid/1/dn | cat -A  (no blank data row)","handlingStrategy":"try-catch","validationCode":"// detect a blank df data row before DF parses it\n// (run 'df -k <dir>' via ProcessBuilder and assert line 1 is non-blank)","typeGuard":null,"tryCatchPattern":"try {\n  df.getMount();\n} catch (IOException e) { // 'Unexpected empty line'\n  // fall back to java.io.File.getCanonicalPath/parent logic for mount detection\n}","preventionTips":["Pin LC_ALL=C for daemons so df output has a stable layout.","Avoid custom df wrappers/shims on hosts running Hadoop daemons.","Add a df-output sanity check to node validation scripts."],"tags":["hadoop","disk","df","parsing","locale","system-command"],"backgroundTag":"df-command-output-parse-failure","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}