quarkusio/quarkus · warning · IllegalArgumentException

Param was null

Error message

Param was null

What it means

CacheControlDelegate is the JAX-RS RuntimeDelegate HeaderDelegate that parses a Cache-Control HTTP header from its string form. The JAX-RS contract requires an IllegalArgumentException for null input, so fromString(null) throws this error instead of returning null.

Source

Thrown at independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/headers/CacheControlDelegate.java:18

package org.jboss.resteasy.reactive.common.headers;

import java.util.List;

import jakarta.ws.rs.core.CacheControl;
import jakarta.ws.rs.ext.RuntimeDelegate;

import org.jboss.resteasy.reactive.common.util.ExtendedCacheControl;

/**
 * @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
 */
public class CacheControlDelegate implements RuntimeDelegate.HeaderDelegate<CacheControl> {
    public static final CacheControlDelegate INSTANCE = new CacheControlDelegate();

    public CacheControl fromString(String value) throws IllegalArgumentException {
        if (value == null)
            throw new IllegalArgumentException("Param was null");
        ExtendedCacheControl result = new ExtendedCacheControl();
        result.setNoTransform(false);

        String[] directives = value.split(",");
        for (String directive : directives) {
            directive = directive.trim();

            String[] nv = directive.split("=");
            String name = nv[0].trim();
            String val = null;
            if (nv.length > 1) {
                val = nv[1].trim();
                if (val.startsWith("\""))
                    val = val.substring(1);
                if (val.endsWith("\""))
                    val = val.substring(0, val.length() - 1);
            }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Check for null before calling fromString and handle absence explicitly
  2. Default the value to an empty/sensible string if the header is optional
  3. Use Map.getOrDefault(headers, "Cache-Control", "") style lookups
  4. Fix upstream code so it never passes null header values into the delegate

Example fix

// before
CacheControl cc = CacheControlDelegate.INSTANCE.fromString(headers.getFirst("Cache-Control"));
// after
String value = headers.getFirst("Cache-Control");
CacheControl cc = value == null ? null : CacheControlDelegate.INSTANCE.fromString(value);
Defensive patterns

Strategy: type-guard

Validate before calling

if (value == null || value.isBlank()) { /* skip header parsing */ }

Type guard

boolean isParsableHeader(String v) { return v != null && !v.isEmpty(); }

Try / catch

try {
    CacheControl cc = CacheControlDelegate.INSTANCE.fromString(value);
} catch (IllegalArgumentException e) {
    // null or malformed header; treat as absent
}

Prevention

When it happens

Trigger: Passing a null header string to CacheControlDelegate.INSTANCE.fromString(null), directly or via RuntimeDelegate/RESTEasy Reactive header parsing when a Cache-Control header value is unexpectedly absent.

Common situations: Manually parsing header maps where the header key exists but value is null; framework code invoking the delegate with a missing header value; interceptors reading Cache-Control of responses that never set it.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/59615e5c07e660eb. Report an issue: GitHub.