Skip to content

Unstable test Http2Test.testHttpConnect, possibly due to garbage collected NetClient #5853

@ahus1

Description

@ahus1

Version

master

Context

The test sometimes fails, with a percentage of 20% (?) when running it locally in my IDE.
It also failed in the CI

See https://github.com/eclipse-vertx/vert.x/actions/runs/20429375873/job/58696486105

Steps to reproduce

Run the test.

When debugging this, I found that the following snippet connects to NetServer, but then disconnects immediately without sending any data. I assume that the NetClient is garbage collected.

I'll prepare a PR where this no longer happens by keeping a reference.

vertx.createNetServer(new NetServerOptions().setPort(1235).setHost("localhost")).connectHandler(socket -> {
socket.handler(socket::write);
closeSocket.thenAccept(v -> {
socket.close();
});
}).listen().onComplete(onSuccess(netServer -> {
server.requestHandler(req -> {
vertx.createNetClient(new NetClientOptions()).connect(1235, "localhost").onComplete(onSuccess(dst -> {
req.response().setStatusCode(sc);
req.response().setStatusMessage("Connection established");
// Now create a NetSocket
req.toNetSocket().onComplete(onSuccess(src -> {
// Create pumps which echo stuff
src.pipeTo(dst);
dst.pipeTo(src);
}));
}));
});

Do you have a reproducer?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions