[dotnet] Add a lock around child resource manipulation (#5563)

[dotnet] Add a lock around child resource manipulation to prevent hashset concurrency issue

Co-authored-by: Justin Van Patten <jvp@justinvp.com>
This commit is contained in:
Mikhail Shilkov 2020-10-13 19:28:57 +02:00 committed by GitHub
parent ceec3eac0f
commit 4f07891595
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

View file

@ -57,6 +57,9 @@ CHANGELOG
- [sdk/python] Fix ResourceOptions annotations and doc strings.
[#5559](https://github.com/pulumi/pulumi/pull/5559)
- [sdk/dotnet] Fix HashSet concurrency issue.
[#5563](https://github.com/pulumi/pulumi/pull/5563)
## 2.11.2 (2020-10-01)
- feat(autoapi): expose EnvVars LocalWorkspaceOption to set in ctor

View file

@ -151,7 +151,12 @@ namespace Pulumi
{
if (resource is ComponentResource)
{
AddTransitivelyReferencedChildResourcesOfComponentResources(resource.ChildResources, result);
HashSet<Resource> childResources;
lock (resource.ChildResources)
{
childResources = new HashSet<Resource>(resource.ChildResources);
}
AddTransitivelyReferencedChildResourcesOfComponentResources(childResources, result);
}
}
}

View file

@ -188,7 +188,10 @@ namespace Pulumi
if (options.Parent != null)
{
this._parentResource = options.Parent;
this._parentResource.ChildResources.Add(this);
lock (this._parentResource.ChildResources)
{
this._parentResource.ChildResources.Add(this);
}
if (options.Protect == null)
options.Protect = options.Parent._protect;