apache/druid · error · UnsupportedOperationException

Emitter is null, cannot emit.

Error message

Emitter is null, cannot emit.

What it means

AlertBuilder wraps an alert event and a reference to an Emitter. If the builder was constructed without an Emitter (the null-emitter constructor), emit() throws UnsupportedOperationException instead of silently dropping the alert. It is a programmatic misuse guard: alerts must be wired to an emitter before they can be sent.

Solutions

  1. Construct the AlertBuilder with a real emitter: new AlertBuilder(emitter, description) or set the emitter before emit().
  2. Ensure the Druid emitter module is initialized before any component can emit alerts (check startup order / lifecycle wiring).
  3. If emitting alerts from a context without an emitter (e.g. tests), stub the emitter with a no-op Emitter implementation instead of passing null.
  4. Guard call sites: only call emit() when an emitter is configured, otherwise log the alert.

Example fix

// before
AlertBuilder alert = new AlertBuilder("Auth check failed").severity(Alert.Severity.NOTIFICATION);
alert.emit(); // UnsupportedOperationException: emitter is null
// after
AlertBuilder alert = new AlertBuilder(emitter, "Auth check failed").severity(Alert.Severity.NOTIFICATION);
if (emitter != null) {
  alert.emit();
} else {
  log.warn("No emitter configured; dropping alert");
}
Defensive patterns

Strategy: type-guard

Validate before calling

if (emitter == null) { log.warn("No emitter configured; skipping alert"); return; }

Type guard

boolean canEmit = (emitter != null);

Try / catch

try {
  alert.emit();
} catch (UnsupportedOperationException e) {
  log.warn("Alert dropped: no emitter configured");
}

Prevention

When it happens

Trigger: Calling new AlertBuilder(description).ok()/warn()/critical() via the constructor variant that takes no Emitter (or passing null), then calling .emit(). Seen in code paths like handleAuthorizationCheckError where the emitter dependency was not injected.

Common situations: Unit tests instantiating AlertBuilder without an emitter; framework/extension code where the Emitter is not yet initialized (e.g. alert emitted before Druid startup wiring completes) or a DI/config oversight left emitter null.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/6ea3404336b3d6f9. Report an issue: GitHub.

Appendix: source

Thrown at processing/src/main/java/org/apache/druid/java/util/emitter/service/AlertBuilder.java:107

    return this;
  }

  public AlertBuilder severity(AlertEvent.Severity severity)
  {
    this.severity = severity;
    return this;
  }

  @Override
  public AlertEvent build(ImmutableMap<String, String> serviceDimensions)
  {
    return new AlertEvent(DateTimes.nowUtc(), serviceDimensions, severity, description, dataMap);
  }

  public void emit()
  {
    if (emitter == null) {
      throw new UnsupportedOperationException("Emitter is null, cannot emit.");
    }

    emitter.emit(this);
  }
}

View on GitHub (pinned to 9b90983fd2)