TestServer: Copy the feature collection to mitigate multi-threading
This commit is contained in:
parent
1e556e0b46
commit
64596d538b
|
|
@ -110,7 +110,13 @@ namespace Microsoft.AspNetCore.TestHost
|
|||
{
|
||||
// Sets HasStarted
|
||||
await _responseFeature.FireOnSendingHeadersAsync();
|
||||
_responseTcs.TrySetResult(_httpContext);
|
||||
// Copy the feature collection so we're not multi-threading on the same collection.
|
||||
var newFeatures = new FeatureCollection();
|
||||
foreach (var pair in _httpContext.Features)
|
||||
{
|
||||
newFeatures[pair.Key] = pair.Value;
|
||||
}
|
||||
_responseTcs.TrySetResult(new DefaultHttpContext(newFeatures));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue