Skip to content

Commit

Permalink
Fixes a concurrency issue when working with versions => dotnet/corefx…
Browse files Browse the repository at this point in the history
  • Loading branch information
mynkow committed Mar 21, 2019
1 parent 0c9328e commit 38f9e29
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ public ProjectionVersions Get(string projectionName)
{
if (string.IsNullOrEmpty(projectionName)) throw new ArgumentNullException(nameof(projectionName));

var versions = store.GetOrAdd(projectionName, new ProjectionVersions());
return versions;
return store.GetOrAdd(projectionName, new ProjectionVersions());
}

public void Cache(ProjectionVersion version)
{
if (ReferenceEquals(null, version)) throw new ArgumentNullException(nameof(version));
var versions = store.GetOrAdd(version.ProjectionName, new ProjectionVersions());
versions.Add(version);
if (version is null) throw new ArgumentNullException(nameof(version));

ProjectionVersions versions = Get(version.ProjectionName);
lock (versions)
{
versions.Add(version);
}
}
}
}

0 comments on commit 38f9e29

Please sign in to comment.