quarkusio/quarkus · warning · IllegalArgumentException

null max age

Error message

null max age

What it means

When parsing a Cache-Control header, the delegate found a 'max-age' directive but no '=' value following it (e.g. 'max-age' alone or 'max-age='), which is malformed per the HTTP spec, so it throws IllegalArgumentException.

Source

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

                    val = val.substring(0, val.length() - 1);
            }

            String lowercase = name.toLowerCase();
            if ("no-cache".equals(lowercase)) {
                result.setNoCache(true);
                if (val != null && !"".equals(val)) {
                    result.getNoCacheFields().add(val);
                }
            } else if ("private".equals(lowercase)) {
                result.setPrivate(true);
                if (val != null && !"".equals(val)) {
                    result.getPrivateFields().add(val);
                }
            } else if ("no-store".equals(lowercase)) {
                result.setNoStore(true);
            } else if ("max-age".equals(lowercase)) {
                if (val == null)
                    throw new IllegalArgumentException("null max age");
                result.setMaxAge(Integer.valueOf(val));
            } else if ("s-maxage".equals(lowercase)) {
                if (val == null)
                    throw new IllegalArgumentException("null s-maxage");
                result.setSMaxAge(Integer.valueOf(val));
            } else if ("no-transform".equals(lowercase)) {
                result.setNoTransform(true);
            } else if ("must-revalidate".equals(lowercase)) {
                result.setMustRevalidate(true);
            } else if ("proxy-revalidate".equals(lowercase)) {
                result.setProxyRevalidate(true);
            } else if ("public".equals(lowercase)) {
                result.setPublic(true);
            } else {
                if (val == null)
                    val = "";
                result.getCacheExtension().put(name, val);
            }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Correct the header to include a value: max-age=3600
  2. Sanitize/validate the header string before parsing
  3. Fix the server/proxy/CDN configuration producing the malformed directive
  4. Catch IllegalArgumentException and treat as no-cache or ignore the header

Example fix

// before
Cache-Control: no-cache, max-age
// after
Cache-Control: no-cache, max-age=3600
Defensive patterns

Strategy: validation

Validate before calling

if (directive.startsWith("max-age") && !directive.matches("max-age=\\d+")) { throw new IllegalArgumentException("max-age requires a numeric value: " + directive); }

Try / catch

try {
    CacheControl cc = CacheControlDelegate.INSTANCE.fromString(headerValue);
} catch (IllegalArgumentException e) {
    if (e.getMessage().contains("max age")) { /* fallback: treat as no caching directives */ }
}

Prevention

When it happens

Trigger: A Cache-Control header string containing 'max-age' with no value, e.g. 'Cache-Control: no-cache, max-age' or 'max-age=' passed to CacheControlDelegate.fromString.

Common situations: Misconfigured CDN/proxy emitting valueless max-age; hand-written header strings missing the seconds value; template/config errors generating cache headers.

Related errors


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