quarkusio/quarkus · warning · IllegalArgumentException
param was null
Error message
param was null
What it means
CacheControlDelegate.toString(CacheControl) serializes a CacheControl object into a Cache-Control header string. The JAX-RS HeaderDelegate contract mandates IllegalArgumentException when the object to serialize is null.
Source
Thrown at independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/headers/CacheControlDelegate.java:84
} else {
if (val == null)
val = "";
result.getCacheExtension().put(name, val);
}
}
return result;
}
private static StringBuilder addDirective(String directive, StringBuilder buffer) {
if (buffer.length() > 0)
buffer.append(", ");
buffer.append(directive);
return buffer;
}
public String toString(CacheControl value) {
if (value == null)
throw new IllegalArgumentException("param was null");
StringBuilder buffer = new StringBuilder();
if (value.isNoCache()) {
List<String> fields = value.getNoCacheFields();
if (fields.size() < 1) {
addDirective("no-cache", buffer);
} else {
for (String field : value.getNoCacheFields()) {
addDirective("no-cache", buffer).append("=\"").append(field).append("\"");
}
}
}
if (value instanceof ExtendedCacheControl) {
ExtendedCacheControl ecc = (ExtendedCacheControl) value;
if (ecc.isPublic()) {
addDirective("public", buffer);
}
}
if (value.isMustRevalidate())View on GitHub (pinned to e1c734241f)
Solutions
- Null-check the CacheControl before serializing and skip setting the header when null
- Initialize a default CacheControl (e.g. new CacheControl()) instead of leaving null
- Use Optional<CacheControl> and only write the header if present
- Fix the code path that produces the null object
Example fix
// before
String header = CacheControlDelegate.INSTANCE.toString(cacheControl); // NPE-style failure on null
// after
if (cacheControl != null) {
response.header("Cache-Control", CacheControlDelegate.INSTANCE.toString(cacheControl));
} Defensive patterns
Strategy: type-guard
Validate before calling
if (cacheControl == null) { /* skip setting header */ } Type guard
boolean isSerializable(CacheControl cc) { return cc != null; } Try / catch
try {
String h = CacheControlDelegate.INSTANCE.toString(cc);
} catch (IllegalArgumentException e) {
// null CacheControl; omit header or substitute default
} Prevention
- Initialize CacheControl objects before serialization
- Skip header emission when the object is null
- Use Optional<CacheControl> in header-building code
When it happens
Trigger: Passing a null CacheControl to CacheControlDelegate.INSTANCE.toString(null), e.g. when building a response header from a value that failed to initialize.
Common situations: Cache-control settings loaded from config that resolved to null; conditional header-building code that forgot the null case; unit tests exercising the delegate with null.
Related errors
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/7d062e5501a9f804.
Report an issue: GitHub.