{"record":{"id":"d431002e6ae92a1c","repo":"openzipkin/zipkin","slug":"hostport-null","errorCode":null,"errorMessage":"hostPort == null","messagePattern":"hostPort == null","errorType":"validation","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"zipkin-storage/cassandra/src/main/java/zipkin2/storage/cassandra/internal/HostAndPort.java","lineNumber":53,"sourceCode":"\n  @Override public int hashCode() {\n    int h = 1;\n    h *= 1000003;\n    h ^= (host == null) ? 0 : host.hashCode();\n    h *= 1000003;\n    h ^= port;\n    return h;\n  }\n\n  @Override public String toString() {\n    return \"HostAndPort{host=\" + host + \", port=\" + port + \"}\";\n  }\n\n  /**\n   * Constructs a host-port pair from the given string, defaulting to the indicated port if absent\n   */\n  public static HostAndPort fromString(String hostPort, int defaultPort) {\n    if (hostPort == null) throw new NullPointerException(\"hostPort == null\");\n\n    String host = hostPort;\n    int endHostIndex = hostPort.length();\n    if (hostPort.startsWith(\"[\")) { // Bracketed IPv6\n      endHostIndex = hostPort.lastIndexOf(']') + 1;\n      host = hostPort.substring(1, endHostIndex == 0 ? 1 : endHostIndex - 1);\n      if (!Endpoint.newBuilder().parseIp(host)) { // reuse our IPv6 validator\n        throw new IllegalArgumentException(hostPort + \" contains an invalid IPv6 literal\");\n      }\n    } else {\n      int colonIndex = hostPort.indexOf(':'), nextColonIndex = hostPort.lastIndexOf(':');\n      if (colonIndex >= 0) {\n        if (colonIndex == nextColonIndex) { // only 1 colon\n          host = hostPort.substring(0, colonIndex);\n          endHostIndex = colonIndex;\n        } else if (!Endpoint.newBuilder().parseIp(hostPort)) { // reuse our IPv6 validator\n          throw new IllegalArgumentException(hostPort + \" is an invalid IPv6 literal\");\n        }","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/openzipkin/zipkin/blob/878ce2a1fad54ca941d17fdcf2e1d924b148eb1f/zipkin-storage/cassandra/src/main/java/zipkin2/storage/cassandra/internal/HostAndPort.java#L35-L71","documentation":"HostAndPort.fromString(hostPort, defaultPort) throws NullPointerException('hostPort == null') when the contact-point string is null. It is a plain fail-fast guard before any parsing; contact points must be non-null strings.","triggerScenarios":"Passing a null contact point string, e.g. from CASSANDRA_CONTACT_POINTS processing where a split/trim produced null or a config lookup returned null.","commonSituations":"Config property missing so the loader hands null into the parser; string splitting logic that yields null elements.","solutions":["Supply a non-null host or host:port string such as 'localhost' or '127.0.0.1:9042'.","Default the config value at load time (e.g. getenvOrDefault('CASSANDRA_CONTACT_POINTS', 'localhost')).","Filter null/blank entries before parsing lists of contact points."],"exampleFix":"// before\nHostAndPort.fromString(env.get(\"HOST\"), 9042); // env.get -> null\n\n// after\nHostAndPort.fromString(env.getOrDefault(\"HOST\", \"localhost\"), 9042);","handlingStrategy":"validation","validationCode":"String hp = env.getOrDefault(\"CASSANDRA_CONTACT_POINTS\", \"localhost\");\nif (hp == null || hp.isBlank()) throw new IllegalArgumentException(\"Contact point must not be empty\");\nHostAndPort.fromString(hp, 9042);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always default contact-point config values instead of passing lookups through.","Reject blank entries when parsing comma-separated lists."],"tags":["cassandra","zipkin","null-check","contact-points","configuration"],"backgroundTag":null,"analyzedSha":"878ce2a1fad54ca941d17fdcf2e1d924b148eb1f","analyzedAt":"2026-08-14T15:17:09.895Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}