Skip to content

Commit f29e4cd

Browse files
committed
fix: moves parse async out of the condition since it always accepts a cancellation token
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
1 parent 32373ec commit f29e4cd

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/Microsoft.Graph.Core/Requests/BatchRequestBuilder.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,10 @@ private static async Task ThrowIfFailedResponseAsync(HttpResponseMessage httpRes
112112
{
113113
#if NET5_0_OR_GREATER
114114
using var responseContent = await httpResponseMessage.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
115-
using var document = await JsonDocument.ParseAsync(responseContent, cancellationToken: cancellationToken).ConfigureAwait(false);
116115
#else
117116
using var responseContent = await httpResponseMessage.Content.ReadAsStreamAsync().ConfigureAwait(false);
118-
using var document = await JsonDocument.ParseAsync(responseContent).ConfigureAwait(false);
119117
#endif
118+
using var document = await JsonDocument.ParseAsync(responseContent, cancellationToken: cancellationToken).ConfigureAwait(false);
120119
var parsable = new JsonParseNode(document.RootElement);
121120
throw new ServiceException(ErrorConstants.Messages.BatchRequestError, httpResponseMessage.Headers, (int)httpResponseMessage.StatusCode, new Exception(parsable.GetErrorMessage()));
122121
}

0 commit comments

Comments
 (0)