quarkusio/quarkus · error · IllegalArgumentException
Param cannot be null
Error message
Param cannot be null
What it means
RequestImpl.evaluatePreconditions(Date) throws IllegalArgumentException when the lastModified Date parameter is null, per the JAX-RS contract. It cannot evaluate If-Modified-Since/If-Unmodified-Since without a timestamp.
Source
Thrown at independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/jaxrs/RequestImpl.java:155
return null;
}
return Response.status(Response.Status.PRECONDITION_FAILED).lastModified(lastModified);
}
/**
* We must compare header dates (seconds-precision) with dates that have the same precision,
* otherwise they may include milliseconds and they will never match the Last-Modified
* values that we generate from them (since we drop their milliseconds when we write the headers)
*/
private long millisecondsWithSecondsPrecision(Date lastModified) {
return (lastModified.getTime() / 1000) * 1000;
}
@Override
public Response.ResponseBuilder evaluatePreconditions(Date lastModified) {
if (lastModified == null)
throw new IllegalArgumentException("Param cannot be null");
Response.ResponseBuilder builder = null;
MultivaluedMap<String, String> headers = requestContext.getHttpHeaders().getRequestHeaders();
String ifModifiedSince = headers.getFirst(HttpHeaders.IF_MODIFIED_SINCE);
if (ifModifiedSince != null && (!isRfc7232preconditions() || (!headers.containsKey(HttpHeaders.IF_NONE_MATCH)))) {
builder = ifModifiedSince(ifModifiedSince, lastModified);
}
if (builder == null) {
String ifUnmodifiedSince = headers.getFirst(HttpHeaders.IF_UNMODIFIED_SINCE);
if (ifUnmodifiedSince != null && (!isRfc7232preconditions() || (!headers.containsKey(HttpHeaders.IF_MATCH)))) {
builder = ifUnmodifiedSince(ifUnmodifiedSince, lastModified);
}
}
if (builder != null && varyHeader != null)
builder.header(HttpHeaders.VARY, varyHeader);
return builder;
}
View on GitHub (pinned to e1c734241f)
Solutions
- Provide a valid lastModified Date, falling back to a creation timestamp or Instant.now().
- When the timestamp is unknown, use the no-arg evaluatePreconditions() overload.
- Null-check the date and return an unconditioned response builder when absent.
Example fix
// before
Response.ResponseBuilder rb = request.evaluatePreconditions(lastModified); // may be null
// after
Response.ResponseBuilder rb = lastModified != null
? request.evaluatePreconditions(lastModified)
: request.evaluatePreconditions(); Defensive patterns
Strategy: type-guard
Validate before calling
if (lastModified == null) {
return request.evaluatePreconditions();
} Type guard
boolean hasTimestamp(Date d) {
return d != null;
} Try / catch
try {
return request.evaluatePreconditions(lastModified);
} catch (IllegalArgumentException e) {
return request.evaluatePreconditions();
} Prevention
- Store a non-null last-modified on every cacheable resource
- Default to creation time when modification time is unknown
- Use the no-arg overload when the date is unavailable
When it happens
Trigger: Calling request.evaluatePreconditions(Date) with a null Date — e.g. the resource's modification timestamp was never set or the lookup returned null.
Common situations: File or entity metadata missing a last-modified value; a Date field that is null for newly created resources; passing an Optional-wrapped date after calling get() on an empty Optional.
Related errors
- Last modified was null
- ETag was null
- etag was null
- retrieving all roles not supported when JAX-RS security cont
- More than one Application class: ${applications}
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/d57b5ca1c9f85d56.
Report an issue: GitHub.