quarkusio/quarkus · error · java.lang.NullPointerException

Param was null

Error message

Param was null

What it means

WebTargetImpl.path(String) throws this NullPointerException when the path argument is null, per the JAX-RS WebTarget contract. The client aborts URI building early rather than producing a malformed target.

Source

Thrown at independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/WebTargetImpl.java:101

        abortIfClosed();
        return uriBuilder.clone();
    }

    public UriBuilderImpl getUriBuilderUnsafe() {
        return (UriBuilderImpl) uriBuilder;
    }

    @Override
    public ConfigurationImpl getConfiguration() {
        abortIfClosed();
        return configuration;
    }

    @Override
    public WebTargetImpl path(String path) throws NullPointerException {
        abortIfClosed();
        if (path == null)
            throw new NullPointerException("Param was null");
        UriBuilder copy = uriBuilder.clone().path(path);
        return newInstance(client, copy, configuration);
    }

    @Override
    public WebTargetImpl resolveTemplate(String name, Object value) throws NullPointerException {
        abortIfClosed();
        if (name == null)
            throw new NullPointerException("Param was null");
        if (value == null)
            throw new NullPointerException("Param was null");
        String val = configuration.toString(value);
        UriBuilder copy = uriBuilder.clone().resolveTemplate(name, val);
        WebTargetImpl target = newInstance(client, copy, configuration);
        return target;
    }

    @Override

View on GitHub (pinned to e1c734241f)

Solutions

  1. Ensure the path value is non-null before calling path() (supply a default or require the config property)
  2. Use a constant/validated base path instead of a possibly-null variable
  3. Null-check and skip the path() call when the segment is optional

Example fix

// before
webTarget.path(config.getBasePath()); // getBasePath() may be null
// after
String basePath = config.getBasePath();
if (basePath != null) {
    webTarget = webTarget.path(basePath);
}
Defensive patterns

Strategy: validation

Validate before calling

Objects.requireNonNull(path, "path must not be null before webTarget.path()");
webTarget = webTarget.path(path);

Type guard

String safePath(String p) {
    return p == null ? "" : p; // or throw earlier with a clearer message
}

Try / catch

try {
    target = target.path(path);
} catch (NullPointerException e) {
    if ("Param was null".equals(e.getMessage())) {
        throw new IllegalStateException("Path segment was null; check configuration/parameters", e);
    } else throw e;
}

Prevention

When it happens

Trigger: Calling webTarget.path(null) directly, or passing a null path variable / unset configuration value into the path building chain (e.g. path(config.getPath()) where the property was missing).

Common situations: Optional @ConfigProperty or system property not set, yielding null; a method parameter that callers may leave null; string concatenation refactors that make a previously defaulted value null.

Related errors


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