{"record":{"id":"01777995a110fbd9","repo":"openzipkin/zipkin","slug":"metrics-null-017779","errorCode":null,"errorMessage":"metrics == null","messagePattern":"metrics == null","errorType":"exception","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"zipkin-collector/rabbitmq/src/main/java/zipkin2/collector/rabbitmq/RabbitMQCollector.java","lineNumber":66,"sourceCode":"    ConnectionFactory connectionFactory = new ConnectionFactory();\n    Address[] addresses;\n    int concurrency = 1;\n\n    @Override\n    public Builder storage(StorageComponent storage) {\n      this.delegate.storage(storage);\n      return this;\n    }\n\n    @Override\n    public Builder sampler(CollectorSampler sampler) {\n      this.delegate.sampler(sampler);\n      return this;\n    }\n\n    @Override\n    public Builder metrics(CollectorMetrics metrics) {\n      if (metrics == null) throw new NullPointerException(\"metrics == null\");\n      this.metrics = metrics.forTransport(\"rabbitmq\");\n      this.delegate.metrics(this.metrics);\n      return this;\n    }\n\n    public Builder addresses(List<String> addresses) {\n      this.addresses = convertAddresses(addresses);\n      return this;\n    }\n\n    public Builder concurrency(int concurrency) {\n      this.concurrency = concurrency;\n      return this;\n    }\n\n    public Builder connectionFactory(ConnectionFactory connectionFactory) {\n      if (connectionFactory == null) throw new NullPointerException(\"connectionFactory == null\");\n      this.connectionFactory = connectionFactory;","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/openzipkin/zipkin/blob/878ce2a1fad54ca941d17fdcf2e1d924b148eb1f/zipkin-collector/rabbitmq/src/main/java/zipkin2/collector/rabbitmq/RabbitMQCollector.java#L48-L84","documentation":"RabbitMQCollector.Builder.metrics(CollectorMetrics) throws NullPointerException on a null argument. The metrics instance is scoped to the 'rabbitmq' transport and forwarded to the delegate Collector; the builder requires it non-null so metric registration can never fail later with a confusing NPE.","triggerScenarios":"Calling .metrics(null) — e.g. a DI container injecting a missing CollectorMetrics bean, or a conditional expression that yields null when metrics are 'disabled'.","commonSituations":"Custom server integrations where metrics are treated as optional and null is used to mean 'none'.","solutions":["Pass CollectorMetrics.NOOP_METRICS (or a real implementation) instead of null","Provide a default metrics bean in DI setups","Omit the metrics() call — the builder defaults to NOOP metrics already"],"exampleFix":"// before\nbuilder.metrics(metricsEnabled ? metricsImpl : null);\n\n// after\nbuilder.metrics(metricsEnabled ? metricsImpl : CollectorMetrics.NOOP_METRICS);","handlingStrategy":"validation","validationCode":"builder.metrics(metrics != null ? metrics : CollectorMetrics.NOOP_METRICS);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use NOOP_METRICS as the 'disabled' sentinel, never null","Default DI beans for CollectorMetrics"],"tags":["rabbitmq","zipkin","builder","null-check","metrics"],"backgroundTag":null,"analyzedSha":"878ce2a1fad54ca941d17fdcf2e1d924b148eb1f","analyzedAt":"2026-08-14T15:17:09.895Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}