Skip to content

Commit

Permalink
Removed ConfigureAwait from Middleware since user-context is relevant (
Browse files Browse the repository at this point in the history
  • Loading branch information
snakefoot authored May 26, 2024
1 parent 24baed0 commit 6a7ecfc
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public async Task<ActionResult> TestLog([FromBody]string request)
{
try
{
await Task.Delay(5).ConfigureAwait(false);
await Task.Delay(5);
throw new ApplicationException("Test log message");
}
catch (Exception ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public async Task Invoke(HttpContext context)
AspNetBufferingTargetWrapper.OnBeginRequest(context);

// Execute the next class in the HTTP pipeline, this can be the next middleware or the actual handler
await _next(context).ConfigureAwait(false);
await _next(context); // NOSONAR
}
finally
{
Expand Down
2 changes: 1 addition & 1 deletion src/NLog.Web.AspNetCore/NLogRequestPostedBodyMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public async Task Invoke(HttpContext context)
// This is required, otherwise reading the request will destructively read the request
context.Request.EnableBuffering();

var requestBody = await ReadPostedBodyFromStream(context.Request.Body).ConfigureAwait(false);
var requestBody = await ReadPostedBodyFromStream(context.Request.Body); // NOSONAR
if (!string.IsNullOrEmpty(requestBody))
{
context.Items[AspNetRequestPostedBodyLayoutRenderer.NLogPostedRequestBodyKey] = requestBody;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void HttpRequestExceptionFilterTest()
{
try
{
middlewareInstance.Invoke(defaultContext).ConfigureAwait(false).GetAwaiter().GetResult();
middlewareInstance.Invoke(defaultContext).GetAwaiter().GetResult();
}
catch
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public void ContentLengthTooLargeTest()

// Act
var middlewareInstance = new NLogRequestPostedBodyMiddleware(Next,NLogRequestPostedBodyMiddlewareOptions.Default);
middlewareInstance.Invoke(defaultContext).ConfigureAwait(false).GetAwaiter().GetResult();
middlewareInstance.Invoke(defaultContext).GetAwaiter().GetResult();

// Assert
Assert.NotNull(defaultContext.Items);
Expand Down

0 comments on commit 6a7ecfc

Please sign in to comment.