Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Attempting to set the ConcurrentObjectResolutionTimeout value on the ObjectContainer to TimeSpan.Zero sometimes throws an exception if running multiple tests in parallel. #445

Merged
merged 1 commit into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* Fix: Deprecated dependency `Specflow.Internal.Json` is used. Relpaced with `System.Text.Json`. The dependency was used for laoding `reqnroll.json`, for Visual Studio integration and for telemetry. (#373)
* Fix: Error with NUnit 4: "Only static OneTimeSetUp and OneTimeTearDown are allowed for InstancePerTestCase mode" (#379)
* Fix: Reqnroll.Autofac: FeatureContext cannot be resolved in BeforeFeature/AfterFeature hooks (#340)
* Fix: Attempting to set the `ConcurrentObjectResolutionTimeout` value on the `ObjectContainer` to `TimeSpan.Zero` sometimes throws an exception if running multiple tests in parallel. (#440)

*Contributors of this release (in alphabetical order):* @Antwane, @clrudolphi, @gasparnagy, @obligaron, @olegKoshmeliuk, @SeanKilleen, @StefH

Expand Down
12 changes: 11 additions & 1 deletion Reqnroll/BoDi/ObjectContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,17 @@ protected static object ExecuteWithLock(object lockObject, Func<object> getter,
return obj;

if (timeout == TimeSpan.Zero)
return factory();
{
Monitor.Enter(lockObject);
try
{
return factory();
}
finally
{
Monitor.Exit(lockObject);
}
}

if (Monitor.TryEnter(lockObject, timeout))
{
Expand Down