Skip to content

Fix static lock in TestApplicationActionQueue#53304

Merged
Evangelink merged 1 commit intomainfrom
fix/test-action-queue-static-lock
Mar 9, 2026
Merged

Fix static lock in TestApplicationActionQueue#53304
Evangelink merged 1 commit intomainfrom
fix/test-action-queue-static-lock

Conversation

@Evangelink
Copy link
Member

Summary

Changes _lock in TestApplicationActionQueue from static to an instance field.

Problem

The _lock field is static, meaning all TestApplicationActionQueue instances share the same lock. However, the lock protects instance state (_aggregateExitCode), so it should be scoped to the instance. A static lock incorrectly serializes exit code aggregation across all instances, which would cause unnecessary contention if multiple instances were ever created (e.g., in tests or future refactoring).

Changes

  • src/Cli/dotnet/Commands/Test/MTP/TestApplicationActionQueue.cs: static readonly Lock _lockreadonly Lock _lock

Change _lock from static to instance field. The lock protects instance
state (_aggregateExitCode) so it should be scoped to the instance. A
static lock incorrectly serializes exit code aggregation across all
instances.
Copy link
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 bug in TestApplicationActionQueue where the _lock field was declared static, causing all instances of the class to share the same lock. Since _lock only protects instance-level state (_aggregateExitCode), the lock should be scoped to each instance. Making it non-static eliminates unnecessary cross-instance contention and correctly limits the lock's scope to the data it protects.

Changes:

  • Removed static from the _lock field declaration in TestApplicationActionQueue

Copy link
Member

@Youssef1313 Youssef1313 left a comment

Choose a reason for hiding this comment

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

Today we only create one instance so there is no behavior difference, but makes sense from semantics point of view.

@Evangelink Evangelink merged commit f455dfc into main Mar 9, 2026
32 checks passed
@Evangelink Evangelink deleted the fix/test-action-queue-static-lock branch March 9, 2026 19:28
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.

3 participants