{"record":{"id":"de4a50feca8b4a44","repo":"quarkusio/quarkus","slug":"value-is-null-de4a50","errorCode":null,"errorMessage":"Value is null","messagePattern":"Value is null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/UriBuilderImpl.java","lineNumber":766,"sourceCode":"            return new URI(buf);\n            //return URI.create(buf);\n        } catch (IllegalArgumentException iae) {\n            throw iae;\n        } catch (Exception e) {\n            throw new UriBuilderException(\"failed to create URI\", e);\n        }\n    }\n\n    public UriBuilder matrixParam(String name, Object... values) throws IllegalArgumentException {\n        if (name == null)\n            throw new IllegalArgumentException(\"Name parameter is null\");\n        if (values == null)\n            throw new IllegalArgumentException(\"Values parameter is null\");\n        if (path == null)\n            path = \"\";\n        for (Object val : values) {\n            if (val == null)\n                throw new IllegalArgumentException(\"Value is null\");\n            String matrixName = encode ? Encode.encodeMatrixParam(name) : name;\n            String matrixValue = encode ? Encode.encodeMatrixParam(val.toString()) : val.toString();\n            path += \";\" + matrixName + \"=\" + matrixValue;\n        }\n        return this;\n    }\n\n    private static final Pattern PARAM_REPLACEMENT = Pattern.compile(\"_resteasy_uri_parameter\");\n\n    public UriBuilder replaceMatrixParam(String name, Object... values) throws IllegalArgumentException {\n        if (name == null)\n            throw new IllegalArgumentException(\"Name parameter is null\");\n        if (path == null) {\n            if (values != null && values.length > 0)\n                return matrixParam(name, values);\n            return this;\n        }\n","sourceCodeStart":748,"sourceCodeEnd":784,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/UriBuilderImpl.java#L748-L784","documentation":"UriBuilderImpl.matrixParam(name, values) rejects any null element inside the varargs values array by throwing IllegalArgumentException(\"Value is null\"). RESTEasy Reactive follows the JAX-RS UriBuilder contract, which does not permit null matrix parameter values, so each value is eagerly validated before encoding and appending to the path.","triggerScenarios":"Calling matrixParam(name, v1, v2, ...) where the values array itself is fine but at least one element is null, e.g. matrixParam(\"m\", null) or matrixParam(\"opts\", flagA, flagB) with flagB == null.","commonSituations":"Building a URI from optional fields (query results, config values, DTO fields) where some optional values are null and are passed straight into matrixParam instead of being filtered or defaulted first.","solutions":["Filter nulls before calling: Arrays.stream(values).filter(Objects::nonNull).toArray()","Use a default value for optional fields before building the URI","Skip the matrixParam call entirely when all values are null","Wrap in try-catch for IllegalArgumentException if nulls are expected and tolerable"],"exampleFix":"// before\nUriBuilder.fromPath(\"/items\").matrixParam(\"sort\", sortBy, direction); // direction may be null\n// after\nUriBuilder.fromPath(\"/items\").matrixParam(\"sort\", Arrays.stream(new Object[]{sortBy, direction}).filter(Objects::nonNull).toArray());","handlingStrategy":"validation","validationCode":"if (values == null || Arrays.stream(values).anyMatch(Objects::isNull)) { throw new IllegalArgumentException(\"matrixParam values must not contain nulls\"); }","typeGuard":"boolean hasNoNulls(Object[] arr) { return arr != null && Arrays.stream(arr).noneMatch(Objects::isNull); }","tryCatchPattern":"try { builder.matrixParam(name, values); } catch (IllegalArgumentException e) { if (!e.getMessage().contains(\"null\")) throw e; /* handle null value: filter and retry */ }","preventionTips":["Filter null elements with Objects::nonNull before passing varargs","Never pass Optional.get()/nullable fields directly into UriBuilder value arrays","Sanitize collections when populating them, not at the UriBuilder call site","Add unit tests for URI building with optional/absent values"],"tags":["jaxrs","uribuilder","null-check","resteasy-reactive"],"backgroundTag":"null-argument-validation","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"}