Skip to content

Commit 61699d9

Browse files
committed
fix infinity loop when Scan Config
1 parent 1aab797 commit 61699d9

File tree

3 files changed

+4
-14
lines changed

3 files changed

+4
-14
lines changed

src/Mapster.Tests/WhenRegisteringAndMappingRace.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ public void Explicit_Mapping_Requirementd()
104104
var simplePoco = new WhenAddingCustomMappings.SimplePoco { Id = Guid.NewGuid(), Name = "TestName" };
105105

106106
TypeAdapterConfigConcurrency<WhenAddingCustomMappings.SimplePoco, WeirdPoco>.NewConfig()
107-
108107
.Map(dest => dest.IHaveADifferentId, src => src.Id)
109108
.Map(dest => dest.MyNamePropertyIsDifferent, src => src.Name)
110109
.Ignore(dest => dest.Children)
@@ -143,8 +142,6 @@ public void Scan_Explicit_Mapping_Requirementd()
143142

144143
TypeAdapterConfigFactory.GlobalSettings.Scan(Assembly.GetExecutingAssembly());
145144

146-
//TypeAdapter.Adapt<WhenAddingCustomMappings.SimplePoco, WeirdPoco>(simplePoco);
147-
148145
for (int i = 0; i < 100; i++)
149146
{
150147
Parallel.Invoke(

src/Mapster/TypeAdapterConfig/TypeAdapterConfig.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,8 @@ public LambdaExpression CreateMapExpression(TypeTuple tuple, MapType mapType)
104104
}
105105
finally
106106
{
107-
if (ConcurrencyEnvironment)
108-
{
109-
Configure.Set();
110-
}
111-
107+
Configure.Set();
108+
112109
if (fork != null)
113110
context.Configs.Pop();
114111
context.Running.Remove(tuple);

src/Mapster/TypeAdapterConfig/TypeAdapterConfigIRegisterExtentions.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ public static void Apply(this ITypeAdapterConfig config, IEnumerable<Lazy<IRegis
3636
/// <returns>A list of registered mappings</returns>
3737
public static IList<IRegister> Scan(this ITypeAdapterConfig config, params Assembly[] assemblies)
3838
{
39-
if (config.ConcurrencyEnvironment)
40-
{
41-
config.Configure.WaitOne(-1, false);
42-
}
43-
39+
4440
List<IRegister> registers = assemblies.Select(assembly => assembly.GetLoadableTypes()
4541
.Where(x => typeof(IRegister).GetTypeInfo().IsAssignableFrom(x.GetTypeInfo()) && x.GetTypeInfo().IsClass && !x.GetTypeInfo().IsAbstract))
4642
.SelectMany(registerTypes =>
@@ -70,7 +66,7 @@ public static IList<IRegister> ScanConcurrency(this ITypeAdapterConfig config, p
7066
if (config is IConfigConcurrency cfg2)
7167
{
7268
config.Configure.Set();
73-
cfg2.ConcurrencyEnvironment = false;
69+
cfg2.ConcurrencyEnvironment = false;
7470
}
7571
}
7672

0 commit comments

Comments
 (0)