openzipkin/zipkin · error · NullPointerException

transportType == null

Error message

transportType == null

What it means

InMemoryCollectorMetrics.forTransport scopes an existing metrics registry to a named transport (e.g. 'http', 'kafka', 'activemq'); the transport name keys the per-transport counters, so null would corrupt the metric map and is rejected. This is the metrics implementation backing zipkin-server's metrics endpoint.

Source

Thrown at zipkin-collector/core/src/main/java/zipkin2/collector/InMemoryCollectorMetrics.java:34

  private final String spans;
  private final String spansDropped;

  public InMemoryCollectorMetrics() {
    this(new ConcurrentHashMap<>(), null);
  }

  InMemoryCollectorMetrics(ConcurrentHashMap<String, AtomicInteger> metrics, String transport) {
    this.metrics = metrics;
    this.messages = scope("messages", transport);
    this.messagesDropped = scope("messagesDropped", transport);
    this.bytes = scope("bytes", transport);
    this.spans = scope("spans", transport);
    this.spansDropped = scope("spansDropped", transport);
  }

  @Override
  public InMemoryCollectorMetrics forTransport(String transportType) {
    if (transportType == null) throw new NullPointerException("transportType == null");
    return new InMemoryCollectorMetrics(metrics, transportType);
  }

  @Override
  public void incrementMessages() {
    increment(messages, 1);
  }

  public int messages() {
    return get(messages);
  }

  @Override
  public void incrementMessagesDropped() {
    increment(messagesDropped, 1);
  }

  public int messagesDropped() {

View on GitHub (pinned to 878ce2a1fa)

Solutions

  1. Pass a fixed, non-null transport label string ("http", "kafka", "activemq", ...).
  2. Default the label if it comes from config: transport != null ? transport : "unknown".
  3. Reuse the built-in collectors (ActiveMQCollector/KafkaCollector) which scope metrics for you.

Example fix

// before
String t = props.getProperty("transport"); // null
metrics.forTransport(t); // NPE

// after
metrics.forTransport(t != null ? t : "unknown");
Defensive patterns

Strategy: validation

Validate before calling

java
String label = (transportType != null) ? transportType : "unknown";
return metrics.forTransport(label);

Prevention

When it happens

Trigger: Calling inMemoryCollectorMetrics.forTransport(null) — e.g. a collector wrapper deriving the transport label from config that resolved to null, then delegating to forTransport like ActiveMQCollector/KafkaCollector builders do internally with a hard-coded name.

Common situations: Custom CollectorComponent implementations copying the built-in builders but deriving the transport string dynamically; config-driven transport label missing.

Related errors


AI-assisted analysis of openzipkin/zipkin@878ce2a1fa (2026-08-14). Data as JSON: /api/errors/18733aa07a8b0cf4. Report an issue: GitHub.