Skip to content

Commit 2c0b22a

Browse files
CopilotCarnaViire
andcommitted
Update LifetimeTrackingHttpMessageHandler.Dispose to properly dispose inner handler
Co-authored-by: CarnaViire <3184057+CarnaViire@users.noreply.github.com>
1 parent 2d3b136 commit 2c0b22a

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

src/libraries/Microsoft.Extensions.Http/src/DefaultHttpClientFactory.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ public void Dispose()
361361
{
362362
if (entry != null)
363363
{
364+
// During explicit disposal, don't check if can dispose - just force disposal
364365
disposables.Add(entry);
365366
}
366367
}

src/libraries/Microsoft.Extensions.Http/src/ExpiredHandlerTrackingEntry.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public void Dispose()
3535
{
3636
try
3737
{
38+
// Always dispose the inner handler when explicitly disposing
3839
InnerHandler.Dispose();
3940
}
4041
finally

src/libraries/Microsoft.Extensions.Http/src/LifetimeTrackingHttpMessageHandler.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ public LifetimeTrackingHttpMessageHandler(HttpMessageHandler innerHandler)
1818
protected override void Dispose(bool disposing)
1919
{
2020
// The lifetime of this is tracked separately by ActiveHandlerTrackingEntry
21+
// During explicit disposal, we need to dispose the inner handler
22+
if (disposing)
23+
{
24+
base.Dispose(disposing);
25+
}
2126
}
2227
}
2328
}

0 commit comments

Comments
 (0)