quarkusio/quarkus · error · IllegalArgumentException

`%s` must not be `null`

Error message

`%s` must not be `null`

What it means

Validation.validateTimeout guards Duration arguments used by Redis commands with timeouts (e.g. wait, setex-style TTLs, blocking command timeouts). A null Duration cannot be converted to a Redis time value, so the datasource fails fast with IllegalArgumentException naming the offending parameter.

Source

Thrown at extensions/redis-client/runtime/src/main/java/io/quarkus/redis/runtime/datasource/Validation.java:115

            throw new IllegalArgumentException("`" + name + "` must not be empty");
        }
    }

    static void validateLongitude(double longitude) {
        if (longitude < -180 || longitude > 180) {
            throw new IllegalArgumentException("The longitude must be in [-180, 180]");
        }
    }

    static void validateLatitude(double latitude) {
        if (latitude < -85.05112878 || latitude > 85.05112878) {
            throw new IllegalArgumentException("The latitude must be in [85.05112878, 85.05112878]");
        }
    }

    public static void validateTimeout(Duration value, String name) {
        if (value == null) {
            throw new IllegalArgumentException(String.format("`%s` must not be `null`", name));
        }
        if (value.isNegative()) {
            throw new IllegalArgumentException(String.format("`%s` must be greater than or equal to zero", name));
        }
    }

    public static void positive(double amount, String name) {
        if (amount <= 0) {
            throw new IllegalArgumentException(String.format("`%s` must be greater than zero`", name));
        }
    }

    public static void positiveOrZero(double amount, String name) {
        if (amount < 0) {
            throw new IllegalArgumentException(String.format("`%s` must be greater or equal to zero", name));
        }
    }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Provide a non-null Duration, e.g. Duration.ofSeconds(5), at the call site
  2. Give the config property a default value or mark it required so it is never null
  3. Use Optional/Objects.requireNonNullElse to substitute a default: Objects.requireNonNullElse(cfg.ttl(), Duration.ZERO)
  4. If zero is intended, pass Duration.ZERO explicitly (it passes this check; only negatives are rejected by the sibling branch)

Example fix

// before
redis.set(key, value, SetArgs ex(ttl)); // ttl is null
// after
Duration ttl = Objects.requireNonNullElse(configuredTtl, Duration.ofSeconds(60));
redis.set(key, value, SetArgs ex(ttl));
Defensive patterns

Strategy: validation

Validate before calling

Objects.requireNonNull(ttl, "ttl must not be null");
Duration safe = Objects.requireNonNullElse(ttl, Duration.ofSeconds(60));

Try / catch

try { redis.setTimeout(value); } catch (IllegalArgumentException e) { log.error("Invalid timeout: {}", e.getMessage()); throw new ConfigurationException(e); }

Prevention

When it happens

Trigger: Passing a null Duration to a Redis command that accepts a timeout/duration parameter, typically because a config property was absent and no default was applied, or a method returned Optional.empty().get-less null.

Common situations: Application configuration (e.g. quarkus.redis.timeout or a custom TTL property) not set so an injected field stays null; computing a Duration from a nullable timestamp difference; refactoring that dropped a default value like Duration.ofSeconds(5).

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/9c3a1cf429713d8d. Report an issue: GitHub.