From e8931b32fc666a4ae822ca5a98cf1ccdc01f582a Mon Sep 17 00:00:00 2001 From: leisurelyclouds Date: Sun, 5 May 2019 16:50:38 +0800 Subject: [PATCH] fix NullReferenceException (#335) --- src/DotNetCore.CAP/Diagnostics/TracingHeaders.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/DotNetCore.CAP/Diagnostics/TracingHeaders.cs b/src/DotNetCore.CAP/Diagnostics/TracingHeaders.cs index 11093d4..8fb7e21 100644 --- a/src/DotNetCore.CAP/Diagnostics/TracingHeaders.cs +++ b/src/DotNetCore.CAP/Diagnostics/TracingHeaders.cs @@ -9,7 +9,7 @@ namespace DotNetCore.CAP.Diagnostics { public class TracingHeaders : IEnumerable> { - private List> _dataStore; + private List> _dataStore = new List>(); public IEnumerator> GetEnumerator() { @@ -23,11 +23,6 @@ namespace DotNetCore.CAP.Diagnostics public void Add(string name, string value) { - if (_dataStore == null) - { - _dataStore = new List>(); - } - _dataStore.Add(new KeyValuePair(name, value)); } @@ -46,4 +41,4 @@ namespace DotNetCore.CAP.Diagnostics _dataStore?.Clear(); } } -} \ No newline at end of file +}