openzipkin/zipkin · error · NullPointerException

connectionFactory == null

Error message

connectionFactory == null

What it means

RabbitMQCollector.Builder.connectionFactory(ConnectionFactory) throws NullPointerException when null. The ConnectionFactory is how the collector creates its AMQP connection(s); supplying one lets you customize credentials/vhosts, and the builder demands it be a real instance. If you never call it, a default factory is used at connect time.

Source

Thrown at zipkin-collector/rabbitmq/src/main/java/zipkin2/collector/rabbitmq/RabbitMQCollector.java:83

    public Builder metrics(CollectorMetrics metrics) {
      if (metrics == null) throw new NullPointerException("metrics == null");
      this.metrics = metrics.forTransport("rabbitmq");
      this.delegate.metrics(this.metrics);
      return this;
    }

    public Builder addresses(List<String> addresses) {
      this.addresses = convertAddresses(addresses);
      return this;
    }

    public Builder concurrency(int concurrency) {
      this.concurrency = concurrency;
      return this;
    }

    public Builder connectionFactory(ConnectionFactory connectionFactory) {
      if (connectionFactory == null) throw new NullPointerException("connectionFactory == null");
      this.connectionFactory = connectionFactory;
      return this;
    }

    /** Queue zipkin spans will be consumed from. Defaults to "zipkin-spans". */
    public Builder queue(String queue) {
      if (queue == null) throw new NullPointerException("queue == null");
      this.queue = queue;
      return this;
    }

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

  final String queue;

View on GitHub (pinned to 878ce2a1fa)

Solutions

  1. To use defaults, simply do not call connectionFactory() at all
  2. Otherwise pass a configured com.rabbitmq.client.ConnectionFactory (host, credentials, vhost, TLS)
  3. Fix the factory bean/config so it never yields null

Example fix

// before
ConnectionFactory cf = config.hasRabbitConfig() ? buildFactory(config) : null;
builder.connectionFactory(cf);

// after
if (config.hasRabbitConfig()) builder.connectionFactory(buildFactory(config));
// else: omit the call to use the default factory
Defensive patterns

Strategy: validation

Validate before calling

if (customFactory != null) builder.connectionFactory(customFactory);
// else: omit the call to use the default factory

Prevention

When it happens

Trigger: Calling .connectionFactory(null) — e.g. a factory bean that failed to initialize and returned null, or a config branch intended to 'use the default' passing null explicitly.

Common situations: Conditional wiring where 'use default factory' is expressed as null instead of omitting the setter call; or a custom factory built from config keys that were missing.

Related errors


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