quarkusio/quarkus · error · IllegalArgumentException

Segment parameter is null

Error message

Segment parameter is null

What it means

UriBuilderImpl.segment(segments) throws IllegalArgumentException("Segment parameter is null") when the segments varargs array itself is null (a distinct message from "Segment is null", which covers an individual null element). Path segments are required to construct a valid URI path.

Source

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

    public String getUserInfo() {
        return userInfo;
    }

    public String getPath() {
        return path;
    }

    public String getQuery() {
        return query;
    }

    public String getFragment() {
        return fragment;
    }

    public UriBuilder segment(String... segments) throws IllegalArgumentException {
        if (segments == null)
            throw new IllegalArgumentException("Segment parameter is null");
        for (String segment : segments) {
            if (segment == null)
                throw new IllegalArgumentException("Segment is null");
            path(Encode.encodePathSegment(segment));
        }
        return this;
    }

    public URI buildFromEncoded(Object... values) throws IllegalArgumentException, UriBuilderException {
        if (values == null)
            throw new IllegalArgumentException("Values is null");
        return buildFromValues(false, true, values);
    }

    public UriBuilder replacePath(String path) {
        if (path == null) {
            this.path = null;
            return this;

View on GitHub (pinned to e1c734241f)

Solutions

  1. Pass at least one non-null string or call a path-building method instead
  2. Guard: if (segments != null) builder.segment(segments)
  3. Initialize the segments array before use
  4. Default to an empty array for optional path parts

Example fix

// before
builder.segment(parts); // parts == null
// after
if (parts != null) builder.segment(parts);
Defensive patterns

Strategy: validation

Validate before calling

if (segments == null || Arrays.stream(segments).anyMatch(Objects::isNull)) { throw new IllegalArgumentException("segments must be non-null"); }

Type guard

boolean isValidSegments(String[] segments) { return segments != null && Arrays.stream(segments).allMatch(s -> s != null && !s.isEmpty()); }

Try / catch

try { builder.segment(segments); } catch (IllegalArgumentException e) { if (e.getMessage().contains("Segment")) { /* fix or skip segment list */ } else throw e; }

Prevention

When it happens

Trigger: Calling segment((String[]) null) or segment(someArray) where someArray is a null String[]/varargs array.

Common situations: Passing a path-parts array from parsed config or a split operation that returned null; varargs misuse where a single null literal becomes a null array.

Related errors


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