quarkusio/quarkus · error · IllegalArgumentException

URI is null

Error message

URI is null

What it means

UriBuilderImpl.uri(URI) throws 'URI is null' when the caller passes a null java.net.URI. The JAX-RS UriBuilder contract requires IllegalArgumentException for invalid arguments and null is treated as invalid. The guard fires before any URI component merging happens.

Source

Thrown at independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/UriBuilderImpl.java:250

        }
        if (match.group(7) != null)
            replaceQuery(match.group(7));
        if (match.group(9) != null)
            fragment(match.group(9));
        return this;
    }

    public UriBuilder uri(String uriTemplate) throws IllegalArgumentException {
        return uriTemplate(uriTemplate);
    }

    public UriBuilder uriFromCharSequence(CharSequence uriTemplate) throws IllegalArgumentException {
        return uriTemplate(uriTemplate);
    }

    public UriBuilder uri(URI uri) throws IllegalArgumentException {
        if (uri == null)
            throw new IllegalArgumentException("URI is null");

        if (uri.getRawFragment() != null)
            fragment = uri.getRawFragment();

        if (uri.isOpaque()) {
            scheme = uri.getScheme();
            ssp = uri.getRawSchemeSpecificPart();
            return this;
        }

        if (uri.getScheme() == null) {
            if (ssp != null) {
                if (uri.getRawSchemeSpecificPart() != null) {
                    ssp = uri.getRawSchemeSpecificPart();
                    return this;
                }
            }
        } else {

View on GitHub (pinned to e1c734241f)

Solutions

  1. Null-check before calling: if (uri != null) builder.uri(uri); else use a default
  2. Make the URI source throw on failure (URI.create) rather than return null
  3. Provide a fallback default URI when configuration is absent
  4. Fail fast with Objects.requireNonNull(uri, 'uri') at your call site

Example fix

// before: URI base = loadBaseUri(); // may return null; builder.uri(base) throws // after: URI base = loadBaseUri(); if (base == null) throw new IllegalStateException('base URI must be configured'); builder.uri(base);
Defensive patterns

Strategy: type-guard

Validate before calling

static URI nonNullUri(URI uri, URI fallback) {
    return uri != null ? uri : java.util.Objects.requireNonNull(fallback, 'no base URI configured');
}

Type guard

static boolean hasUri(URI uri) {
    return uri != null;
}

Try / catch

try {
    builder.uri(uri);
} catch (IllegalArgumentException e) {
    if (uri == null)
        throw new IllegalStateException('Base URI is not configured; check quarkus.rest-client settings', e);
    throw e;
}

Prevention

When it happens

Trigger: Calling builder.uri(null) directly, or passing a URI variable that is null because optional configuration was absent or a lookup/factory method returned null instead of throwing.

Common situations: REST client base URI read from optional config that is not set; factory methods returning null on failure; refactors that made a previously-validated URI field nullable.

Related errors


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