quarkusio/quarkus · error · IllegalArgumentException
Value is null
Error message
Value is null
What it means
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.
Source
Thrown at independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/UriBuilderImpl.java:766
return new URI(buf);
//return URI.create(buf);
} catch (IllegalArgumentException iae) {
throw iae;
} catch (Exception e) {
throw new UriBuilderException("failed to create URI", e);
}
}
public UriBuilder matrixParam(String name, Object... values) throws IllegalArgumentException {
if (name == null)
throw new IllegalArgumentException("Name parameter is null");
if (values == null)
throw new IllegalArgumentException("Values parameter is null");
if (path == null)
path = "";
for (Object val : values) {
if (val == null)
throw new IllegalArgumentException("Value is null");
String matrixName = encode ? Encode.encodeMatrixParam(name) : name;
String matrixValue = encode ? Encode.encodeMatrixParam(val.toString()) : val.toString();
path += ";" + matrixName + "=" + matrixValue;
}
return this;
}
private static final Pattern PARAM_REPLACEMENT = Pattern.compile("_resteasy_uri_parameter");
public UriBuilder replaceMatrixParam(String name, Object... values) throws IllegalArgumentException {
if (name == null)
throw new IllegalArgumentException("Name parameter is null");
if (path == null) {
if (values != null && values.length > 0)
return matrixParam(name, values);
return this;
}
View on GitHub (pinned to e1c734241f)
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
Example fix
// before
UriBuilder.fromPath("/items").matrixParam("sort", sortBy, direction); // direction may be null
// after
UriBuilder.fromPath("/items").matrixParam("sort", Arrays.stream(new Object[]{sortBy, direction}).filter(Objects::nonNull).toArray()); Defensive patterns
Strategy: validation
Validate before calling
if (values == null || Arrays.stream(values).anyMatch(Objects::isNull)) { throw new IllegalArgumentException("matrixParam values must not contain nulls"); } Type guard
boolean hasNoNulls(Object[] arr) { return arr != null && Arrays.stream(arr).noneMatch(Objects::isNull); } Try / catch
try { builder.matrixParam(name, values); } catch (IllegalArgumentException e) { if (!e.getMessage().contains("null")) throw e; /* handle null value: filter and retry */ } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/de4a50feca8b4a44.
Report an issue: GitHub.