Skip to content

Keep the NetClient referenced in tests that rely on the connection staying open - #6317

Open
jnbdz wants to merge 1 commit into
eclipse-vertx:masterfrom
SiteNetSoft:issue-6218-flaky-unreferenced-clients
Open

Keep the NetClient referenced in tests that rely on the connection staying open#6317
jnbdz wants to merge 1 commit into
eclipse-vertx:masterfrom
SiteNetSoft:issue-6218-flaky-unreferenced-clients

Conversation

@jnbdz

@jnbdz jnbdz commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Motivation

Http2Test#testSslHandshakeTimeout is listed in #6218 as failing in 4 out of 60 CI runs with Timeout Unsatisfied checkpoint.

The test opens a connection with vertx.createNetClient().connect(...).await(), keeps neither the client nor the socket referenced and returns, then the checkpoint waits for the server to report handshake timed out after 1234ms. Since a client that is no longer referenced is closed when it is garbage collected, under memory pressure the connection is closed before the handshake timeout happens: the server sees a plain close, never reports the SSLHandshakeException, and the checkpoint is never satisfied. Adding a System.gc() loop after the connect reproduces the CI failure deterministically:

java.util.concurrent.TimeoutException: Unsatisfied checkpoint

HttpConnectionEarlyResetTest#testExceptionCaught has the same pattern: it expects a connection reset (SO_LINGER=0) two seconds after connecting, but a client closed by the garbage collector closes the connection gracefully instead and the latch never counts down.

Changes

Keep the NetClient in a field in both tests so it stays referenced for the duration of the test (test-only change). Http2Test#testSslHandshakeTimeout passes with the forced garbage collection in place once the client is referenced.

Related to #6218.

…aying open

Motivation:

Http2Test#testSslHandshakeTimeout is listed in eclipse-vertx#6218 as failing in 4 out of
60 CI runs with an unsatisfied checkpoint. The test connects with an
unreferenced NetClient and returns, then waits for the server to report the
handshake timeout. A client that is no longer referenced is closed when it is
garbage collected, so under memory pressure the connection is closed before
the handshake timeout happens and the server never reports it. Forcing a
garbage collection after the connect reproduces the CI failure every time.

HttpConnectionEarlyResetTest#testExceptionCaught has the same pattern: it
expects a connection reset two seconds after connecting, a client closed by
the garbage collector closes the connection gracefully instead.

Changes:

Keep the NetClient in a field in both tests so that it stays referenced for
the duration of the test.

@tsegismont tsegismont left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you

@tsegismont

Copy link
Copy Markdown
Member

Please rebase and run mvn spotless:apply to apply formatting changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants