From 97c524c335ef525da4b6fc59f8eb61e70ec233b9 Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Fri, 3 May 2024 09:14:32 -0700 Subject: [PATCH] Add EnableThreadSafetyChecks support and Enable it for all test --- .../OrchardCore.Data.YesSql.Abstractions/YesSqlOptions.cs | 2 ++ .../OrchardCoreBuilderExtensions.cs | 3 ++- test/OrchardCore.Tests/Apis/Context/SiteStartup.cs | 7 +++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/OrchardCore/OrchardCore.Data.YesSql.Abstractions/YesSqlOptions.cs b/src/OrchardCore/OrchardCore.Data.YesSql.Abstractions/YesSqlOptions.cs index a0b92c24ae8..574f6f31731 100644 --- a/src/OrchardCore/OrchardCore.Data.YesSql.Abstractions/YesSqlOptions.cs +++ b/src/OrchardCore/OrchardCore.Data.YesSql.Abstractions/YesSqlOptions.cs @@ -15,4 +15,6 @@ public class YesSqlOptions public IAccessorFactory VersionAccessorFactory { get; set; } public IContentSerializer ContentSerializer { get; set; } + + public bool EnableThreadSafetyChecks { get; set; } } diff --git a/src/OrchardCore/OrchardCore.Data.YesSql/OrchardCoreBuilderExtensions.cs b/src/OrchardCore/OrchardCore.Data.YesSql/OrchardCoreBuilderExtensions.cs index 47ee8ca320e..22b6668eb17 100644 --- a/src/OrchardCore/OrchardCore.Data.YesSql/OrchardCoreBuilderExtensions.cs +++ b/src/OrchardCore/OrchardCore.Data.YesSql/OrchardCoreBuilderExtensions.cs @@ -186,10 +186,11 @@ private static YesSql.Configuration GetStoreConfiguration(IServiceProvider sp, Y { CommandsPageSize = yesSqlOptions.CommandsPageSize, QueryGatingEnabled = yesSqlOptions.QueryGatingEnabled, + EnableThreadSafetyChecks = yesSqlOptions.EnableThreadSafetyChecks, TableNameConvention = tableNameFactory.Create(databaseTableOptions), IdentityColumnSize = Enum.Parse(databaseTableOptions.IdentityColumnSize), Logger = loggerFactory.CreateLogger("YesSql"), - ContentSerializer = new DefaultContentJsonSerializer(serializerOptions.Value.SerializerOptions) + ContentSerializer = new DefaultContentJsonSerializer(serializerOptions.Value.SerializerOptions), }; if (yesSqlOptions.IdGenerator != null) diff --git a/test/OrchardCore.Tests/Apis/Context/SiteStartup.cs b/test/OrchardCore.Tests/Apis/Context/SiteStartup.cs index d130cdc7d99..d96cca600b0 100644 --- a/test/OrchardCore.Tests/Apis/Context/SiteStartup.cs +++ b/test/OrchardCore.Tests/Apis/Context/SiteStartup.cs @@ -1,3 +1,4 @@ +using OrchardCore.Data.YesSql; using OrchardCore.Modules; using OrchardCore.Modules.Manifest; using OrchardCore.Recipes.Services; @@ -26,6 +27,12 @@ public void ConfigureServices(IServiceCollection services) ) .ConfigureServices(collection => { + collection.Configure(options => + { + // To ensure we don't encounter any concurrent issue, enable EnableThreadSafetyChecks for all test. + options.EnableThreadSafetyChecks = true; + }); + collection.AddScoped(); collection.AddScoped(sp =>