{"record":{"id":"2a94ea03e8f74bb8","repo":"openzipkin/zipkin","slug":"metrics-null-2a94ea","errorCode":null,"errorMessage":"metrics == null","messagePattern":"metrics == null","errorType":"validation","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"zipkin-collector/scribe/src/main/java/zipkin2/collector/scribe/ScribeCollector.java","lineNumber":39,"sourceCode":"\n  public static Builder newBuilder() {\n    return new Builder();\n  }\n\n  /** Configuration including defaults needed to receive spans from a Scribe category. */\n  public static final class Builder extends CollectorComponent.Builder {\n    Collector.Builder delegate = Collector.newBuilder(ScribeCollector.class);\n    CollectorMetrics metrics = CollectorMetrics.NOOP_METRICS;\n    String category = \"zipkin\";\n    int port = 9410;\n\n    @Override public Builder storage(StorageComponent storage) {\n      delegate.storage(storage);\n      return this;\n    }\n\n    @Override public Builder metrics(CollectorMetrics metrics) {\n      if (metrics == null) throw new NullPointerException(\"metrics == null\");\n      this.metrics = metrics.forTransport(\"scribe\");\n      delegate.metrics(this.metrics);\n      return this;\n    }\n\n    @Override public Builder sampler(CollectorSampler sampler) {\n      delegate.sampler(sampler);\n      return this;\n    }\n\n    /** Category zipkin spans will be consumed from. Defaults to \"zipkin\" */\n    public Builder category(String category) {\n      if (category == null) throw new NullPointerException(\"category == null\");\n      this.category = category;\n      return this;\n    }\n\n    /** The port to listen on. Defaults to 9410 */","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/openzipkin/zipkin/blob/878ce2a1fad54ca941d17fdcf2e1d924b148eb1f/zipkin-collector/scribe/src/main/java/zipkin2/collector/scribe/ScribeCollector.java#L21-L57","documentation":"ScribeCollector.Builder.metrics(CollectorMetrics) throws NullPointerException when metrics is null. The metrics instance is scoped to the 'scribe' transport and passed through to the delegate Collector; the builder requires it non-null at configuration time. Omitting the call is fine — the builder defaults to NOOP metrics.","triggerScenarios":"Calling .metrics(null) — typically a DI wiring path where no CollectorMetrics bean exists, or a conditional that uses null to mean 'metrics disabled'.","commonSituations":"Custom server bootstrap code where metrics are optional and null is used as a sentinel.","solutions":["Pass CollectorMetrics.NOOP_METRICS or a real metrics implementation","Provide a default CollectorMetrics bean in the DI container","Do not call metrics() at all to keep the NOOP default"],"exampleFix":"// before\nbuilder.metrics(enabled ? metricsImpl : null);\n\n// after\nbuilder.metrics(enabled ? metricsImpl : CollectorMetrics.NOOP_METRICS);","handlingStrategy":"validation","validationCode":"builder.metrics(metrics != null ? metrics : CollectorMetrics.NOOP_METRICS);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use NOOP_METRICS instead of null for 'no metrics'","Provide a DI default for CollectorMetrics"],"tags":["scribe","zipkin","builder","null-check","metrics"],"backgroundTag":null,"analyzedSha":"878ce2a1fad54ca941d17fdcf2e1d924b148eb1f","analyzedAt":"2026-08-14T15:17:09.895Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}