Skip to content

Commit d79f6ba

Browse files
committed
Whoops...probably need some thread safety here.
1 parent b5a7813 commit d79f6ba

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

JSONAPI/Core/ModelManager.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,19 @@ public PropertyInfo GetIdProperty(Type type)
4242

4343
var idPropCache = _idProperties.Value;
4444

45-
if (idPropCache.TryGetValue(type, out idprop)) return idprop;
46-
47-
//TODO: Enable attribute-based determination
45+
lock (idPropCache)
46+
{
47+
if (idPropCache.TryGetValue(type, out idprop)) return idprop;
48+
49+
//TODO: Enable attribute-based determination
4850

49-
idprop = type.GetProperty("Id");
51+
idprop = type.GetProperty("Id");
5052

51-
if (idprop == null)
52-
throw new InvalidOperationException(String.Format("Unable to determine Id property for type {0}", type));
53+
if (idprop == null)
54+
throw new InvalidOperationException(String.Format("Unable to determine Id property for type {0}", type));
5355

54-
_idProperties.Value.Add(type, idprop);
56+
idPropCache.Add(type, idprop);
57+
}
5558

5659
return idprop;
5760
}

0 commit comments

Comments
 (0)