Skip to content

Document that clients must be kept referenced to avoid being shut down when garbage collected - #6318

Merged
tsegismont merged 1 commit into
eclipse-vertx:masterfrom
SiteNetSoft:docs-client-lifecycle
Aug 25, 2026
Merged

Document that clients must be kept referenced to avoid being shut down when garbage collected#6318
tsegismont merged 1 commit into
eclipse-vertx:masterfrom
SiteNetSoft:docs-client-lifecycle

Conversation

@jnbdz

@jnbdz jnbdz commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Motivation

HttpClient, NetClient and WebSocketClient are lightweight proxies (CleanableHttpClient, CleanableNetClient, CleanableWebSocketClient) that are shut down when they are garbage collected. This is intentional, but it is not mentioned anywhere in the documentation, and users who create a client inline without keeping a reference to it regularly observe connections closed unexpectedly, requests refused with Client is closed, or WebSocket handshakes aborted, and report it as a bug: #5839 (WebSocket handshake), #5916 and #5987 (TCP / unpooled HTTP connections), #5577 (Pool closed). Even the test suite has been bitten (#5853, #6317).

Changes

Docs only.

  • http.adoc, "Creating an HTTP client": IMPORTANT admonition explaining that a client must stay referenced for as long as it is used, that an unreferenced client is shut down when garbage collected as if HttpClient#shutdown() had been called (new requests refused, connections closed), the failures this surfaces as, and where to keep the reference.
  • http.adoc, "WebSockets on the client": the same note, mentioning that WebSockets with a handshake in progress are closed as well.
  • tcp.adoc, "Creating a TCP client": the same note pointing at NetClient#shutdown() and the existing "TCP graceful shut down" section (sockets without a shutdown handler are closed immediately).

While there, in the WebSocket client section:

  • fixed two truncated sentences (e Vert.x ...The Vert.x ..., en connecting ...When connecting ...) and stray leading spaces;
  • the clientWebSocketConfigurationAndConnect example block was indented by one space, so it was rendered as a literal paragraph rather than a source block; it now renders as [source,java].

Verified with mvn compile (docgen): the generated http.adoc / tcp.adoc contain the admonitions with resolved API links and the fixed source block.

…n when garbage collected

Motivation:

HTTP, TCP and WebSocket clients are lightweight proxies that are shut down
when they are garbage collected. Users creating a client inline, without
keeping a reference to it, observe connections closed unexpectedly, requests
refused with "Client is closed" or WebSocket handshakes aborted, and report
it as a bug (eclipse-vertx#5839, eclipse-vertx#5916, eclipse-vertx#5987, eclipse-vertx#5577). The behavior is not documented.

Changes:

Add an admonition to the HTTP client, TCP client and WebSocket client
sections explaining that a client must stay referenced for as long as it is
used, what happens when it is garbage collected and where to keep the
reference.

While there, fix two truncated sentences in the WebSocket client section
and the indentation of a source block that was rendered as a literal
paragraph.
@tsegismont tsegismont added this to the 5.2.0 milestone Aug 25, 2026

@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.

Looks good to me, thanks

@tsegismont
tsegismont merged commit 8ea18c4 into eclipse-vertx:master Aug 25, 2026
8 checks passed
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