Skip to content

When releasing request in the request Proxy handler and returning a failed future, program timesout #141

@mskacelik

Description

@mskacelik

Version

5.0.7 and 4.5.24

Context

When returning a Failed Future within the interceptor (after the request.release()) I expect to get a 502, not a timeout.
OS: Tahoe 26.2
JVM: openjdk version "21.0.9" 2025-10-21 LTS

Steps to reproduce

Reproducer written in jbang.
Uncomment the line with resource release.

//DEPS io.vertx:vertx-core:5.0.7
//DEPS io.vertx:vertx-http-proxy:5.0.7

import io.vertx.core.Future;
import io.vertx.core.Vertx;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.HttpClient;
import io.vertx.core.http.HttpServer;
import io.vertx.core.http.HttpMethod;
import io.vertx.httpproxy.Body;
import io.vertx.httpproxy.HttpProxy;
import io.vertx.httpproxy.ProxyContext;
import io.vertx.httpproxy.ProxyInterceptor;
import io.vertx.httpproxy.ProxyRequest;
import io.vertx.httpproxy.ProxyResponse;

public class reproducer {

    public static void main(String[] args) {
        Vertx vertx = Vertx.vertx();
        HttpClient client = vertx.createHttpClient();

        HttpProxy proxy = HttpProxy.reverseProxy(client).origin(7070, "localhost");

        proxy.addInterceptor(new ProxyInterceptor() {
            @Override
            public Future<ProxyResponse> handleProxyRequest(ProxyContext context) {
                System.out.println("Interceptor triggered...");
                // when uncommented it will timeout
                // context.request().release();
                return Future.failedFuture("");
            }
        });

        // automatic request when server is ready
        vertx.createHttpServer()
                .requestHandler(proxy)
                .listen(8080)
                .onComplete(res -> {
                    if (res.succeeded()) {
                        System.out.println("Proxy listening on port 8080. Testing...");
                        client.request(HttpMethod.GET, 8080, "localhost", "/")
                                .compose(request -> request.send())
                                .onComplete(ar -> {
                                    if (ar.succeeded()) {
                                        ar.result().body().onSuccess(body -> {
                                            System.out.println("Response Status: " + ar.result().statusCode());
                                            vertx.close();
                                        });
                                    } else {
                                        ar.cause().printStackTrace();
                                        vertx.close();
                                    }
                                });
                    } else {
                        res.cause().printStackTrace();
                        vertx.close();
                    }
                });
    }
}

Do you have a reproducer?

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions