#57081·quarkus

WebSockets Next: BasicWebSocketConnector adds a '/' to the base URI path when no path is set

Author: CrowayCreated Oct 1, 2026Updated Oct 1, 2026
Labelsarea/websockets

Describe the bug

connect() builds the request path with mergePath(baseUri.getPath(), replacePathParameters(path)). With the default empty path, mergePath appends "/" + "", so baseUri("ws://host/v1/connect?id=1") requests /v1/connect/?id=1.

Expected behavior

The request path is the base URI path as given: /v1/connect?id=1.

Actual behavior

/v1/connect/?id=1. Servers matching the path exactly reject the upgrade or route it elsewhere.

How to Reproduce?

Test for extensions/websockets-next/deployment/src/test/java/io/quarkus/websockets/next/test/client/ (fails on 3.40.1 with expected: "/v1/connect?id=1" but was: "/v1/connect/?id=1"):

java
package io.quarkus.websockets.next.test.client;

import static org.assertj.core.api.Assertions.assertThat;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;

import jakarta.inject.Inject;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.test.QuarkusExtensionTest;
import io.quarkus.websockets.next.BasicWebSocketConnector;
import io.vertx.core.Vertx;
import io.vertx.core.http.HttpServer;

public class BasicConnectorBaseUriPathTest {

    @RegisterExtension
    public static final QuarkusExtensionTest test = new QuarkusExtensionTest()
            .withApplicationRoot(root -> {
            });

    @Inject
    Vertx vertx;

    @Inject
    BasicWebSocketConnector connector;

    @Test
    void sendsTheBaseUriPathAsGivenWhenNoPathIsSet() throws Exception {
        CompletableFuture<String> requestUri = new CompletableFuture<>();
        HttpServer server = vertx.createHttpServer()
                .webSocketHandler(ws -> requestUri.complete(ws.uri()))
                .listen(0).toCompletionStage().toCompletableFuture().get(10, TimeUnit.SECONDS);
        try {
            connector.baseUri("ws://localhost:" + server.actualPort() + "/v1/connect?id=1")
                    .connectAndAwait();

            assertThat(requestUri.get(10, TimeUnit.SECONDS)).isEqualTo("/v1/connect?id=1");
        } finally {
            server.close().toCompletionStage().toCompletableFuture().get(10, TimeUnit.SECONDS);
        }
    }
}

Output of uname -a or ver

Darwin 27.0.0

Output of java -version

openjdk 25.0.2 (Temurin)

Quarkus version or git rev

3.40.1 (same code on main at cd8646d2438)

Build tool (ie. output of mvnw --version or gradlew --version)

Maven 3.9.16

Additional information

Not appending anything in mergePath when the second path is empty makes the test pass. Workaround: pass the last path segment with path(...).