quarkusio/quarkus · error · IllegalArgumentException
Cookie value was null
Error message
Cookie value was null
What it means
CookieParser.parseCookies throws IllegalArgumentException when the Cookie header string passed in is null. It is a strict precondition check: parsing cannot proceed without a header value. Callers are expected to treat a missing Cookie header as 'no cookies' rather than passing null.
Source
Thrown at independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/util/CookieParser.java:11
package org.jboss.resteasy.reactive.common.util;
import java.util.ArrayList;
import java.util.List;
import jakarta.ws.rs.core.Cookie;
public class CookieParser {
public static List<Cookie> parseCookies(String cookieHeader) {
if (cookieHeader == null) {
throw new IllegalArgumentException("Cookie value was null");
}
// cookie headers can be separated by "," (HTTP header separator), or ";" (Cookie separator)
// FIXME: the current cookie RFC doesn't mention params for cookies sent by the client
// doesn't mention $ as a prefix either
// FIXME: make this faster if we have a single cookie
try {
List<Cookie> cookies = new ArrayList<>();
int version = 0;
String domain = null;
String path = null;
String cookieName = null;
String cookieValue = null;
String[] parts = cookieHeader.split("[;,]");
for (String part : parts) {
String[] nv = part.split("=", 2);
String name = nv.length > 0 ? nv[0].trim() : "";View on GitHub (pinned to e1c734241f)
Solutions
- Null-check the header value before calling parseCookies and return an empty list instead
- Use the framework's request.getCookies() (Jakarta REST HttpHeaders) which handles absence gracefully
- Wrap the call and convert IllegalArgumentException to an empty result if null is expected in your context
Example fix
// before
List<Cookie> cookies = CookieParser.parseCookies(request.getHeader("Cookie"));
// after
String header = request.getHeader("Cookie");
List<Cookie> cookies = header == null ? List.of() : CookieParser.parseCookies(header); Defensive patterns
Strategy: validation
Validate before calling
String cookieHeader = request.getHeader("Cookie");
List<Cookie> cookies = cookieHeader == null ? List.of() : CookieParser.parseCookies(cookieHeader); Type guard
List<Cookie> safeParseCookies(String header) { return header == null ? List.of() : CookieParser.parseCookies(header); } Try / catch
List<Cookie> cookies;
try {
cookies = CookieParser.parseCookies(header);
} catch (IllegalArgumentException e) {
cookies = List.of(); // no Cookie header sent
} Prevention
- Treat a missing Cookie header as an empty list, never pass null
- Prefer HttpHeaders.getCookies() over manual parsing when available
- Wrap header-parsing utilities with null-safe helpers
When it happens
Trigger: Calling CookieParser.parseCookies(null), typically after getHeader("Cookie") returned null on a request with no Cookie header.
Common situations: Server-side header parsing where the incoming request has no cookies; utility code that forwards header values without a null check.
Related errors
- Different array length
- File does not exist: ${file}
- File is not a regular file: ${file}
- File cannot be read: ${file}
- Offset (${offset}) must be >= 0: ${file}
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/19f92ef2f88a65f4.
Report an issue: GitHub.