quarkusio/quarkus · error · IllegalStateException

Only one server ErrorInterceptor is supported

Error message

Only one server ErrorInterceptor is supported

What it means

WebSocketTelemetryProviderBuilder allows exactly one server ErrorInterceptor provider. A second call to pathToServerErrorInterceptor() (i.e. a second telemetry/decorating provider attempting to install a server error interceptor) throws IllegalStateException, since composition is not implemented.

Source

Thrown at extensions/websockets-next/runtime/src/main/java/io/quarkus/websockets/next/runtime/telemetry/WebSocketTelemetryProviderBuilder.java:107

            var pathToInterceptor2 = this.pathToServerConnectionInterceptor;
            this.pathToServerConnectionInterceptor = new Function<>() {
                @Override
                public ConnectionInterceptor apply(String path) {
                    var interceptor1 = pathToInterceptor1.apply(path);
                    var interceptor2 = pathToInterceptor2.apply(path);
                    return new CompositeConnectionInterceptor(List.of(interceptor1, interceptor2));
                }
            };
        }
    }

    void pathToServerErrorInterceptor(Function<String, ErrorInterceptor> pathToServerErrorInterceptor) {
        Objects.requireNonNull(pathToServerErrorInterceptor);
        if (this.pathToServerErrorInterceptor == null) {
            this.pathToServerErrorInterceptor = pathToServerErrorInterceptor;
        } else {
            // we can implement composite if we need this in the future
            throw new IllegalStateException("Only one server ErrorInterceptor is supported");
        }
    }

    void pathToClientErrorInterceptor(Function<String, ErrorInterceptor> pathToClientErrorInterceptor) {
        Objects.requireNonNull(pathToClientErrorInterceptor);
        if (this.pathToClientErrorInterceptor == null) {
            this.pathToClientErrorInterceptor = pathToClientErrorInterceptor;
        } else {
            // we can implement composite if we need this in the future
            throw new IllegalStateException("Only one client ErrorInterceptor is supported");
        }
    }

    void pathToServerSendingInterceptor(Function<String, SendingInterceptor> pathToServerSendingInterceptor) {
        Objects.requireNonNull(pathToServerSendingInterceptor);
        if (this.pathToServerSendingInterceptor == null) {
            this.pathToServerSendingInterceptor = pathToServerSendingInterceptor;
        } else {

View on GitHub (pinned to e1c734241f)

Solutions

  1. Remove or disable one of the providers supplying a server ErrorInterceptor
  2. Merge the two interceptors into a single composite implementation of your own and register only that one
  3. Use quarkus.observability / telemetry config to disable one provider's interceptor

Example fix

// before
telemetryProviderBuilder.pathToServerErrorInterceptor(f1);
telemetryProviderBuilder.pathToServerErrorInterceptor(f2); // throws
// after
Function<String, ErrorInterceptor> composite = path -> msg -> {
    try { return f1.apply(path).handle(msg); }
    finally { f2.apply(path).handle(msg); }
};
telemetryProviderBuilder.pathToServerErrorInterceptor(composite);
Defensive patterns

Strategy: validation

Validate before calling

// check classpath for multiple telemetry providers before build
duplicateInterceptors.forEach(f -> checkOnlyOneRegistered());

Prevention

When it happens

Trigger: Registering two telemetry providers (or a provider plus a custom one) that both supply a server ErrorInterceptor — e.g. quarkus-websockets-next telemetry combined with opentelemetry and a custom ErrorInterceptor, or duplicate provider beans.

Common situations: Having both an OTel-based telemetry provider and a custom ErrorInterceptor on the classpath; multiple @ApplicationScoped beans implementing the provider extension point.

Related errors


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