Fix shared options mutation in AbpRemoteServiceApiDescriptionProvider#25542
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes a concurrency/memory-growth bug in ABP’s MVC API explorer integration by ensuring AbpRemoteServiceApiDescriptionProvider.GetApiResponseTypes() no longer mutates the shared singleton options (IOptions<AbpRemoteServiceApiDescriptionProviderOptions>.Value.SupportedResponseTypes) during API description rebuilds.
Changes:
- Update
GetApiResponseTypes()to create and yield freshApiResponseTypeinstances (including newly builtApiResponseFormats) instead of modifying the option templates. - Add test coverage to verify templates are not mutated across repeated calls and that concurrent executions do not throw.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApiExploring/AbpRemoteServiceApiDescriptionProvider.cs | Avoids shared options mutation by cloning response type templates per call and building formats on the new instances. |
| framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ApiExploring/AbpRemoteServiceApiDescriptionProvider_Tests.cs | Adds regression tests for non-mutation, correct response type creation, and concurrency safety. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## rel-10.4 #25542 +/- ##
============================================
- Coverage 49.42% 49.41% -0.02%
============================================
Files 3670 3671 +1
Lines 123599 123848 +249
Branches 9453 9466 +13
============================================
+ Hits 61091 61201 +110
- Misses 60672 60816 +144
+ Partials 1836 1831 -5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Thank you for the quick fix. I was preparing a pull request for this, but you beat me to it 🙂 The solution is clever and clean. I really appreciate the fast response. |
Fixes #25536.
GetApiResponseTypes()mutated the singletonIOptions<AbpRemoteServiceApiDescriptionProviderOptions>.SupportedResponseTypeson every call, causing unbounded growth ofApiResponseFormatsand concurrentList<>.Addraces on/Abp/ServiceProxyScript. Each call now yields freshApiResponseTypeinstances.