openzipkin/zipkin · error · NullPointerException

topic is null or empty

Error message

topic is null or empty

What it means

PulsarCollector.Builder.topic(String) throws NullPointerException when the topic is null or empty (checked with StringUtils.isNullOrEmpty). The topic is the queue zipkin spans are consumed from (default "zipkin"); an empty string is treated as a misconfiguration, not just null. Fail-fast at builder time.

Source

Thrown at zipkin-collector/pulsar/src/main/java/zipkin2/collector/pulsar/PulsarCollector.java:71

      this.delegate.sampler(sampler);
      return this;
    }

    @Override
    public PulsarCollector build() {
      return new PulsarCollector(this);
    }

    /** Count of concurrent message consumers on the topic. Defaults to 1. */
    public Builder concurrency(Integer concurrency) {
      if (concurrency < 1) throw new IllegalArgumentException("concurrency < 1");
      this.concurrency = concurrency;
      return this;
    }

    /** Queue zipkin spans will be consumed from. Defaults to "zipkin". */
    public Builder topic(String topic) {
      if (StringUtils.isNullOrEmpty(topic)) throw new NullPointerException("topic is null or empty");
      this.topic = topic;
      return this;
    }

    /** The service URL for the Pulsar client ex. pulsar://my-broker:6650. No default. */
    public Builder serviceUrl(String serviceUrl) {
      if (StringUtils.isNullOrEmpty(serviceUrl)) throw new NullPointerException("serviceUrl is null or empty");
      clientProps.put("serviceUrl", serviceUrl);
      return this;
    }

    /** Specify the subscription name for this consumer. No default. */
    public Builder subscriptionName(String subscriptionName) {
      if (StringUtils.isNullOrEmpty(subscriptionName)) throw new NullPointerException("serviceUrl is null or empty");
      consumerProps.put("subscriptionName", subscriptionName);
      return this;
    }

View on GitHub (pinned to 878ce2a1fa)

Solutions

  1. Pass a concrete topic name, e.g. .topic("zipkin")
  2. Default missing config at read time: getOrDefault("pulsar.topic", "zipkin") and treat blank as unset
  3. Omit the topic() call entirely to keep the default "zipkin"

Example fix

// before
builder.topic(config.get("topic").trim()); // "" when key absent

// after
String topic = config.getOrDefault("topic", "zipkin").trim();
if (topic.isEmpty()) topic = "zipkin";
builder.topic(topic);
Defensive patterns

Strategy: validation

Validate before calling

String topic = config.getOrDefault("pulsar.topic", "zipkin");
if (topic == null || topic.trim().isEmpty()) topic = "zipkin";
builder.topic(topic);

Type guard

static boolean isMeaningful(String s) { return s != null && !s.trim().isEmpty(); }

Prevention

When it happens

Trigger: Calling .topic(null) or .topic("") — e.g. reading the topic name from a config key that is absent (null) or present but blank.

Common situations: Optional topic config rendered as an empty string in YAML/JSON bindings, or trimming user input to "" before passing it in.

Related errors


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