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
- Pass a non-null Duration, e.g. GetExArgs.INSTANCE.ex(Duration.ofSeconds(30))
- Apply a default TTL when the configured value is null
- 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
- Set a default TTL in configuration so the Duration is never null
- Check Optional<Duration> with orElse(defaultTtl) before calling ex()
- Fail fast on null TTLs at the repository/service boundary
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
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- `timestamp` must not be `null`
- `timeout` must not be `null`
- `timestamp` must not be `null`
- The timestamp must be positive
- The timestamp must be positive
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/7f8e0f5a22f80027.
Report an issue: GitHub.