apache/hadoop · error · IllegalArgumentException

Name cannot be NULL or emtpy

Error message

Name cannot be NULL or emtpy

What it means

Thrown as IllegalArgumentException from MultipleOutputs.checkTokenName (MultipleOutputs.java:223). Every named-output channel name must be a non-empty string of letters and digits only; passing null or the empty string fails this first validation. (The message contains the upstream typo 'emtpy'.) It fires from addNamedOutput() at job setup and from write(namedOutput, ...) in the task.

Source

Thrown at hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/lib/output/MultipleOutputs.java:223

  /**
   * Cache for the taskContexts
   */
  private Map<String, TaskAttemptContext> taskContexts = new HashMap<String, TaskAttemptContext>();
  /**
   * Cached TaskAttemptContext which uses the job's configured settings
   */
  private TaskAttemptContext jobOutputFormatContext;

  /**
   * Checks if a named output name is valid token.
   *
   * @param namedOutput named output Name
   * @throws IllegalArgumentException if the output name is not valid.
   */
  private static void checkTokenName(String namedOutput) {
    if (namedOutput == null || namedOutput.length() == 0) {
      throw new IllegalArgumentException(
        "Name cannot be NULL or emtpy");
    }
    for (char ch : namedOutput.toCharArray()) {
      if ((ch >= 'A') && (ch <= 'Z')) {
        continue;
      }
      if ((ch >= 'a') && (ch <= 'z')) {
        continue;
      }
      if ((ch >= '0') && (ch <= '9')) {
        continue;
      }
      throw new IllegalArgumentException(
        "Name cannot be have a '" + ch + "' char");
    }
  }

  /**

View on GitHub (pinned to 2add963021)

Solutions

  1. Pass a non-empty, alphanumeric channel name (e.g. 'metrics', 'errors01')
  2. Validate dynamically generated names before use: reject or default when null/empty
  3. Centralize channel naming in one constant/enum so call sites cannot drift

Example fix

// before
String channel = record.split("\\|")[0]; // may be "" on malformed input
mos.write(channel, key, value);

// after
String channel = record.split("\\|")[0];
if (channel == null || channel.isEmpty()) {
  channel = "default";
}
mos.write(channel, key, value);
Defensive patterns

Strategy: validation

Validate before calling

// guard channel names at their source
static String requireChannelName(String raw) {
  if (raw == null || raw.isEmpty()) throw new IllegalArgumentException("channel name required");
  return raw;
}

Type guard

static boolean isValidMultipleOutputsToken(String name) {
  if (name == null || name.isEmpty()) return false;
  for (char ch : name.toCharArray()) {
    if (!((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9'))) return false;
  }
  return !name.equals("part");
}

Prevention

When it happens

Trigger: MultipleOutputs.addNamedOutput(job, null, ...) or addNamedOutput(job, "", ...); or mos.write("", key, value) / mos.write(null, key, value) in a Mapper/Reducer. Typical origin: the name comes from user input, a config key, or string splitting that yielded an empty token.

Common situations: Generating channel names dynamically from data (e.g. split('|')[0] on an unexpected input line) and hitting an empty segment; passing an unvalidated parameter into a job-driver utility that calls addNamedOutput.

Related errors


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