apache/hadoop · error · IllegalArgumentException

Name cannot be NULL or emtpy

Error message

Name cannot be NULL or emtpy

What it means

MultipleOutputs validates every named-output token with checkTokenName(), which first rejects null or zero-length names with this IllegalArgumentException (the message contains the original typo 'emtpy'). The check runs from checkNamedOutputName — used by addNamedOutput/addMultiNamedOutput — and also for the multiName argument of getCollector(name, multiName, reporter) when the output is multi. It means the name string you passed is null or empty.

Source

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

    List<String> definedChannels = getNamedOutputsList(conf);
    if (alreadyDefined && definedChannels.contains(namedOutput)) {
      throw new IllegalArgumentException("Named output '" + namedOutput +
        "' already alreadyDefined");
    } else if (!alreadyDefined && !definedChannels.contains(namedOutput)) {
      throw new IllegalArgumentException("Named output '" + namedOutput +
        "' not defined");
    }
  }

  /**
   * 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, purely alphanumeric name (see also the character check in the same method)
  2. When multiName derives from data, substitute a default token for blank values before calling getCollector (e.g. value.isEmpty() ? "NA" : value)
  3. Validate/normalize output names in one helper used by both driver and task code

Example fix

// before: data-driven multiName can be empty -> IllegalArgumentException
mos.getCollector("seq", category, reporter);

// after: normalize blank values before use
String safeName = (category == null || category.isEmpty()) ? "NA" : category;
mos.getCollector("seq", safeName, reporter);
Defensive patterns

Strategy: validation

Validate before calling

// normalize before registering or collecting
static String safeToken(String s) {
  return (s == null || s.trim().isEmpty()) ? "NA" : s.trim();
}
mos.getCollector("seq", safeToken(multiName), reporter);

Type guard

static boolean isValidToken(String name) {
  return name != null && !name.isEmpty();
}

Prevention

When it happens

Trigger: addNamedOutput(conf, null, ...) or addNamedOutput(conf, "", ...) during job setup; mos.getCollector("seq", "", reporter) where the empty string comes from a computed multiName (e.g. key.toString() returning empty, or a split-derived field that was blank).

Common situations: multiName values computed from data (dates, categories) that can be empty for some records; optional output names passed through configuration that default to unset; refactoring that leaves a placeholder empty string.

Related errors


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