{"record":{"id":"d57b5ca1c9f85d56","repo":"quarkusio/quarkus","slug":"param-cannot-be-null","errorCode":null,"errorMessage":"Param cannot be null","messagePattern":"Param cannot be null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/jaxrs/RequestImpl.java","lineNumber":155,"sourceCode":"            return null;\n        }\n        return Response.status(Response.Status.PRECONDITION_FAILED).lastModified(lastModified);\n\n    }\n\n    /**\n     * We must compare header dates (seconds-precision) with dates that have the same precision,\n     * otherwise they may include milliseconds and they will never match the Last-Modified\n     * values that we generate from them (since we drop their milliseconds when we write the headers)\n     */\n    private long millisecondsWithSecondsPrecision(Date lastModified) {\n        return (lastModified.getTime() / 1000) * 1000;\n    }\n\n    @Override\n    public Response.ResponseBuilder evaluatePreconditions(Date lastModified) {\n        if (lastModified == null)\n            throw new IllegalArgumentException(\"Param cannot be null\");\n        Response.ResponseBuilder builder = null;\n        MultivaluedMap<String, String> headers = requestContext.getHttpHeaders().getRequestHeaders();\n        String ifModifiedSince = headers.getFirst(HttpHeaders.IF_MODIFIED_SINCE);\n        if (ifModifiedSince != null && (!isRfc7232preconditions() || (!headers.containsKey(HttpHeaders.IF_NONE_MATCH)))) {\n            builder = ifModifiedSince(ifModifiedSince, lastModified);\n        }\n        if (builder == null) {\n            String ifUnmodifiedSince = headers.getFirst(HttpHeaders.IF_UNMODIFIED_SINCE);\n            if (ifUnmodifiedSince != null && (!isRfc7232preconditions() || (!headers.containsKey(HttpHeaders.IF_MATCH)))) {\n                builder = ifUnmodifiedSince(ifUnmodifiedSince, lastModified);\n            }\n        }\n        if (builder != null && varyHeader != null)\n            builder.header(HttpHeaders.VARY, varyHeader);\n\n        return builder;\n    }\n","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/jaxrs/RequestImpl.java#L137-L173","documentation":"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.","triggerScenarios":"Calling request.evaluatePreconditions(Date) with a null Date — e.g. the resource's modification timestamp was never set or the lookup returned null.","commonSituations":"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.","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."],"exampleFix":"// before\nResponse.ResponseBuilder rb = request.evaluatePreconditions(lastModified); // may be null\n// after\nResponse.ResponseBuilder rb = lastModified != null\n    ? request.evaluatePreconditions(lastModified)\n    : request.evaluatePreconditions();","handlingStrategy":"type-guard","validationCode":"if (lastModified == null) {\n    return request.evaluatePreconditions();\n}","typeGuard":"boolean hasTimestamp(Date d) {\n    return d != null;\n}","tryCatchPattern":"try {\n    return request.evaluatePreconditions(lastModified);\n} catch (IllegalArgumentException e) {\n    return request.evaluatePreconditions();\n}","preventionTips":["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"],"tags":["jaxrs","resteasy-reactive","last-modified","conditional-request"],"backgroundTag":"null-last-modified-precondition","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}