Skip to content

Dispose HttpResponseMessage and HttpContent in HTTP client proxy#25478

Merged
EngincanV merged 1 commit into
rel-10.4from
maliming/issue-25475-dispose-response
Jun 1, 2026
Merged

Dispose HttpResponseMessage and HttpContent in HTTP client proxy#25478
EngincanV merged 1 commit into
rel-10.4from
maliming/issue-25475-dispose-response

Conversation

@maliming
Copy link
Copy Markdown
Member

@maliming maliming commented May 26, 2026

Fixes #25475

ABP HTTP client proxy uses HttpCompletionOption.ResponseHeadersRead, but several paths dropped the response without disposing it and held the connection open. Dispose HttpResponseMessage / HttpContent on these paths.

ABP dynamic HTTP client proxy uses HttpCompletionOption.ResponseHeadersRead,
but several paths in ClientProxyBase and DynamicHttpProxyInterceptor dropped
the response without disposing it, leaving the underlying connection
occupied until the server closed it or the client timed out.

Fixes #25475
Copilot AI review requested due to automatic review settings May 26, 2026 08:28
@maliming maliming added this to the 10.4-patch milestone May 26, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a connection/resource leak in ABP’s dynamic HTTP client proxy when using HttpCompletionOption.ResponseHeadersRead by ensuring responses/contents are disposed on non-success and “no return value” code paths, so connections aren’t held open unnecessarily (Fixes #25475).

Changes:

  • Dispose the returned HttpContent for void-returning proxy methods (both interceptor and base proxy paths).
  • Ensure HttpResponseMessage is disposed when throwing for non-success responses to deterministically release the underlying connection.
  • Add regression tests verifying HttpContent is disposed for non-ABP error responses and successful responses.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
framework/test/Volo.Abp.Http.Client.Tests/Volo/Abp/Http/DynamicProxying/ClientProxyResponseDisposal_Tests.cs Adds tests asserting HttpContent is disposed on key success/error paths.
framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpProxyInterceptor.cs Disposes HttpContent for void-returning dynamic proxy invocations.
framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/ClientProxying/ClientProxyBase.cs Disposes response/content on void return, JSON/string parsing, and non-success throw paths.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 26, 2026

Codecov Report

❌ Patch coverage is 68.18182% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.40%. Comparing base (4265df0) to head (2eb9193).

Files with missing lines Patch % Lines
.../Abp/Http/Client/ClientProxying/ClientProxyBase.cs 63.15% 6 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           rel-10.4   #25478      +/-   ##
============================================
- Coverage     49.44%   49.40%   -0.04%     
============================================
  Files          3670     3670              
  Lines        123599   123611      +12     
  Branches       9453     9453              
============================================
- Hits          61111    61069      -42     
- Misses        60654    60715      +61     
+ Partials       1834     1827       -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@maliming maliming requested a review from EngincanV May 26, 2026 09:13
@EngincanV EngincanV merged commit 519076a into rel-10.4 Jun 1, 2026
4 of 5 checks passed
@EngincanV EngincanV deleted the maliming/issue-25475-dispose-response branch June 1, 2026 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants