apache/hadoop · error · NullPointerException

Identifier cannot be null

Error message

Identifier cannot be null

What it means

RefreshRegistry.register maps a refresh identifier (conventionally a reverse-DNS string like 'org.apache.hadoop.example') to a RefreshHandler so dfsadmin/rmadmin-style refresh requests can reach it. A null identifier throws NullPointerException immediately as a fail-fast guard, since null can never be dispatched to by name.

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/RefreshRegistry.java:67

  }

  private final Multimap<String, RefreshHandler> handlerTable;

  public RefreshRegistry() {
    handlerTable = HashMultimap.create();
  }

  /**
   * Registers an object as a handler for a given identity.
   * Note: will prevent handler from being GC'd, object should unregister itself
   *  when done
   * @param identifier a unique identifier for this resource,
   *                   such as org.apache.hadoop.blacklist
   * @param handler the object to register
   */
  public synchronized void register(String identifier, RefreshHandler handler) {
    if (identifier == null) {
      throw new NullPointerException("Identifier cannot be null");
    }
    handlerTable.put(identifier, handler);
  }

  /**
   * Remove the registered object for a given identity.
   * @param identifier the resource to unregister
   * @param handler input handler.
   * @return the true if removed
   */
  public synchronized boolean unregister(String identifier, RefreshHandler handler) {
    return handlerTable.remove(identifier, handler);
  }

  public synchronized void unregisterAll(String identifier) {
    handlerTable.removeAll(identifier);
  }

View on GitHub (pinned to 2add963021)

Solutions

  1. Pass a unique, stable, non-null identifier (reverse-DNS convention) when registering.
  2. If the identifier comes from configuration, validate the key exists at startup and fail with a clear message instead of registering null.
  3. Wrap registration in a helper that does Objects.requireNonNull(identifier, ...) so the failure names the problem.

Example fix

// before
String id = conf.get("my.refresh.identifier"); // null if key missing
RefreshRegistry.defaultRegistry().register(id, handler);
// after
String id = Objects.requireNonNull(
    conf.get("my.refresh.identifier"),
    "my.refresh.identifier must be configured");
RefreshRegistry.defaultRegistry().register(id, handler);
Defensive patterns

Strategy: validation

Validate before calling

String id = Objects.requireNonNull(identifierSource(),
    "refresh identifier source returned null");
if (id.isEmpty()) {
  throw new IllegalArgumentException("refresh identifier must not be empty");
}
RefreshRegistry.defaultRegistry().register(id, handler);

Prevention

When it happens

Trigger: Calling RefreshRegistry.defaultRegistry().register(null, handler); identifiers built from configuration values or annotations where the lookup returned null.

Common situations: Custom refreshable plugins registering handlers during service init; identifier strings read from a config key that is absent; refactors that changed the identifier source to something nullable.

Related errors


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