Skip to content

Commit

Permalink
fix NullReferenceException (#335)
Browse files Browse the repository at this point in the history
  • Loading branch information
leisurelyclouds authored and yang-xiaodong committed May 5, 2019
1 parent fbda6e2 commit e8931b3
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/DotNetCore.CAP/Diagnostics/TracingHeaders.cs
Expand Up @@ -9,7 +9,7 @@ namespace DotNetCore.CAP.Diagnostics
{
public class TracingHeaders : IEnumerable<KeyValuePair<string, string>>
{
private List<KeyValuePair<string, string>> _dataStore;
private List<KeyValuePair<string, string>> _dataStore = new List<KeyValuePair<string, string>>();

public IEnumerator<KeyValuePair<string, string>> GetEnumerator()
{
Expand All @@ -23,11 +23,6 @@ IEnumerator IEnumerable.GetEnumerator()

public void Add(string name, string value)
{
if (_dataStore == null)
{
_dataStore = new List<KeyValuePair<string, string>>();
}

_dataStore.Add(new KeyValuePair<string, string>(name, value));
}

Expand All @@ -46,4 +41,4 @@ public void Cleaar()
_dataStore?.Clear();
}
}
}
}

0 comments on commit e8931b3

Please sign in to comment.