Skip to content

Commit

Permalink
😊 修复 日志上下文字典使用 ContainsKey 有线程安全问题导致出现重复 Key 异常
Browse files Browse the repository at this point in the history
  • Loading branch information
MonkSoul committed Aug 15, 2024
1 parent 8d77141 commit 53665b5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static LogContext Set(this LogContext logContext, object key, object valu

logContext.Properties ??= new Dictionary<object, object>();

if (logContext.Properties.ContainsKey(key)) logContext.Properties.Remove(key);
logContext.Properties.Remove(key);
logContext.Properties.Add(key, value);
return logContext;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static LogContext Set(this LogContext logContext, object key, object valu

logContext.Properties ??= new Dictionary<object, object>();

if (logContext.Properties.ContainsKey(key)) logContext.Properties.Remove(key);
logContext.Properties.Remove(key);
logContext.Properties.Add(key, value);
return logContext;
}
Expand Down

0 comments on commit 53665b5

Please sign in to comment.