quarkusio/quarkus · error · IllegalArgumentException

param was null

Error message

param was null

What it means

LocaleDelegate.fromString(String) converts a Accept-Language/Content-Language style header value into a java.util.Locale via LocaleHelper.extractLocale. It rejects a null input with IllegalArgumentException("param was null") because the JAX-RS HeaderDelegate contract forbids null.

Source

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

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

import java.util.Locale;

import jakarta.ws.rs.ext.RuntimeDelegate;

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

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

    public Locale fromString(String value) throws IllegalArgumentException {
        if (value == null)
            throw new IllegalArgumentException("param was null");
        return LocaleHelper.extractLocale(value);
    }

    public String toString(Locale value) {
        if (value == null)
            throw new IllegalArgumentException("param was null");
        return LocaleHelper.toLanguageString(value);
    }

}

View on GitHub (pinned to e1c734241f)

Solutions

  1. Null-check the header value before parsing: if (raw != null) Locale l = delegate.fromString(raw).
  2. Default to Locale.ROOT or a configured fallback Locale when the header is absent.
  3. Catch IllegalArgumentException and fall back to the default locale.
  4. For manual parsing, use Locale.forLanguageTag(raw) after a null/empty check.

Example fix

// before
Locale locale = LocaleDelegate.INSTANCE.fromString(headers.getHeaderString("Content-Language")); // throws when absent
// after
String raw = headers.getHeaderString("Content-Language");
Locale locale = (raw == null || raw.isEmpty()) ? Locale.ROOT : LocaleDelegate.INSTANCE.fromString(raw);
Defensive patterns

Strategy: type-guard

Validate before calling

String raw = headers.getHeaderString("Accept-Language");
if (raw == null || raw.isBlank()) raw = "en"; // or Locale.ROOT default

Type guard

Locale safeLocale(String value) {
    return value == null || value.isBlank() ? Locale.ROOT : Locale.forLanguageTag(value);
}

Try / catch

try {
    Locale locale = LocaleDelegate.INSTANCE.fromString(raw);
} catch (IllegalArgumentException e) {
    Locale locale = Locale.ROOT;
}

Prevention

When it happens

Trigger: Calling LocaleDelegate.INSTANCE.fromString(null) directly, or RESTEasy Reactive deserializing a Locale-typed header/parameter whose value is null.

Common situations: Reading the Content-Language or Accept-Language header that is not present (getHeaderString returns null) and passing it straight to the delegate; tests passing null.

Related errors


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