{"record":{"id":"d6bc68c4e3722575","repo":"openzipkin/zipkin","slug":"topic-null","errorCode":null,"errorMessage":"topic == null","messagePattern":"topic == null","errorType":"exception","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"zipkin-collector/kafka/src/main/java/zipkin2/collector/kafka/KafkaCollector.java","lineNumber":85,"sourceCode":"    public Builder sampler(CollectorSampler sampler) {\n      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(\"kafka\");\n      delegate.metrics(this.metrics);\n      return this;\n    }\n\n    /**\n     * Topic zipkin spans will be consumed from. Defaults to \"zipkin\". Multiple topics may be\n     * specified if comma delimited.\n     */\n    public Builder topic(String topic) {\n      if (topic == null) throw new NullPointerException(\"topic == null\");\n      this.topic = topic;\n      return this;\n    }\n\n    /** The bootstrapServers connect string, ex. 127.0.0.1:9092. No default. */\n    public Builder bootstrapServers(String bootstrapServers) {\n      if (bootstrapServers == null) throw new NullPointerException(\"bootstrapServers == null\");\n      properties.put(BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);\n      return this;\n    }\n\n    /** The consumer group this process is consuming on behalf of. Defaults to \"zipkin\" */\n    public Builder groupId(String groupId) {\n      if (groupId == null) throw new NullPointerException(\"groupId == null\");\n      properties.put(GROUP_ID_CONFIG, groupId);\n      return this;\n    }\n","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/openzipkin/zipkin/blob/878ce2a1fad54ca941d17fdcf2e1d924b148eb1f/zipkin-collector/kafka/src/main/java/zipkin2/collector/kafka/KafkaCollector.java#L67-L103","documentation":"KafkaCollector.Builder.topic(String) rejects null: the topic (or comma-delimited topic list) the collector consumes must be a concrete string. The default is \"zipkin\"; only an explicit null (not empty) is an error, mirroring the queue-name check in the ActiveMQ collector.","triggerScenarios":"Calling .topic(null), most commonly .topic(System.getenv(\"KAFKA_TOPIC\")) or a properties lookup for an unset key.","commonSituations":"Optional topic override treated as mandatory; env var not exported in the deployment; property key typo (topics vs topic); test config omitting the topic.","solutions":["Skip the .topic(...) call when unset to use the default \"zipkin\" topic.","Or coalesce: .topic(t != null ? t : \"zipkin\").","Verify the env/property name and that it is exported to the collector process."],"exampleFix":"// before\nString t = System.getenv(\"KAFKA_TOPIC\"); // null when unset\nbuilder.topic(t); // NPE\n\n// after\nif (System.getenv(\"KAFKA_TOPIC\") != null) {\n  builder.topic(System.getenv(\"KAFKA_TOPIC\"));\n}","handlingStrategy":"validation","validationCode":"java\nString t = System.getenv(\"KAFKA_TOPIC\");\nif (t != null) builder.topic(t); // defaults to \"zipkin\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only set optional string config on builders when present; rely on documented defaults otherwise.","Verify env vars are exported to the collector process."],"tags":["zipkin","java","kafka","collector","configuration"],"backgroundTag":null,"analyzedSha":"878ce2a1fad54ca941d17fdcf2e1d924b148eb1f","analyzedAt":"2026-08-14T15:17:09.895Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}