Skip to content

Commit fb2f914

Browse files
rajaniraogbuehler
andauthored
fix: make JsonDiffer thread safe (#683)
Concurrent execution of JsonDiffer() on multiple threads causes ArgumentOutOfRangeException during Dispose(). Create new instance of JsonPatchDeltaFormatter for every call. Please refer to this issue: #682 --------- Co-authored-by: AVEVA\rajani.rao <[email protected]> Co-authored-by: Christoph Bühler <[email protected]>
1 parent 08ea58c commit fb2f914

File tree

1 file changed

+3
-3
lines changed
  • src/KubeOps.Operator.Web/Webhooks/Admission/Mutation

1 file changed

+3
-3
lines changed

src/KubeOps.Operator.Web/Webhooks/Admission/Mutation/JsonDiffer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ namespace KubeOps.Operator.Web.Webhooks.Admission.Mutation;
99

1010
internal static class JsonDiffer
1111
{
12-
private static readonly JsonPatchDeltaFormatter Formatter = new();
13-
1412
public static string Base64Diff(this JsonNode from, object? to)
1513
{
14+
var formatter = new JsonPatchDeltaFormatter();
15+
1616
var toToken = GetNode(to);
17-
var patch = from.Diff(toToken, Formatter)!;
17+
var patch = from.Diff(toToken, formatter)!;
1818

1919
return Convert.ToBase64String(Encoding.UTF8.GetBytes(patch.ToString()));
2020
}

0 commit comments

Comments
 (0)