Skip to content

fix: ServerSocket leak in AutoBalancerTestUtils#findLocalPorts#3244

Merged
daniel-y merged 1 commit intoAutoMQ:mainfrom
iamsanjaymalakar:iamsanjaymalakar/findlocalports-socket-leak
Mar 9, 2026
Merged

fix: ServerSocket leak in AutoBalancerTestUtils#findLocalPorts#3244
daniel-y merged 1 commit intoAutoMQ:mainfrom
iamsanjaymalakar:iamsanjaymalakar/findlocalports-socket-leak

Conversation

@iamsanjaymalakar
Copy link
Copy Markdown
Contributor

Linked Issue

Fixes #3243

What changed

Ensure ServerSocket is closed when an IOException occurs after the socket is created but before it is added to the tracking list (e.g., during setReuseAddress(true)).

Why

Prevents leaking file descriptors in the test utility, avoiding potential flakiness/resource exhaustion in CI.

Testing

No behavior change in the success path; only improves cleanup on failure.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 4, 2026

CLA assistant check
All committers have signed the CLA.

@iamsanjaymalakar iamsanjaymalakar changed the title Fix ServerSocket leak in AutoBalancerTestUtils#findLocalPorts fix: ServerSocket leak in AutoBalancerTestUtils#findLocalPorts Mar 4, 2026
Copy link
Copy Markdown
Contributor

@Gezi-lzq Gezi-lzq left a comment

Choose a reason for hiding this comment

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

Looks good. This correctly closes the ServerSocket when an exception occurs after socket creation (e.g. during setReuseAddress), which prevents FD leaks in the test utility failure path.

@daniel-y daniel-y merged commit 9d94a9b into AutoMQ:main Mar 9, 2026
6 of 7 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.

[BUG] AutoBalancerTestUtils.findLocalPorts may leak ServerSocket on IOException

4 participants