{"record":{"id":"d3cd7f4dac2d0c7c","repo":"redis/jedis","slug":"driverinfo-must-not-be-null","errorCode":null,"errorMessage":"DriverInfo must not be null","messagePattern":"DriverInfo must not be null","errorType":"validation","errorClass":"JedisValidationException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/ClientSetInfoConfig.java","lineNumber":74,"sourceCode":"   * @param libNameSuffix the suffix to append to \"jedis\" (will be placed in parentheses)\n   * @throws JedisValidationException if libNameSuffix contains braces\n   */\n  public ClientSetInfoConfig(String libNameSuffix) {\n    this.disabled = false;\n    this.driverInfo = DriverInfo.builder().addUpstreamDriver(libNameSuffix).build();\n  }\n\n  /**\n   * Creates a new ClientSetInfoConfig with the specified driver information.\n   * <p>\n   * This is the recommended constructor for setting up driver information with upstream drivers.\n   * The driver information can optionally override the library name completely.\n   * @param driverInfo the driver information, must not be {@code null}\n   * @throws JedisValidationException if driverInfo is {@code null}\n   */\n  public ClientSetInfoConfig(DriverInfo driverInfo) {\n    if (driverInfo == null) {\n      throw new JedisValidationException(\"DriverInfo must not be null\");\n    }\n    this.disabled = false;\n    this.driverInfo = driverInfo;\n  }\n\n  /**\n   * @return {@code true} if CLIENT SETINFO is disabled, {@code false} otherwise\n   */\n  public boolean isDisabled() {\n    return disabled;\n  }\n\n  /**\n   * @return the driver information\n   */\n  public DriverInfo getDriverInfo() {\n    return driverInfo;\n  }","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/ClientSetInfoConfig.java#L56-L92","documentation":"ClientSetInfoConfig is used with CLIENT SETINFO to attach driver/library metadata to a Redis connection. The constructor validates its argument and throws JedisValidationException when driverInfo is null, because a config with neither driverInfo nor a meaningful value would produce invalid CLIENT SETINFO arguments.","triggerScenarios":"Calling `new ClientSetInfoConfig(null)` directly, or passing a DriverInfo variable that was never initialized (or returned null from a factory/lookup) into the constructor or into ClientSetInfoConfig.builder().driverInfo(null).","commonSituations":"Building connection configuration where DriverInfo is loaded conditionally (e.g. from properties) and a missing property yields null; refactoring code that previously passed a library-name string and now passes a DriverInfo object.","solutions":["Construct a DriverInfo before building the config, e.g. `new ClientSetInfoConfig(new DriverInfo(\"my-lib\", \"1.0.0\"))`","Null-check the DriverInfo value at the call site before creating ClientSetInfoConfig","If driver info is optional in your flow, guard with `driverInfo == null ? default : new ClientSetInfoConfig(driverInfo)`"],"exampleFix":"// before\nDriverInfo info = loadDriverInfo(); // may return null\nClientSetInfoConfig cfg = new ClientSetInfoConfig(info);\n// after\nDriverInfo info = loadDriverInfo();\nClientSetInfoConfig cfg = info != null ? new ClientSetInfoConfig(info) : null;","handlingStrategy":"validation","validationCode":"if (driverInfo == null) throw new IllegalArgumentException(\"driverInfo must be set before creating ClientSetInfoConfig\");","typeGuard":"static boolean hasDriverInfo(DriverInfo d) { return d != null; }","tryCatchPattern":"try { new ClientSetInfoConfig(driverInfo); } catch (JedisValidationException e) { logger.error(\"ClientSetInfoConfig requires non-null DriverInfo\", e); driverInfo = new DriverInfo(\"default\", \"0\"); }","preventionTips":["Always construct DriverInfo alongside ClientSetInfoConfig in a single factory method","Null-check configuration values loaded from properties/env before building client config","Enable IDE null-analysis (@NonNull) to catch null arguments at compile time"],"tags":["java","validation","null-check","client-setinfo"],"backgroundTag":"null-argument","analyzedSha":"6dac31d4c224fb3257c216f3985340c6f500cdcb","analyzedAt":"2026-09-08T04:55:01.204Z","contentChangedAt":"2026-09-08T04:55:01.204Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}