{"record":{"id":"be187b6fdcc5666d","repo":"openzipkin/zipkin","slug":"loggingclass-null","errorCode":null,"errorMessage":"loggingClass == null","messagePattern":"loggingClass == null","errorType":"exception","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"zipkin-collector/core/src/main/java/zipkin2/collector/Collector.java","lineNumber":43,"sourceCode":" * This component takes action on spans received from a transport. This includes deserializing,\n * sampling and scheduling for storage.\n *\n * <p>Callbacks passed do not propagate to the storage layer. They only return success or failures\n * before storage is attempted. This ensures that calling threads are disconnected from storage\n * threads.\n */\npublic class Collector { // not final for mock\n  static final Callback<Void> NOOP_CALLBACK = new Callback<Void>() {\n    @Override public void onSuccess(Void value) {\n    }\n\n    @Override public void onError(Throwable t) {\n    }\n  };\n\n  /** 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;","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/openzipkin/zipkin/blob/878ce2a1fad54ca941d17fdcf2e1d924b148eb1f/zipkin-collector/core/src/main/java/zipkin2/collector/Collector.java#L25-L61","documentation":"Collector.newBuilder(Class<?>) requires a non-null logging class because it derives the SLF4J logger category from it (LoggerFactory.getLogger(loggingClass.getName())). The logger scopes accept() warnings (e.g. storage failures, dropped spans) to the calling collector's category, so null is a programming error.","triggerScenarios":"Calling Collector.newBuilder(null), usually when a class variable or config-driven class reference is null at wiring time.","commonSituations":"Copy-pasted bootstrap code where the class literal was dropped; reflective setup where the Class object failed to load and null propagated.","solutions":["Pass the concrete collector class, e.g. Collector.newBuilder(LazyActiveMQCollector.class).","If the class reference is dynamic, null-check it before calling and fail with a descriptive message."],"exampleFix":"// before\nClass<?> lc = config.getLoggingClass(); // null\nCollector.newBuilder(lc); // NPE\n\n// after\nCollector.newBuilder(ActiveMQCollector.class);","handlingStrategy":"validation","validationCode":"java\nObjects.requireNonNull(loggingClass, \"loggingClass\");\nreturn Collector.newBuilder(loggingClass);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass class literals (Foo.class) rather than variables where possible."],"tags":["zipkin","java","collector","builder","logging"],"backgroundTag":null,"analyzedSha":"878ce2a1fad54ca941d17fdcf2e1d924b148eb1f","analyzedAt":"2026-08-14T15:17:09.895Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}