Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
Clone the JsonSerilizerOption instead of modifying it (#2280)
Browse files Browse the repository at this point in the history
  • Loading branch information
chkeita authored Aug 22, 2022
1 parent d83723b commit dc3ab3d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/ApiService/ApiService/onefuzzlib/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,18 @@ public class Events : IEvents {
private readonly ILogTracer _log;
private readonly IContainers _containers;
private readonly ICreds _creds;
private readonly JsonSerializerOptions _options;

public Events(IQueue queue, IWebhookOperations webhook, ILogTracer log, IContainers containers, ICreds creds) {
_queue = queue;
_webhook = webhook;
_log = log;
_containers = containers;
_creds = creds;
_options = new JsonSerializerOptions(EntityConverter.GetJsonSerializerOptions()) {
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
};
_options.Converters.Add(new RemoveUserInfo());
}

public async Async.Task QueueSignalrEvent(EventMessage message) {
Expand All @@ -58,10 +63,7 @@ public async Async.Task SendEvent(BaseEvent anEvent) {
}

public void LogEvent(BaseEvent anEvent) {
var options = EntityConverter.GetJsonSerializerOptions();
options.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
options.Converters.Add(new RemoveUserInfo());
var serializedEvent = JsonSerializer.Serialize(anEvent, anEvent.GetType(), options);
var serializedEvent = JsonSerializer.Serialize(anEvent, anEvent.GetType(), _options);
_log.WithTag("Event Type", anEvent.GetEventType().ToString()).Info($"sending event: {anEvent.GetEventType()} - {serializedEvent}");
}
}
Expand Down

0 comments on commit dc3ab3d

Please sign in to comment.