apache/hadoop · error · HadoopIllegalArgumentException

Redundant -protocol command

Error message

Redundant -protocol command

What it means

parseProtocolArgs throws HadoopIllegalArgumentException('Redundant -protocol command') when -protocol is supplied more than once, because the protocol field is already non-null. The tool accepts -protocol at most once per invocation (defaulting to http when omitted).

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/log/LogLevel.java:213

            "Redundant -setlevel command");
      }
      // check number of arguments is sufficient
      if (index+3 >= args.length) {
        throw new HadoopIllegalArgumentException(
            "-setlevel needs three parameters");
      }
      operation = Operations.SETLEVEL;
      hostName = args[index+1];
      className = args[index+2];
      level = args[index+3];
      return index+4;
    }

    private int parseProtocolArgs(String[] args, int index) throws
        HadoopIllegalArgumentException {
      // make sure only -protocol is specified
      if (protocol != null) {
        throw new HadoopIllegalArgumentException(
            "Redundant -protocol command");
      }
      // check number of arguments is sufficient
      if (index+1 >= args.length) {
        throw new HadoopIllegalArgumentException(
            "-protocol needs one parameter");
      }
      // check protocol is valid
      protocol = args[index+1];
      if (!isValidProtocol(protocol)) {
        throw new HadoopIllegalArgumentException(
            "Invalid protocol: " + protocol);
      }
      return index+2;
    }

    /**
     * Send HTTP/HTTPS request to get log level.

View on GitHub (pinned to 2add963021)

Solutions

  1. Keep a single -protocol (http|https) token — or drop it entirely to use the http default.
  2. Fix wrapper scripts so they do not stack a -protocol onto an already-complete command.
  3. If both variants are needed, run two separate invocations.

Example fix

# before
hadoop loglevel -getlevel nn:9871 cls -protocol https -protocol http

# after
hadoop loglevel -getlevel nn:9871 cls -protocol https
Defensive patterns

Strategy: validation

Validate before calling

long n = Arrays.stream(args).filter(a -> a.equals("-protocol")).count();
if (n > 1) {
  throw new HadoopIllegalArgumentException("-protocol may appear only once (default http)");
}

Prevention

When it happens

Trigger: 'hadoop loglevel -getlevel h c -protocol http -protocol https'; commands assembled by combining fragments that each carry their own -protocol; copy-paste duplication.

Common situations: Merging two example commands into one line; wrappers that add -protocol https on top of a user-supplied command that already has it.

Related errors


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