{"record":{"id":"58a678e72abb2c1c","repo":"openzipkin/zipkin","slug":"storage-null","errorCode":null,"errorMessage":"storage == null","messagePattern":"storage == null","errorType":"exception","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"zipkin-collector/core/src/main/java/zipkin2/collector/Collector.java","lineNumber":59,"sourceCode":"  /** Needed to scope this to the correct logging category */\n  public static Builder newBuilder(Class<?> loggingClass) {\n    if (loggingClass == null) throw new NullPointerException(\"loggingClass == null\");\n    return new Builder(LoggerFactory.getLogger(loggingClass.getName()));\n  }\n\n  public static final class Builder {\n    final Logger logger;\n    StorageComponent storage;\n    CollectorSampler sampler;\n    CollectorMetrics metrics;\n\n    Builder(Logger logger) {\n      this.logger = logger;\n    }\n\n    /** Sets {@link {@link CollectorComponent.Builder#storage(StorageComponent)}} */\n    public Builder storage(StorageComponent storage) {\n      if (storage == null) throw new NullPointerException(\"storage == null\");\n      this.storage = storage;\n      return this;\n    }\n\n    /** Sets {@link {@link CollectorComponent.Builder#metrics(CollectorMetrics)}} */\n    public Builder metrics(CollectorMetrics metrics) {\n      if (metrics == null) throw new NullPointerException(\"metrics == null\");\n      this.metrics = metrics;\n      return this;\n    }\n\n    /** Sets {@link {@link CollectorComponent.Builder#sampler(CollectorSampler)}} */\n    public Builder sampler(CollectorSampler sampler) {\n      if (sampler == null) throw new NullPointerException(\"sampler == null\");\n      this.sampler = sampler;\n      return this;\n    }\n","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/openzipkin/zipkin/blob/878ce2a1fad54ca941d17fdcf2e1d924b148eb1f/zipkin-collector/core/src/main/java/zipkin2/collector/Collector.java#L41-L77","documentation":"Collector.Builder.storage rejects null because a Collector is meaningless without a StorageComponent to accept spans into. Storage is the one required dependency with no NOOP default — the Collector constructor re-checks it — so fail-fast at the setter keeps the error at the call site.","triggerScenarios":"Calling .storage(null) on the Collector builder, typically when the storage component construction (e.g. MySQL/ES storage from config) failed or was skipped and null is forwarded.","commonSituations":"Storage config block missing or mis-typed so the factory returns null; conditional storage setup skipped on a code path; tests building a Collector without a storage double.","solutions":["Construct and pass a real StorageComponent first (e.g. MySQLStorage.newBuilder(...)....build()).","For tests, use an in-memory storage: StorageComponent InMemoryStorage.newBuilder().build().","Fix the wiring so storage is guaranteed non-null before the collector is built."],"exampleFix":"// before\nStorageComponent s = config.storage(); // null when config missing\nCollector.newBuilder(cls).storage(s); // NPE\n\n// after\nStorageComponent s = requireNonNull(config.storage(), \"storage config missing\");\nCollector.newBuilder(cls).storage(s);","handlingStrategy":"validation","validationCode":"java\nStorageComponent storage = Objects.requireNonNull(config.storage(), \"storage config missing\");\nCollector.newBuilder(cls).storage(storage);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make storage construction part of startup validation; use InMemoryStorage in tests."],"tags":["zipkin","java","collector","storage","configuration"],"backgroundTag":null,"analyzedSha":"878ce2a1fad54ca941d17fdcf2e1d924b148eb1f","analyzedAt":"2026-08-14T15:17:09.895Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}