quarkusio/quarkus · error · IllegalArgumentException

`timeout` must not be `null`

Error message

`timeout` must not be `null`

What it means

GetExArgs.ex(Duration) sets a seconds-based expiration for GETEX and calls timeout.toSeconds(). A null Duration cannot be converted, so the library throws IllegalArgumentException immediately. It indicates the caller omitted the expiration value.

Source

Thrown at extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/value/GetExArgs.java:40

     * Set the expiration timeout, in seconds.
     *
     * @param timeout expiration timeout in seconds
     * @return the current {@code GetExArgs}
     */
    public GetExArgs ex(long timeout) {
        this.ex = timeout;
        return this;
    }

    /**
     * Set the expiration timeout, in seconds.
     *
     * @param timeout expiration timeout in seconds
     * @return the current {@code GetExArgs}
     */
    public GetExArgs ex(Duration timeout) {
        if (timeout == null) {
            throw new IllegalArgumentException("`timeout` must not be `null`");
        }
        return ex(timeout.toSeconds());
    }

    /**
     * Set the expiration timestamp as a number of seconds since the Unix epoch.
     *
     * @param timestamp the timestamp
     * @return the current {@code GetExArgs}
     */
    public GetExArgs exAt(long timestamp) {
        this.exAt = timestamp;
        return this;
    }

    /**
     * Set the expiration timestamp as a number of seconds since the Unix epoch.
     *

View on GitHub (pinned to e1c734241f)

Solutions

  1. Pass a non-null Duration, e.g. GetExArgs.INSTANCE.ex(Duration.ofSeconds(30))
  2. Apply a default TTL when the configured value is null
  3. Validate the Duration at your service boundary before invoking Redis

Example fix

// before
GetExArgs args = GetExArgs.INSTANCE.ex(ttl); // ttl may be null
// after
GetExArgs args = ttl != null
    ? GetExArgs.INSTANCE.ex(ttl)
    : GetExArgs.INSTANCE.ex(Duration.ofSeconds(60));
Defensive patterns

Strategy: validation

Validate before calling

if (timeout == null) {
    throw new IllegalArgumentException("timeout is required before GetExArgs.ex()");
}
GetExArgs.INSTANCE.ex(timeout);

Type guard

boolean hasTtl(Duration d) { return d != null && !d.isNegative() && !d.isZero(); }

Try / catch

try {
    redis.value().getset(key, value, GetExArgs.INSTANCE.ex(timeout));
} catch (IllegalArgumentException e) {
    throw new IllegalStateException("TTL not configured for GETEX: " + e.getMessage(), e);
}

Prevention

When it happens

Trigger: Calling GetExArgs.ex(null) — commonly when the Duration comes from an optional config property or a nullable method parameter.

Common situations: Missing configuration for a TTL default; a Duration field left uninitialized; passing a value from a downstream API that returned null instead of a default TTL.

Understand the failure class

Related errors


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