Skip to content

Commit

Permalink
Fix memory leak by disposing JsonDocument properly
Browse files Browse the repository at this point in the history
  • Loading branch information
mtmk committed Nov 21, 2024
1 parent 429f665 commit 6a47672
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/NATS.Client.JetStream/NatsJSContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ internal async ValueTask<NatsResult<NatsJSResponse<TResponse>>> TryJSRequestAsyn
// .NET 6 new APIs to the rescue: we can read the buffer once
// by deserializing into a document, inspect and using the new
// API deserialize to the final type from the document.
var jsonDocument = msg.Data;
using var jsonDocument = msg.Data;

if (jsonDocument.RootElement.TryGetProperty("error", out var errorElement))
{
Expand Down

0 comments on commit 6a47672

Please sign in to comment.