Skip to content

Commit 812265c

Browse files
authored
Update graceful-shutdown.md - Avoid memory leak on combined CancellationTokenSource (#6089)
1 parent c31406f commit 812265c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

samples/kubernetes/graceful-shutdown/graceful-shutdown.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ app.Use((httpContext, next) =>
4949
{
5050
var hostLifetime = httpContext.RequestServices.GetRequiredService<IHostApplicationLifetime>();
5151
var originalCt = httpContext.RequestAborted;
52-
var combinedCt = CancellationTokenSource.CreateLinkedTokenSource(originalCt, hostLifetime.ApplicationStopping).Token;
53-
httpContext.RequestAborted = combinedCt;
52+
using var combinedCts = CancellationTokenSource.CreateLinkedTokenSource(originalCt, hostLifetime.ApplicationStopping);
53+
httpContext.RequestAborted = combinedCts.Token;
5454
return next(httpContext);
5555
});
5656
```

0 commit comments

Comments
 (0)