Document that clients must be kept referenced to avoid being shut down when garbage collected - #6318
Merged
tsegismont merged 1 commit intoAug 25, 2026
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
HttpClient,NetClientandWebSocketClientare 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 withClient 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":IMPORTANTadmonition 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 ifHttpClient#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 atNetClient#shutdown()and the existing "TCP graceful shut down" section (sockets without a shutdown handler are closed immediately).While there, in the WebSocket client section:
e Vert.x ...→The Vert.x ...,en connecting ...→When connecting ...) and stray leading spaces;clientWebSocketConfigurationAndConnectexample 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 generatedhttp.adoc/tcp.adoccontain the admonitions with resolved API links and the fixed source block.