openzipkin/zipkin · error · NullPointerException

loggingClass == null

Error message

loggingClass == null

What it means

Collector.newBuilder(Class<?>) requires a non-null logging class because it derives the SLF4J logger category from it (LoggerFactory.getLogger(loggingClass.getName())). The logger scopes accept() warnings (e.g. storage failures, dropped spans) to the calling collector's category, so null is a programming error.

Source

Thrown at zipkin-collector/core/src/main/java/zipkin2/collector/Collector.java:43

 * This component takes action on spans received from a transport. This includes deserializing,
 * sampling and scheduling for storage.
 *
 * <p>Callbacks passed do not propagate to the storage layer. They only return success or failures
 * before storage is attempted. This ensures that calling threads are disconnected from storage
 * threads.
 */
public class Collector { // not final for mock
  static final Callback<Void> NOOP_CALLBACK = new Callback<Void>() {
    @Override public void onSuccess(Void value) {
    }

    @Override public void onError(Throwable t) {
    }
  };

  /** Needed to scope this to the correct logging category */
  public static Builder newBuilder(Class<?> loggingClass) {
    if (loggingClass == null) throw new NullPointerException("loggingClass == null");
    return new Builder(LoggerFactory.getLogger(loggingClass.getName()));
  }

  public static final class Builder {
    final Logger logger;
    StorageComponent storage;
    CollectorSampler sampler;
    CollectorMetrics metrics;

    Builder(Logger logger) {
      this.logger = logger;
    }

    /** Sets {@link {@link CollectorComponent.Builder#storage(StorageComponent)}} */
    public Builder storage(StorageComponent storage) {
      if (storage == null) throw new NullPointerException("storage == null");
      this.storage = storage;
      return this;

View on GitHub (pinned to 878ce2a1fa)

Solutions

  1. Pass the concrete collector class, e.g. Collector.newBuilder(LazyActiveMQCollector.class).
  2. If the class reference is dynamic, null-check it before calling and fail with a descriptive message.

Example fix

// before
Class<?> lc = config.getLoggingClass(); // null
Collector.newBuilder(lc); // NPE

// after
Collector.newBuilder(ActiveMQCollector.class);
Defensive patterns

Strategy: validation

Validate before calling

java
Objects.requireNonNull(loggingClass, "loggingClass");
return Collector.newBuilder(loggingClass);

Prevention

When it happens

Trigger: Calling Collector.newBuilder(null), usually when a class variable or config-driven class reference is null at wiring time.

Common situations: Copy-pasted bootstrap code where the class literal was dropped; reflective setup where the Class object failed to load and null propagated.

Related errors


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