{"record":{"id":"fc465d6a37fbbf87","repo":"redis/jedis","slug":"version-can-not-be-null","errorCode":null,"errorMessage":"Version can not be null","messagePattern":"Version can not be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/csc/RedisVersion.java","lineNumber":11,"sourceCode":"package redis.clients.jedis.csc;\n\nimport java.util.Arrays;\n\nclass RedisVersion implements Comparable<RedisVersion> {\n\n    private String version;\n    private Integer[] numbers;\n\n    public RedisVersion(String version) {\n        if (version == null) throw new IllegalArgumentException(\"Version can not be null\");\n        this.version = version;\n        this.numbers = Arrays.stream(version.split(\"\\\\.\")).map(n -> Integer.parseInt(n)).toArray(Integer[]::new);\n    }\n\n    @Override\n    public int compareTo(RedisVersion other) {\n        int max = Math.max(this.numbers.length, other.numbers.length);\n        for (int i = 0; i < max; i++) {\n            int thisNumber = this.numbers.length > i ? this.numbers[i]:0;\n            int otherNumber = other.numbers.length > i ? other.numbers[i]:0;\n            if (thisNumber < otherNumber) return -1;\n            if (thisNumber > otherNumber) return 1;\n        }\n        return 0;\n    }\n\n    @Override\n    public String toString() {","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/csc/RedisVersion.java#L1-L29","documentation":"RedisVersion is a comparable wrapper around dotted version strings (e.g. \"7.2.4\"), used by the client-side caching (csc) module to compare server versions. The constructor throws IllegalArgumentException when the supplied version string is null, before attempting to split and parse it into integer components. It is a fail-fast guard against a null version being passed to version comparison logic.","triggerScenarios":"Constructing `new RedisVersion(null)` directly, or passing a null version through csc/BloomFilter configuration (e.g. a RedisVersionHolder or protocol-version setting) whose value was never resolved.","commonSituations":"Reading the version from config or a server handshake response that returned null (e.g. `INFO` parsing failed), or wiring client-side caching where the Redis server version was never probed.","solutions":["Check the value passed to the RedisVersion constructor is a non-null, non-empty dotted version string before constructing it.","If the version comes from config, supply a default (e.g. the minimum supported server version) when the value is absent.","If the version comes from server probing, verify the connection/HELLO or INFO call succeeded before using the result."],"exampleFix":"// before\nRedisVersion v = new RedisVersion(config.getServerVersion());\n// after\nRedisVersion v = config.getServerVersion() != null\n    ? new RedisVersion(config.getServerVersion())\n    : new RedisVersion(\"7.0.0\");","handlingStrategy":"validation","validationCode":"if (version == null || version.isEmpty()) {\n  throw new IllegalArgumentException(\"server version must be resolved before constructing RedisVersion\");\n}","typeGuard":"boolean isValidVersion(String v) { return v != null && v.matches(\"\\\\d+(\\\\.\\\\d+)*\"); }","tryCatchPattern":"try {\n  RedisVersion v = new RedisVersion(serverVersion);\n} catch (IllegalArgumentException e) {\n  // fall back to a default supported version\n}","preventionTips":["Never pass config values straight into RedisVersion without a null/empty check","Provide a default server version when the server cannot be probed","Validate version strings match a dotted-number pattern before parsing"],"tags":["null-check","version-parsing","client-side-caching","illegal-argument"],"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"}