redis/jedis · error · IllegalArgumentException

Version can not be null

Error message

Version can not be null

What it means

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.

Solutions

  1. Check the value passed to the RedisVersion constructor is a non-null, non-empty dotted version string before constructing it.
  2. If the version comes from config, supply a default (e.g. the minimum supported server version) when the value is absent.
  3. If the version comes from server probing, verify the connection/HELLO or INFO call succeeded before using the result.

Example fix

// before
RedisVersion v = new RedisVersion(config.getServerVersion());
// after
RedisVersion v = config.getServerVersion() != null
    ? new RedisVersion(config.getServerVersion())
    : new RedisVersion("7.0.0");
Defensive patterns

Strategy: validation

Validate before calling

if (version == null || version.isEmpty()) {
  throw new IllegalArgumentException("server version must be resolved before constructing RedisVersion");
}

Type guard

boolean isValidVersion(String v) { return v != null && v.matches("\\d+(\\.\\d+)*"); }

Try / catch

try {
  RedisVersion v = new RedisVersion(serverVersion);
} catch (IllegalArgumentException e) {
  // fall back to a default supported version
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of redis/jedis@6dac31d4c2 (2026-09-08). Data as JSON: /api/errors/fc465d6a37fbbf87. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/redis/clients/jedis/csc/RedisVersion.java:11

package redis.clients.jedis.csc;

import java.util.Arrays;

class RedisVersion implements Comparable<RedisVersion> {

    private String version;
    private Integer[] numbers;

    public RedisVersion(String version) {
        if (version == null) throw new IllegalArgumentException("Version can not be null");
        this.version = version;
        this.numbers = Arrays.stream(version.split("\\.")).map(n -> Integer.parseInt(n)).toArray(Integer[]::new);
    }

    @Override
    public int compareTo(RedisVersion other) {
        int max = Math.max(this.numbers.length, other.numbers.length);
        for (int i = 0; i < max; i++) {
            int thisNumber = this.numbers.length > i ? this.numbers[i]:0;
            int otherNumber = other.numbers.length > i ? other.numbers[i]:0;
            if (thisNumber < otherNumber) return -1;
            if (thisNumber > otherNumber) return 1;
        }
        return 0;
    }

    @Override
    public String toString() {

View on GitHub (pinned to 6dac31d4c2)