{"record":{"id":"913d7fcabde194cc","repo":"openzipkin/zipkin","slug":"localdc-null","errorCode":null,"errorMessage":"localDc == null","messagePattern":"localDc == null","errorType":"validation","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"zipkin-storage/cassandra/src/main/java/zipkin2/storage/cassandra/CassandraStorageBuilder.java","lineNumber":110,"sourceCode":"    return (B) this;\n  }\n\n  /**\n   * Comma separated list of host addresses part of Cassandra cluster. You can also specify a custom\n   * port with 'host:port'. Defaults to localhost on port 9042 *\n   */\n  public B contactPoints(String contactPoints) {\n    if (contactPoints == null) throw new NullPointerException(\"contactPoints == null\");\n    this.contactPoints = contactPoints;\n    return (B) this;\n  }\n\n  /**\n   * Name of the datacenter that will be considered \"local\" for latency load balancing. When unset,\n   * load-balancing is round-robin.\n   */\n  public B localDc(String localDc) {\n    if (localDc == null) throw new NullPointerException(\"localDc == null\");\n    this.localDc = localDc;\n    return (B) this;\n  }\n\n  /** Max pooled connections per datacenter-local host. Defaults to 8 */\n  public B maxConnections(int maxConnections) {\n    if (maxConnections <= 0) throw new IllegalArgumentException(\"maxConnections <= 0\");\n    this.poolLocalSize = maxConnections;\n    return (B) this;\n  }\n\n  /** Will throw an exception on startup if authentication fails. No default. */\n  public B username(@Nullable String username) {\n    this.username = username;\n    return (B) this;\n  }\n\n  /** Will throw an exception on startup if authentication fails. No default. */","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/openzipkin/zipkin/blob/878ce2a1fad54ca941d17fdcf2e1d924b148eb1f/zipkin-storage/cassandra/src/main/java/zipkin2/storage/cassandra/CassandraStorageBuilder.java#L92-L128","documentation":"CassandraStorageBuilder.localDc(String) throws NullPointerException ('localDc == null') when explicitly setting the local datacenter name to null. The local DC names which Cassandra datacenter is 'local' for latency-aware load balancing; if you never need to pin it, simply do not call localDc (round-robin is used) — but an explicit null call is rejected.","triggerScenarios":"Calling localDc(null) unconditionally, e.g. builder.localDc(config.get(\"localDc\")) where the property is optional and often unset.","commonSituations":"Config mapping code that always invokes setters even when the property is absent; multi-DC migrations where the property is removed but the setter call remains.","solutions":["Only call localDc when a value exists: if (dc != null) builder.localDc(dc)","Or set it to the correct DC name, e.g. localDc(\"us-east\")","Remove the setter call entirely to keep round-robin load balancing"],"exampleFix":"// before\nString dc = config.get(\"zipkin.storage.cassandra.local-dc\"); // null when unset\nbuilder.localDc(dc);\n\n// after\nString dc = config.get(\"zipkin.storage.cassandra.local-dc\");\nif (dc != null) builder.localDc(dc);","handlingStrategy":"validation","validationCode":"String dc = config.get(\"localDc\");\nif (dc != null) builder.localDc(dc);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Skip optional setter calls entirely when the value is absent instead of passing null","Reserve null for @Nullable-annotated parameters only"],"tags":["zipkin","cassandra","datacenter","null-check","builder"],"backgroundTag":null,"analyzedSha":"878ce2a1fad54ca941d17fdcf2e1d924b148eb1f","analyzedAt":"2026-08-14T15:17:09.895Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}