Skip to content

Fix duplicate data consumer disposal during teardown - #10195

Merged
Amaury Levé (Evangelink) merged 1 commit into
mainfrom
dev/amauryleve/fix-10191-azure-report-teardown
Jul 24, 2026
Merged

Amaury Levé (Evangelink) merged 1 commit into
mainfrom
dev/amauryleve/fix-10191-azure-report-teardown

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Azure DevOps live result publishing can complete successfully and then crash during host teardown because its composite publisher is disposed twice.

CommonHost disposed data consumers owned by the message bus but accidentally recorded the message bus itself in the disposed-instance list. This change records the actual consumer, preventing a composite extension that is also registered as a session service from being disposed again. A regression test covers that shared-registration teardown path.

Tests: CommonHostTests on net8.0

Fixes #10191

Track the disposed data consumer rather than the message bus during host teardown so composite extensions are not disposed twice.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 336d2284-26e0-42ed-9772-cf91bc8eeb6b
Copilot AI review requested due to automatic review settings July 24, 2026 10:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes duplicate disposal of message-bus data consumers during host teardown.

Changes:

  • Tracks the disposed consumer instead of the message bus.
  • Adds regression coverage for consumers also registered as services.
Show a summary per file
File Description
src/Platform/Microsoft.Testing.Platform/Hosts/CommonTestHost.cs Prevents duplicate consumer disposal.
test/UnitTests/Microsoft.Testing.Platform.UnitTests/Hosts/CommonHostTests.cs Verifies shared consumers are disposed once.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Medium

@Evangelink Amaury Levé (Evangelink) added the state/needs-review Awaiting review from the team. label Jul 24, 2026
@Evangelink
Amaury Levé (Evangelink) enabled auto-merge (squash) July 24, 2026 10:52

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note

🤖 Automated review by GitHub Copilot. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

Review Summary

Clean, minimal bug fix with an adequate regression test. The root cause is obvious: alreadyDisposed.Add(service) recorded the message bus instead of the data consumer that was actually disposed and guard-checked, so a data consumer that was also registered as a top-level service would be disposed twice.

Verdict Table

# Dimension Verdict
1 Correctness ✅ Clean
2 Edge cases ✅ Clean
3 Error handling N/A
4 Concurrency / thread-safety N/A
5 Performance ✅ Clean
6 Security N/A
7 Backward compatibility ✅ Clean
8 Public API surface N/A
9 Naming / readability ✅ Clean
10 Code style / conventions ✅ Clean
11 Documentation N/A
12 Localization N/A
13 Test adequacy ✅ Clean
14 Test correctness ✅ Clean
15 Test maintainability ✅ Clean
16 Assertions (banned symbols) ✅ Clean
17 Logging / telemetry N/A
18 Disposal / resource mgmt ✅ Clean
19 Configuration N/A
20 CI / build integration N/A
21 Dependency management N/A
22 Architecture ✅ Clean

Overall: No issues found. The one-line fix is correct and the test covers the exact scenario.

@github-actions

Copy link
Copy Markdown
Contributor

🧪 Test quality grade — PR #10195

GradeTestMutationNotesHow to improve
B (80–89) new CommonHostTests.
DisposeServiceProviderAsync_
WhenDataConsumerIsAlsoRegisteredAsService_
DisposesOnce
3/3 killed All direct mutations of the fix are killed by the precise Times.Once assertion; only one registration order is covered. Add a second scenario where the dataConsumer service is registered before the messageBus, exercising the reversed-iteration path.

This advisory comment was generated automatically. Grades are heuristic
and informational — they do not block merging. Re-run with
/grade-tests.

🤖 Automated content by GitHub Copilot. Generated by the Grade Tests on PR (on open / sync) workflow. · sonnet46 42.3 AIC · ⌖ 4.09 AIC · ⊞ 10.3K · [◷]( · ◷)

@Evangelink

Copy link
Copy Markdown
Member Author

/backport to rel/4.3

@github-actions

Copy link
Copy Markdown
Contributor

@Evangelink
Amaury Levé (Evangelink) merged commit e9d4648 into main Jul 24, 2026
31 of 34 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/fix-10191-azure-report-teardown branch July 24, 2026 13:26
Amaury Levé (Evangelink) added a commit that referenced this pull request Jul 24, 2026
…#10195 (backport to rel/4.3) (#10197)

Co-authored-by: Amaury Levé <[email protected]>
Co-authored-by: Evangelink <[email protected]>
Copilot-Session: 336d2284-26e0-42ed-9772-cf91bc8eeb6b
Amaury Levé (Evangelink) added a commit that referenced this pull request Jul 24, 2026
Copilot-Session: f16544a8-1d0c-4cbc-810a-dd089e86a498
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-review Awaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Microsoft.Testing.Extensions.AzureDevOpsReport crashes during teardown after successful live Azure DevOps test-result publishing

3 participants