From ed08923b46b77ae6b2f3ddb68914a112d8045f43 Mon Sep 17 00:00:00 2001 From: Henrik Date: Mon, 20 Jan 2025 11:41:13 +0100 Subject: [PATCH] Use the new more efficient .NET 9 Lock type (#18015) --- src/Umbraco.Core/Cache/ValueEditorCache.cs | 4 ++-- src/Umbraco.Core/Composing/CollectionBuilderBase.cs | 2 +- src/Umbraco.Core/Composing/TypeFinder.cs | 2 +- src/Umbraco.Core/Composing/TypeLoader.cs | 2 +- src/Umbraco.Core/Diagnostics/MiniDump.cs | 2 +- src/Umbraco.Core/Events/ScopedNotificationPublisher.cs | 2 +- src/Umbraco.Core/Extensions/WaitHandleExtensions.cs | 2 +- src/Umbraco.Core/IO/FileSystems.cs | 2 +- src/Umbraco.Core/Models/PropertyCollection.cs | 2 +- .../Models/PublishedContent/PublishedPropertyType.cs | 2 +- .../PropertyEditors/PropertyValueConverterCollection.cs | 2 +- .../PublishedCache/PublishedElementPropertyBase.cs | 2 +- src/Umbraco.Core/Scoping/LockingMechanism.cs | 2 +- src/Umbraco.Core/Services/NotificationService.cs | 2 +- src/Umbraco.Core/SimpleMainDom.cs | 2 +- src/Umbraco.Core/UdiParserServiceConnectors.cs | 2 +- .../Persistence/Mappers/BaseMapper.cs | 2 +- .../Persistence/Repositories/Implement/UserRepository.cs | 2 +- src/Umbraco.Infrastructure/Runtime/SqlMainDomLock.cs | 2 +- src/Umbraco.Infrastructure/Sync/DatabaseServerMessenger.cs | 2 +- src/Umbraco.PublishedCache.HybridCache/PublishedProperty.cs | 4 ++-- .../Serialization/LazyCompressedString.cs | 4 ++-- .../Localization/DynamicRequestCultureProviderBase.cs | 6 +++--- .../Logging/RegisteredReloadableLogger.cs | 2 +- .../InMemoryAuto/CollectibleRuntimeViewCompiler.cs | 2 +- .../ModelsBuilder/InMemoryAuto/InMemoryModelFactory.cs | 2 +- src/Umbraco.Web.Common/Routing/RoutableDocumentFilter.cs | 2 +- src/Umbraco.Web.Common/Security/BackofficeSecurity.cs | 2 +- tests/Umbraco.TestData/LoadTestController.cs | 2 +- .../Testing/UmbracoIntegrationTestBase.cs | 2 +- .../Umbraco.Infrastructure/Persistence/LocksTests.cs | 2 +- .../Umbraco.Persistence.EFCore/Scoping/EFCoreLockTests.cs | 2 +- 32 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/Umbraco.Core/Cache/ValueEditorCache.cs b/src/Umbraco.Core/Cache/ValueEditorCache.cs index f555b76f5516..85623d30fca1 100644 --- a/src/Umbraco.Core/Cache/ValueEditorCache.cs +++ b/src/Umbraco.Core/Cache/ValueEditorCache.cs @@ -5,13 +5,13 @@ namespace Umbraco.Cms.Core.Cache; public class ValueEditorCache : IValueEditorCache { - private readonly object _dictionaryLocker; + private readonly Lock _dictionaryLocker; private readonly Dictionary> _valueEditorCache; public ValueEditorCache() { _valueEditorCache = new Dictionary>(); - _dictionaryLocker = new object(); + _dictionaryLocker = new Lock(); } public IDataValueEditor GetValueEditor(IDataEditor editor, IDataType dataType) diff --git a/src/Umbraco.Core/Composing/CollectionBuilderBase.cs b/src/Umbraco.Core/Composing/CollectionBuilderBase.cs index 8b1c33a6100f..0a3baa1d3da8 100644 --- a/src/Umbraco.Core/Composing/CollectionBuilderBase.cs +++ b/src/Umbraco.Core/Composing/CollectionBuilderBase.cs @@ -13,7 +13,7 @@ public abstract class CollectionBuilderBase : ICol where TBuilder : CollectionBuilderBase where TCollection : class, IBuilderCollection { - private readonly object _locker = new(); + private readonly Lock _locker = new(); private readonly List _types = new(); private Type[]? _registeredTypes; diff --git a/src/Umbraco.Core/Composing/TypeFinder.cs b/src/Umbraco.Core/Composing/TypeFinder.cs index 202ff9136238..b18239298f2f 100644 --- a/src/Umbraco.Core/Composing/TypeFinder.cs +++ b/src/Umbraco.Core/Composing/TypeFinder.cs @@ -40,7 +40,7 @@ public class TypeFinder : ITypeFinder private static readonly ConcurrentDictionary TypeNamesCache = new(); private readonly IAssemblyProvider _assemblyProvider; - private readonly object _localFilteredAssemblyCacheLocker = new(); + private readonly Lock _localFilteredAssemblyCacheLocker = new(); private readonly ILogger _logger; private readonly List _notifiedLoadExceptionAssemblies = new(); diff --git a/src/Umbraco.Core/Composing/TypeLoader.cs b/src/Umbraco.Core/Composing/TypeLoader.cs index 3920e3d38274..21b895bf6fac 100644 --- a/src/Umbraco.Core/Composing/TypeLoader.cs +++ b/src/Umbraco.Core/Composing/TypeLoader.cs @@ -20,7 +20,7 @@ namespace Umbraco.Cms.Core.Composing; /// public sealed class TypeLoader { - private readonly object _locko = new(); + private readonly Lock _locko = new(); private readonly ILogger _logger; private readonly Dictionary _types = new(); diff --git a/src/Umbraco.Core/Diagnostics/MiniDump.cs b/src/Umbraco.Core/Diagnostics/MiniDump.cs index ac37c69f122d..c553f921af62 100644 --- a/src/Umbraco.Core/Diagnostics/MiniDump.cs +++ b/src/Umbraco.Core/Diagnostics/MiniDump.cs @@ -9,7 +9,7 @@ namespace Umbraco.Cms.Core.Diagnostics; // which itself got it from http://blog.kalmbach-software.de/2008/12/13/writing-minidumps-in-c/ public static class MiniDump { - private static readonly object LockO = new(); + private static readonly Lock LockO = new(); [Flags] public enum Option : uint diff --git a/src/Umbraco.Core/Events/ScopedNotificationPublisher.cs b/src/Umbraco.Core/Events/ScopedNotificationPublisher.cs index f5e66ed722c7..a3bf6d7682d4 100644 --- a/src/Umbraco.Core/Events/ScopedNotificationPublisher.cs +++ b/src/Umbraco.Core/Events/ScopedNotificationPublisher.cs @@ -18,7 +18,7 @@ public class ScopedNotificationPublisher : IScopedNotifica private readonly IEventAggregator _eventAggregator; private readonly List _notificationOnScopeCompleted = new List(); private readonly bool _publishCancelableNotificationOnScopeExit; - private readonly object _locker = new(); + private readonly Lock _locker = new(); private bool _isSuppressed; public ScopedNotificationPublisher(IEventAggregator eventAggregator, bool publishCancelableNotificationOnScopeExit = false) diff --git a/src/Umbraco.Core/Extensions/WaitHandleExtensions.cs b/src/Umbraco.Core/Extensions/WaitHandleExtensions.cs index b0058dd79812..add643415c2b 100644 --- a/src/Umbraco.Core/Extensions/WaitHandleExtensions.cs +++ b/src/Umbraco.Core/Extensions/WaitHandleExtensions.cs @@ -12,7 +12,7 @@ public static class WaitHandleExtensions public static Task WaitOneAsync(this WaitHandle handle, int millisecondsTimeout = Timeout.Infinite) { var tcs = new TaskCompletionSource(); - var callbackHandleInitLock = new object(); + var callbackHandleInitLock = new Lock(); lock (callbackHandleInitLock) { RegisteredWaitHandle? callbackHandle = null; diff --git a/src/Umbraco.Core/IO/FileSystems.cs b/src/Umbraco.Core/IO/FileSystems.cs index 3e403983824c..5e27250cb421 100644 --- a/src/Umbraco.Core/IO/FileSystems.cs +++ b/src/Umbraco.Core/IO/FileSystems.cs @@ -31,7 +31,7 @@ public sealed class FileSystems // shadow support private readonly List _shadowWrappers = new(); - private readonly object _shadowLocker = new(); + private readonly Lock _shadowLocker = new(); private static string? _shadowCurrentId; // static - unique!! #region Constructor diff --git a/src/Umbraco.Core/Models/PropertyCollection.cs b/src/Umbraco.Core/Models/PropertyCollection.cs index dbb648df2947..330869f7172c 100644 --- a/src/Umbraco.Core/Models/PropertyCollection.cs +++ b/src/Umbraco.Core/Models/PropertyCollection.cs @@ -13,7 +13,7 @@ namespace Umbraco.Cms.Core.Models; [DataContract(IsReference = true)] public class PropertyCollection : KeyedCollection, IPropertyCollection { - private readonly object _addLocker = new(); + private readonly Lock _addLocker = new(); /// /// Initializes a new instance of the class. diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs index 1c3818b59278..e22777731023 100644 --- a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs +++ b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs @@ -14,7 +14,7 @@ public class PublishedPropertyType : IPublishedPropertyType { private readonly IPublishedModelFactory _publishedModelFactory; private readonly PropertyValueConverterCollection _propertyValueConverters; - private readonly object _locker = new object(); + private readonly Lock _locker = new(); private volatile bool _initialized; private IPropertyValueConverter? _converter; private PropertyCacheLevel _cacheLevel; diff --git a/src/Umbraco.Core/PropertyEditors/PropertyValueConverterCollection.cs b/src/Umbraco.Core/PropertyEditors/PropertyValueConverterCollection.cs index 9833a31ed7ac..2ede3ad78b22 100644 --- a/src/Umbraco.Core/PropertyEditors/PropertyValueConverterCollection.cs +++ b/src/Umbraco.Core/PropertyEditors/PropertyValueConverterCollection.cs @@ -5,7 +5,7 @@ namespace Umbraco.Cms.Core.PropertyEditors; public class PropertyValueConverterCollection : BuilderCollectionBase { - private readonly object _locker = new(); + private readonly Lock _locker = new(); private Dictionary? _defaultConverters; public PropertyValueConverterCollection(Func> items) diff --git a/src/Umbraco.Core/PublishedCache/PublishedElementPropertyBase.cs b/src/Umbraco.Core/PublishedCache/PublishedElementPropertyBase.cs index 0452cf0b03bd..f290afe5ea11 100644 --- a/src/Umbraco.Core/PublishedCache/PublishedElementPropertyBase.cs +++ b/src/Umbraco.Core/PublishedCache/PublishedElementPropertyBase.cs @@ -14,7 +14,7 @@ internal class PublishedElementPropertyBase : PublishedPropertyBase // means faster execution, but uses memory - not sure if we want it // so making it configurable. private const bool FullCacheWhenPreviewing = true; - private readonly object _locko = new(); + private readonly Lock _locko = new(); private readonly object? _sourceValue; protected readonly bool IsMember; protected readonly bool IsPreviewing; diff --git a/src/Umbraco.Core/Scoping/LockingMechanism.cs b/src/Umbraco.Core/Scoping/LockingMechanism.cs index 171580407d5d..0cee4293f65e 100644 --- a/src/Umbraco.Core/Scoping/LockingMechanism.cs +++ b/src/Umbraco.Core/Scoping/LockingMechanism.cs @@ -13,7 +13,7 @@ public class LockingMechanism : ILockingMechanism { private readonly IDistributedLockingMechanismFactory _distributedLockingMechanismFactory; private readonly ILogger _logger; - private readonly object _locker = new(); + private readonly Lock _locker = new(); private StackQueue<(DistributedLockType lockType, TimeSpan timeout, Guid instanceId, int lockId)>? _queuedLocks; private HashSet? _readLocks; private Dictionary>? _readLocksDictionary; diff --git a/src/Umbraco.Core/Services/NotificationService.cs b/src/Umbraco.Core/Services/NotificationService.cs index e12183a1a6c5..be896eb5f36f 100644 --- a/src/Umbraco.Core/Services/NotificationService.cs +++ b/src/Umbraco.Core/Services/NotificationService.cs @@ -20,7 +20,7 @@ public class NotificationService : INotificationService { // manage notifications // ideally, would need to use IBackgroundTasks - but they are not part of Core! - private static readonly object Locker = new(); + private static readonly Lock Locker = new(); private readonly IContentService _contentService; private readonly ContentSettings _contentSettings; diff --git a/src/Umbraco.Core/SimpleMainDom.cs b/src/Umbraco.Core/SimpleMainDom.cs index 3b3bc1b0c017..ffdd7e706cb3 100644 --- a/src/Umbraco.Core/SimpleMainDom.cs +++ b/src/Umbraco.Core/SimpleMainDom.cs @@ -9,7 +9,7 @@ namespace Umbraco.Cms.Core; public class SimpleMainDom : IMainDom, IDisposable { private readonly List> _callbacks = new(); - private readonly object _locko = new(); + private readonly Lock _locko = new(); private bool _disposedValue; private bool _isStopping; diff --git a/src/Umbraco.Core/UdiParserServiceConnectors.cs b/src/Umbraco.Core/UdiParserServiceConnectors.cs index 465431476ed7..ec30d7f1c8cd 100644 --- a/src/Umbraco.Core/UdiParserServiceConnectors.cs +++ b/src/Umbraco.Core/UdiParserServiceConnectors.cs @@ -7,7 +7,7 @@ namespace Umbraco.Cms.Core; [Obsolete("This class will be removed in a future version.")] public static class UdiParserServiceConnectors { - private static readonly object ScanLocker = new(); + private static readonly Lock ScanLocker = new(); // notes - see U4-10409 // if this class is used during application pre-start it cannot scans the assemblies, diff --git a/src/Umbraco.Infrastructure/Persistence/Mappers/BaseMapper.cs b/src/Umbraco.Infrastructure/Persistence/Mappers/BaseMapper.cs index 8566bcf464c2..7849820e88b9 100644 --- a/src/Umbraco.Infrastructure/Persistence/Mappers/BaseMapper.cs +++ b/src/Umbraco.Infrastructure/Persistence/Mappers/BaseMapper.cs @@ -8,7 +8,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Mappers; public abstract class BaseMapper { - private readonly object _definedLock = new(); + private readonly Lock _definedLock = new(); private readonly MapperConfigurationStore _maps; diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/UserRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/UserRepository.cs index 39e37e528fdc..a1d5a41beaff 100644 --- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/UserRepository.cs +++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/UserRepository.cs @@ -36,7 +36,7 @@ internal class UserRepository : EntityRepositoryBase, IUserReposito private readonly IRuntimeState _runtimeState; private string? _passwordConfigJson; private bool _passwordConfigInitialized; - private readonly object _sqliteValidateSessionLock = new(); + private readonly Lock _sqliteValidateSessionLock = new(); private readonly IDictionary _permissionMappers; private readonly IAppPolicyCache _globalCache; private readonly IScopeAccessor _scopeAccessor; diff --git a/src/Umbraco.Infrastructure/Runtime/SqlMainDomLock.cs b/src/Umbraco.Infrastructure/Runtime/SqlMainDomLock.cs index 9576bad10c85..bc955bcb9fa5 100644 --- a/src/Umbraco.Infrastructure/Runtime/SqlMainDomLock.cs +++ b/src/Umbraco.Infrastructure/Runtime/SqlMainDomLock.cs @@ -23,7 +23,7 @@ public class SqlMainDomLock : IMainDomLock private readonly IUmbracoDatabase? _db; private readonly UmbracoDatabaseFactory _dbFactory; private readonly IOptions _globalSettings; - private readonly object _locker = new(); + private readonly Lock _locker = new(); private readonly string _lockId; private readonly ILogger _logger; private bool _acquireWhenTablesNotAvailable; diff --git a/src/Umbraco.Infrastructure/Sync/DatabaseServerMessenger.cs b/src/Umbraco.Infrastructure/Sync/DatabaseServerMessenger.cs index 734f6ff6d471..ee85d6c3a8ad 100644 --- a/src/Umbraco.Infrastructure/Sync/DatabaseServerMessenger.cs +++ b/src/Umbraco.Infrastructure/Sync/DatabaseServerMessenger.cs @@ -23,7 +23,7 @@ public abstract class DatabaseServerMessenger : ServerMessengerBase, IDisposable private readonly Lazy _initialized; private readonly LastSyncedFileManager _lastSyncedFileManager; - private readonly object _locko = new(); + private readonly Lock _locko = new(); /* * this messenger writes ALL instructions to the database, * but only processes instructions coming from remote servers, diff --git a/src/Umbraco.PublishedCache.HybridCache/PublishedProperty.cs b/src/Umbraco.PublishedCache.HybridCache/PublishedProperty.cs index 85b2577ade2e..577c929f2c18 100644 --- a/src/Umbraco.PublishedCache.HybridCache/PublishedProperty.cs +++ b/src/Umbraco.PublishedCache.HybridCache/PublishedProperty.cs @@ -27,7 +27,7 @@ internal class PublishedProperty : PublishedPropertyBase private CacheValues? _cacheValues; // the variant source and inter values - private readonly object _locko = new(); + private readonly Lock _locko = new(); private ConcurrentDictionary? _sourceValues; // initializes a published content property with a value @@ -270,7 +270,7 @@ public string? Segment private class CacheValues : CacheValue { - private readonly object _locko = new(); + private readonly Lock _locko = new(); private ConcurrentDictionary? _values; public CacheValue For(string? culture, string? segment) diff --git a/src/Umbraco.PublishedCache.HybridCache/Serialization/LazyCompressedString.cs b/src/Umbraco.PublishedCache.HybridCache/Serialization/LazyCompressedString.cs index 84c74ab5cfce..25bcc1a0cc47 100644 --- a/src/Umbraco.PublishedCache.HybridCache/Serialization/LazyCompressedString.cs +++ b/src/Umbraco.PublishedCache.HybridCache/Serialization/LazyCompressedString.cs @@ -11,7 +11,7 @@ namespace Umbraco.Cms.Infrastructure.HybridCache.Serialization; [DebuggerDisplay("{Display}")] internal struct LazyCompressedString { - private readonly object _locker; + private readonly Lock _locker; private byte[]? _bytes; private string? _str; @@ -21,7 +21,7 @@ internal struct LazyCompressedString /// LZ4 Pickle compressed UTF8 String public LazyCompressedString(byte[] bytes) { - _locker = new object(); + _locker = new Lock(); _bytes = bytes; _str = null; } diff --git a/src/Umbraco.Web.Common/Localization/DynamicRequestCultureProviderBase.cs b/src/Umbraco.Web.Common/Localization/DynamicRequestCultureProviderBase.cs index 84bf1531b78b..8af550b65b50 100644 --- a/src/Umbraco.Web.Common/Localization/DynamicRequestCultureProviderBase.cs +++ b/src/Umbraco.Web.Common/Localization/DynamicRequestCultureProviderBase.cs @@ -12,8 +12,8 @@ namespace Umbraco.Cms.Web.Common.Localization; public abstract class DynamicRequestCultureProviderBase : RequestCultureProvider { private readonly RequestLocalizationOptions _options; - private readonly object _lockerSupportedCultures = new(); - private readonly object _lockerSupportedUICultures = new(); + private readonly Lock _lockerSupportedCultures = new(); + private readonly Lock _lockerSupportedUICultures = new(); /// /// Initializes a new instance of the class. @@ -66,7 +66,7 @@ protected DynamicRequestCultureProviderBase(RequestLocalizationOptions requestLo /// The cultures. /// The locker object to use. /// The add action to execute. - private static void TryAddLocked(IEnumerable? supportedCultures, IEnumerable cultures, object locker, Action addAction) + private static void TryAddLocked(IEnumerable? supportedCultures, IEnumerable cultures, Lock locker, Action addAction) { foreach (StringSegment culture in cultures) { diff --git a/src/Umbraco.Web.Common/Logging/RegisteredReloadableLogger.cs b/src/Umbraco.Web.Common/Logging/RegisteredReloadableLogger.cs index 5d9b398678da..499d7aceaf91 100644 --- a/src/Umbraco.Web.Common/Logging/RegisteredReloadableLogger.cs +++ b/src/Umbraco.Web.Common/Logging/RegisteredReloadableLogger.cs @@ -11,7 +11,7 @@ namespace Umbraco.Cms.Web.Common.Logging; /// internal class RegisteredReloadableLogger { - private static readonly object _frozenLock = new(); + private static readonly Lock _frozenLock = new(); private static bool _frozen; private readonly ReloadableLogger _logger; diff --git a/src/Umbraco.Web.Common/ModelsBuilder/InMemoryAuto/CollectibleRuntimeViewCompiler.cs b/src/Umbraco.Web.Common/ModelsBuilder/InMemoryAuto/CollectibleRuntimeViewCompiler.cs index 4cb77897b6cb..f45243e47c29 100644 --- a/src/Umbraco.Web.Common/ModelsBuilder/InMemoryAuto/CollectibleRuntimeViewCompiler.cs +++ b/src/Umbraco.Web.Common/ModelsBuilder/InMemoryAuto/CollectibleRuntimeViewCompiler.cs @@ -20,7 +20,7 @@ namespace Umbraco.Cms.Web.Common.ModelsBuilder.InMemoryAuto; internal class CollectibleRuntimeViewCompiler : IViewCompiler { - private readonly object _cacheLock = new object(); + private readonly Lock _cacheLock = new(); private readonly Dictionary _precompiledViews; private readonly ConcurrentDictionary _normalizedPathCache; private readonly IFileProvider _fileProvider; diff --git a/src/Umbraco.Web.Common/ModelsBuilder/InMemoryAuto/InMemoryModelFactory.cs b/src/Umbraco.Web.Common/ModelsBuilder/InMemoryAuto/InMemoryModelFactory.cs index fe2718595ccb..a625be5d982d 100644 --- a/src/Umbraco.Web.Common/ModelsBuilder/InMemoryAuto/InMemoryModelFactory.cs +++ b/src/Umbraco.Web.Common/ModelsBuilder/InMemoryAuto/InMemoryModelFactory.cs @@ -162,7 +162,7 @@ public InMemoryModelFactory( public Assembly? CurrentModelsAssembly { get; private set; } /// - public object SyncRoot { get; } = new object(); + public object SyncRoot { get; } = new(); private UmbracoServices UmbracoServices => _umbracoServices.Value; diff --git a/src/Umbraco.Web.Common/Routing/RoutableDocumentFilter.cs b/src/Umbraco.Web.Common/Routing/RoutableDocumentFilter.cs index 4abbb21cb380..751ef2d2fdc4 100644 --- a/src/Umbraco.Web.Common/Routing/RoutableDocumentFilter.cs +++ b/src/Umbraco.Web.Common/Routing/RoutableDocumentFilter.cs @@ -21,7 +21,7 @@ public sealed class RoutableDocumentFilter : IRoutableDocumentFilter private readonly GlobalSettings _globalSettings; private readonly IHostingEnvironment _hostingEnvironment; private readonly ConcurrentDictionary _routeChecks = new(StringComparer.OrdinalIgnoreCase); - private readonly object _routeLocker = new(); + private readonly Lock _routeLocker = new(); private readonly WebRoutingSettings _routingSettings; private object _initLocker = new(); private bool _isInit; diff --git a/src/Umbraco.Web.Common/Security/BackofficeSecurity.cs b/src/Umbraco.Web.Common/Security/BackofficeSecurity.cs index 270bea8f01a0..15905b557740 100644 --- a/src/Umbraco.Web.Common/Security/BackofficeSecurity.cs +++ b/src/Umbraco.Web.Common/Security/BackofficeSecurity.cs @@ -10,7 +10,7 @@ namespace Umbraco.Cms.Web.Common.Security; public class BackOfficeSecurity : IBackOfficeSecurity { - private readonly object _currentUserLock = new(); + private readonly Lock _currentUserLock = new(); private readonly IHttpContextAccessor _httpContextAccessor; private readonly IUserService _userService; private IUser? _currentUser; diff --git a/tests/Umbraco.TestData/LoadTestController.cs b/tests/Umbraco.TestData/LoadTestController.cs index 20ad1b5dfcc1..121af67f5db3 100644 --- a/tests/Umbraco.TestData/LoadTestController.cs +++ b/tests/Umbraco.TestData/LoadTestController.cs @@ -28,7 +28,7 @@ public class LoadTestController : Controller "; private static readonly Random s_random = new(); - private static readonly object s_locko = new(); + private static readonly Lock s_locko = new(); private static volatile int s_containerId = -1; diff --git a/tests/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTestBase.cs b/tests/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTestBase.cs index 9e4911d783fe..45eef4b1d147 100644 --- a/tests/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTestBase.cs +++ b/tests/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTestBase.cs @@ -27,7 +27,7 @@ namespace Umbraco.Cms.Tests.Integration.Testing; [NonParallelizable] public abstract class UmbracoIntegrationTestBase { - private static readonly object s_dbLocker = new(); + private static readonly Lock s_dbLocker = new(); private static ITestDatabase? s_dbInstance; private static TestDbMeta s_fixtureDbMeta; private static int s_testCount = 1; diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/LocksTests.cs b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/LocksTests.cs index 93e47821958c..0f373088e4ae 100644 --- a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/LocksTests.cs +++ b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/LocksTests.cs @@ -191,7 +191,7 @@ public void ConcurrentWritersTest() const int threadCount = 8; var threads = new Thread[threadCount]; var exceptions = new Exception[threadCount]; - var locker = new object(); + Lock locker = new(); var acquired = 0; var entered = 0; var ms = new AutoResetEvent[threadCount]; diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Persistence.EFCore/Scoping/EFCoreLockTests.cs b/tests/Umbraco.Tests.Integration/Umbraco.Persistence.EFCore/Scoping/EFCoreLockTests.cs index 200da2557bf6..2d1562f66878 100644 --- a/tests/Umbraco.Tests.Integration/Umbraco.Persistence.EFCore/Scoping/EFCoreLockTests.cs +++ b/tests/Umbraco.Tests.Integration/Umbraco.Persistence.EFCore/Scoping/EFCoreLockTests.cs @@ -125,7 +125,7 @@ public void ConcurrentReadersTest() const int threadCount = 8; var threads = new Thread[threadCount]; var exceptions = new Exception[threadCount]; - var locker = new object(); + Lock locker = new(); var acquired = 0; var m2 = new ManualResetEventSlim(false); var m1 = new ManualResetEventSlim(false);