apache/hadoop · error · IOException

(null) entry in command string: {}

Error message

(null) entry in command string: {}

What it means

Shell.Command.execute() — the entry point behind ShellCommandExecutor — iterates the command array and throws IOException '(null) entry in command string: ...' if any element is null, because ProcessBuilder/Runtime.exec cannot accept null arguments. It is a precondition failure on a dynamically built command line, not an OS error.

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Shell.java:1280

    /**
     * Returns the timeout value set for the executor's sub-commands.
     * @return The timeout value in milliseconds
     */
    @VisibleForTesting
    public long getTimeoutInterval() {
      return timeOutInterval;
    }

    /**
     * Execute the shell command.
     * @throws IOException if the command fails, or if the command is
     * not well constructed.
     */
    public void execute() throws IOException {
      for (String s : command) {
        if (s == null) {
          throw new IOException("(null) entry in command string: "
              + StringUtils.join(" ", command));
        }
      }
      this.run();
    }

    @Override
    public String[] getExecString() {
      return command;
    }

    @Override
    protected void parseExecResult(BufferedReader lines) throws IOException {
      output = new StringBuilder();
      char[] buf = new char[512];
      int nRead;
      while ( (nRead = lines.read(buf, 0, buf.length)) > 0 ) {
        output.append(buf, 0, nRead);

View on GitHub (pinned to 2add963021)

Solutions

  1. Read the exception message — it prints the full joined command so the null's position is visible
  2. Trace which producer supplied the null (usually conf.get("key") for an unset key) and set the key or add a default: conf.get("key", "defaultValue")
  3. Validate the array before execution: Arrays.stream(cmd).allMatch(Objects::nonNull)
  4. Build commands with a small helper that skips or defaults null optional arguments

Example fix

// before
String[] cmd = {"bash", scriptPath, conf.get("mapred.task.exec")}; // third slot may be null
new ShellCommandExecutor(cmd).execute();

// after
Objects.requireNonNull(scriptPath, "scriptPath");
String taskExec = conf.get("mapred.task.exec", "");
String[] cmd = {"bash", scriptPath, taskExec};
new ShellCommandExecutor(cmd).execute();
Defensive patterns

Strategy: validation

Validate before calling

String[] cmd = {"bash", scriptPath, conf.get("some.key", "")};
if (Arrays.stream(cmd).anyMatch(Objects::isNull)) {
  throw new IllegalArgumentException("Null entry in command: " + Arrays.toString(cmd));
}
new ShellCommandExecutor(cmd).execute();

Try / catch

try { executor.execute(); } catch (IOException e) { if (e.getMessage().startsWith("(null) entry")) { /* fix argument source, rebuild cmd */ } else throw e; }

Prevention

When it happens

Trigger: new ShellCommandExecutor(new String[]{...}).execute() where one slot is null: an argument sourced from Configuration.get() that returned null, an env lookup that failed, or an optional flag appended without a null check.

Common situations: Config keys missing from site XML so get() yields null and is spliced into the exec array; refactors making a parameter @Nullable; conditional argument lists built with List.add(maybeNull).

Related errors


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