Skip to content

Commit 0412152

Browse files
committed
Fix returning temporary mapper on concurrent access to BsonMapper
1 parent 91f6c68 commit 0412152

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

LiteDB/Client/Mapper/BsonMapper.GetEntityMapper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ internal EntityMapper GetEntityMapper(Type type)
2828
try
2929
{
3030
// We need to add the empty shell, because ``BuildEntityMapper`` may use this method recursively
31-
mapper = new EntityMapper(type, cts.Token);
32-
EntityMapper addedMapper = _entities.GetOrAdd(type, mapper);
33-
if (ReferenceEquals(addedMapper, mapper))
31+
var newMapper = new EntityMapper(type, cts.Token);
32+
mapper = _entities.GetOrAdd(type, newMapper);
33+
if (ReferenceEquals(mapper, newMapper))
3434
{
3535
try
3636
{

0 commit comments

Comments
 (0)