Skip to content

fix: close resources in NetUtils to prevent leaks - #3249

Closed
lxcxjxhx wants to merge 1 commit into
alibaba:masterfrom
lxcxjxhx:fix/resource-leak-in-netutils
Closed

lxcxjxhx wants to merge 1 commit into
alibaba:masterfrom
lxcxjxhx:fix/resource-leak-in-netutils

Conversation

@lxcxjxhx

Copy link
Copy Markdown

Summary

Fix resource leaks in NetUtils by ensuring proper closure of Socket, PrintWriter, and HttpURLConnection resources.

Changes

  • simpleRequest(): Add HttpURLConnection.disconnect() in finally block to prevent connection leaks
  • requestViaSocket(): Add proper closure of Socket and PrintWriter in finally block to prevent resource leaks

Impact

These resource leaks could lead to:

  • Socket/connection exhaustion in long-running applications
  • File descriptor leaks when making multiple HTTP requests
  • Potential memory leaks in high-throughput scenarios

Testing

Local environment limitations prevent full dynamic testing; relying on CI/CD automated tests for verification.


I apologize for any inconvenience caused by this PR. I noticed these resource leaks while reviewing the codebase and wanted to contribute fixes. Please let me know if any changes are needed.

@CLAassistant

CLAassistant commented Jul 29, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@lxcxjxhx lxcxjxhx closed this by deleting the head repository Jul 31, 2026
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