openzipkin/zipkin · error · NullPointerException

localDc == null

Error message

localDc == null

What it means

CassandraStorageBuilder.localDc(String) throws NullPointerException ('localDc == null') when explicitly setting the local datacenter name to null. The local DC names which Cassandra datacenter is 'local' for latency-aware load balancing; if you never need to pin it, simply do not call localDc (round-robin is used) — but an explicit null call is rejected.

Source

Thrown at zipkin-storage/cassandra/src/main/java/zipkin2/storage/cassandra/CassandraStorageBuilder.java:110

    return (B) this;
  }

  /**
   * Comma separated list of host addresses part of Cassandra cluster. You can also specify a custom
   * port with 'host:port'. Defaults to localhost on port 9042 *
   */
  public B contactPoints(String contactPoints) {
    if (contactPoints == null) throw new NullPointerException("contactPoints == null");
    this.contactPoints = contactPoints;
    return (B) this;
  }

  /**
   * Name of the datacenter that will be considered "local" for latency load balancing. When unset,
   * load-balancing is round-robin.
   */
  public B localDc(String localDc) {
    if (localDc == null) throw new NullPointerException("localDc == null");
    this.localDc = localDc;
    return (B) this;
  }

  /** Max pooled connections per datacenter-local host. Defaults to 8 */
  public B maxConnections(int maxConnections) {
    if (maxConnections <= 0) throw new IllegalArgumentException("maxConnections <= 0");
    this.poolLocalSize = maxConnections;
    return (B) this;
  }

  /** Will throw an exception on startup if authentication fails. No default. */
  public B username(@Nullable String username) {
    this.username = username;
    return (B) this;
  }

  /** Will throw an exception on startup if authentication fails. No default. */

View on GitHub (pinned to 878ce2a1fa)

Solutions

  1. Only call localDc when a value exists: if (dc != null) builder.localDc(dc)
  2. Or set it to the correct DC name, e.g. localDc("us-east")
  3. Remove the setter call entirely to keep round-robin load balancing

Example fix

// before
String dc = config.get("zipkin.storage.cassandra.local-dc"); // null when unset
builder.localDc(dc);

// after
String dc = config.get("zipkin.storage.cassandra.local-dc");
if (dc != null) builder.localDc(dc);
Defensive patterns

Strategy: validation

Validate before calling

String dc = config.get("localDc");
if (dc != null) builder.localDc(dc);

Prevention

When it happens

Trigger: Calling localDc(null) unconditionally, e.g. builder.localDc(config.get("localDc")) where the property is optional and often unset.

Common situations: Config mapping code that always invokes setters even when the property is absent; multi-DC migrations where the property is removed but the setter call remains.

Related errors


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