{"record":{"id":"1b07ddd25388d781","repo":"quarkusio/quarkus","slug":"param-was-null-1b07dd","errorCode":null,"errorMessage":"param was null","messagePattern":"param was null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/headers/LocaleDelegate.java","lineNumber":17,"sourceCode":"package org.jboss.resteasy.reactive.common.headers;\n\nimport java.util.Locale;\n\nimport jakarta.ws.rs.ext.RuntimeDelegate;\n\nimport org.jboss.resteasy.reactive.common.util.LocaleHelper;\n\n/**\n * @author <a href=\"mailto:bill@burkecentral.com\">Bill Burke</a>\n */\npublic class LocaleDelegate implements RuntimeDelegate.HeaderDelegate<Locale> {\n    public static final LocaleDelegate INSTANCE = new LocaleDelegate();\n\n    public Locale fromString(String value) throws IllegalArgumentException {\n        if (value == null)\n            throw new IllegalArgumentException(\"param was null\");\n        return LocaleHelper.extractLocale(value);\n    }\n\n    public String toString(Locale value) {\n        if (value == null)\n            throw new IllegalArgumentException(\"param was null\");\n        return LocaleHelper.toLanguageString(value);\n    }\n\n}\n","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/headers/LocaleDelegate.java#L1-L28","documentation":"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.","triggerScenarios":"Calling LocaleDelegate.INSTANCE.fromString(null) directly, or RESTEasy Reactive deserializing a Locale-typed header/parameter whose value is null.","commonSituations":"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.","solutions":["Null-check the header value before parsing: if (raw != null) Locale l = delegate.fromString(raw).","Default to Locale.ROOT or a configured fallback Locale when the header is absent.","Catch IllegalArgumentException and fall back to the default locale.","For manual parsing, use Locale.forLanguageTag(raw) after a null/empty check."],"exampleFix":"// before\nLocale locale = LocaleDelegate.INSTANCE.fromString(headers.getHeaderString(\"Content-Language\")); // throws when absent\n// after\nString raw = headers.getHeaderString(\"Content-Language\");\nLocale locale = (raw == null || raw.isEmpty()) ? Locale.ROOT : LocaleDelegate.INSTANCE.fromString(raw);","handlingStrategy":"type-guard","validationCode":"String raw = headers.getHeaderString(\"Accept-Language\");\nif (raw == null || raw.isBlank()) raw = \"en\"; // or Locale.ROOT default","typeGuard":"Locale safeLocale(String value) {\n    return value == null || value.isBlank() ? Locale.ROOT : Locale.forLanguageTag(value);\n}","tryCatchPattern":"try {\n    Locale locale = LocaleDelegate.INSTANCE.fromString(raw);\n} catch (IllegalArgumentException e) {\n    Locale locale = Locale.ROOT;\n}","preventionTips":["Null-check header values before invoking header delegates","Provide a default Locale fallback for missing language headers","Prefer Locale.forLanguageTag with an empty-tag default for manual parsing"],"tags":["null-check","jaxrs","http-headers","locale"],"backgroundTag":"null-argument","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}