{"record":{"id":"4e7521f3daadb4d0","repo":"openzipkin/zipkin","slug":"bootstrapservers-null","errorCode":null,"errorMessage":"bootstrapServers == null","messagePattern":"bootstrapServers == null","errorType":"exception","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"zipkin-collector/kafka/src/main/java/zipkin2/collector/kafka/KafkaCollector.java","lineNumber":92,"sourceCode":"      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\n    /** Count of threads consuming the topic. Defaults to 1 */\n    public Builder streams(int streams) {\n      this.streams = streams;\n      return this;\n    }\n\n    /**","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/openzipkin/zipkin/blob/878ce2a1fad54ca941d17fdcf2e1d924b148eb1f/zipkin-collector/kafka/src/main/java/zipkin2/collector/kafka/KafkaCollector.java#L74-L110","documentation":"KafkaCollector.Builder.bootstrapServers(String) rejects a null argument with NullPointerException. bootstrapServers is the Kafka connect string (e.g. 127.0.0.1:9092) and has no default, so the builder enforces that you supply one before build(). This is a fail-fast guard in the builder, thrown at configuration time, not at connection time.","triggerScenarios":"Calling KafkaCollector.newBuilder().bootstrapServers(null), or passing a variable that is null (e.g. an unset environment variable or system property parsed to null) into bootstrapServers().","commonSituations":"Reading KAFKA_BOOTSTRAP_SERVERS from config/env that is missing in a deployment (e.g. Docker/Kubernetes), or wiring the collector in a test without setting the Kafka address. Because there is no default, any deployment that forgets the Kafka connect string fails here.","solutions":["Set the bootstrapServers value explicitly, e.g. .bootstrapServers(\"127.0.0.1:9092\") or from environment: .bootstrapServers(System.getenv(\"KAFKA_BOOTSTRAP_SERVERS\"))","If the value comes from config, validate/require it at application startup before building the collector","For tests, point it at an embedded Kafka broker or a Testcontainers Kafka instance"],"exampleFix":"// before\nKafkaCollector collector = KafkaCollector.newBuilder()\n  .bootstrapServers(System.getenv(\"KAFKA_BOOTSTRAP_SERVERS\")) // null in this env\n  .build();\n\n// after\nString bootstrap = requireNonNull(\n  System.getenv(\"KAFKA_BOOTSTRAP_SERVERS\"), \"KAFKA_BOOTSTRAP_SERVERS must be set\");\nKafkaCollector collector = KafkaCollector.newBuilder()\n  .bootstrapServers(bootstrap)\n  .build();","handlingStrategy":"validation","validationCode":"String bootstrap = System.getenv(\"KAFKA_BOOTSTRAP_SERVERS\");\nif (bootstrap == null || bootstrap.isEmpty()) {\n  throw new IllegalStateException(\"KAFKA_BOOTSTRAP_SERVERS is required\");\n}\nKafkaCollector.newBuilder().bootstrapServers(bootstrap);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat bootstrapServers as a required deployment variable and fail at startup with a clear message","Validate non-empty before calling any builder setter that documents 'No default'","Integration-test the collector wiring with an embedded Kafka so a missing connect string fails in CI, not prod"],"tags":["kafka","zipkin","builder","null-check","configuration"],"backgroundTag":null,"analyzedSha":"878ce2a1fad54ca941d17fdcf2e1d924b148eb1f","analyzedAt":"2026-08-14T15:17:09.895Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}