[Foundation] Ensure NSUrlSessionHandler's session is cleaned up on dispose. Fixes #24376.#24384
[Foundation] Ensure NSUrlSessionHandler's session is cleaned up on dispose. Fixes #24376.#24384rolfbjarne merged 4 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #24376 by ensuring that NSUrlSessionHandler properly invalidates its underlying NSUrlSession when disposed. The fix adds a call to InvalidateAndCancel() in the Dispose method, which is critical for background sessions that need to be properly cleaned up to allow the same session identifier to be reused.
- Adds
session.InvalidateAndCancel()call in theDisposemethod - Includes a comprehensive test verifying background session handlers can be disposed and recreated with the same identifier
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Foundation/NSUrlSessionHandler.cs | Adds InvalidateAndCancel() call in the Dispose method to properly clean up the session |
| tests/monotouch-test/System.Net.Http/NSUrlSessionHandlerTest.cs | New test file with test case verifying background session cleanup and recreation works correctly |
✅ [CI Build #60a35a0] Build passed (Build packages) ✅Pipeline on Agent |
✅ [PR Build #60a35a0] Build passed (Detect API changes) ✅Pipeline on Agent |
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
✅ [CI Build #60a35a0] Build passed (Build macOS tests) ✅Pipeline on Agent |
💻 [CI Build #60a35a0] Tests on macOS X64 - Mac Sonoma (14) passed 💻✅ All tests on macOS X64 - Mac Sonoma (14) passed. Pipeline on Agent |
💻 [CI Build #60a35a0] Tests on macOS M1 - Mac Monterey (12) passed 💻✅ All tests on macOS M1 - Mac Monterey (12) passed. Pipeline on Agent |
💻 [CI Build #60a35a0] Tests on macOS arm64 - Mac Tahoe (26) passed 💻✅ All tests on macOS arm64 - Mac Tahoe (26) passed. Pipeline on Agent |
💻 [CI Build #60a35a0] Tests on macOS arm64 - Mac Sequoia (15) passed 💻✅ All tests on macOS arm64 - Mac Sequoia (15) passed. Pipeline on Agent |
💻 [CI Build #60a35a0] Tests on macOS M1 - Mac Ventura (13) passed 💻✅ All tests on macOS M1 - Mac Ventura (13) passed. Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build #60a35a0] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 121 tests passed 🎉 Tests counts✅ cecil: All 1 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
Fixes #24376
Doc references:
Continuation of #24377 by @dotMorten.