openzipkin/zipkin · error · NullPointerException

consumerProps is empty

Error message

consumerProps is empty

What it means

PulsarCollector.Builder.consumerProps(Map) throws NullPointerException when the supplied map is empty. These props override the Pulsar consumer configuration via ConsumerBuilder.loadConf; an empty map is rejected as a no-op misconfiguration. As with clientProps, a null argument would NPE on isEmpty() before this message.

Source

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

     * @param clientPropsMap Map<String, Object>
     * @return Builder
     * @see org.apache.pulsar.client.api.ClientBuilder#loadConf(Map)
     */
    public Builder clientProps(Map<String, Object> clientPropsMap) {
      if (clientPropsMap.isEmpty()) throw new NullPointerException("clientProps is empty");
      clientProps.putAll(clientPropsMap);
      return this;
    }

    /**
     * Any properties set here will override the previous Pulsar consumer configuration.
     *
     * @param consumerPropsMap Map<String, Object>
     * @return Builder
     * @see org.apache.pulsar.client.api.ConsumerBuilder#loadConf(Map)
     */
    public Builder consumerProps(Map<String, Object> consumerPropsMap) {
      if (consumerPropsMap.isEmpty()) throw new NullPointerException("consumerProps is empty");
      consumerProps.putAll(consumerPropsMap);
      return this;
    }
  }

  final Map<String, Object> clientProps, consumerProps;
  final String topic;
  final LazyPulsarInit lazyPulsarInit;

  PulsarCollector(Builder builder) {
    clientProps = builder.clientProps;
    consumerProps = builder.consumerProps;
    this.topic = builder.topic;
    this.lazyPulsarInit = new LazyPulsarInit(builder);
  }

  @Override
  public PulsarCollector start() {

View on GitHub (pinned to 878ce2a1fa)

Solutions

  1. Guard the call: if (map != null && !map.isEmpty()) builder.consumerProps(map)
  2. Populate the map with actual intended overrides (e.g. subscriptionType, receiverQueueSize) or remove the call
  3. Default optional config sections to null and only invoke the setter when present

Example fix

// before
builder.consumerProps(buildConsumerOverrides(config)); // may return empty map

// after
Map<String, Object> overrides = buildConsumerOverrides(config);
if (!overrides.isEmpty()) builder.consumerProps(overrides);
Defensive patterns

Strategy: type-guard

Validate before calling

Map<String, Object> m = config.consumerProps();
if (m != null && !m.isEmpty()) builder.consumerProps(m);

Type guard

static boolean isNonEmptyMap(Map<?, ?> m) { return m != null && !m.isEmpty(); }

Prevention

When it happens

Trigger: Calling .consumerProps(Collections.emptyMap()) or with an empty map built from an absent config section.

Common situations: Dynamic config that constructs an overrides map and calls consumerProps unconditionally, even when no overrides were specified.

Related errors


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