fix issue where HTTP2 connection could be scavenged but not disposed (#62225)
authorGeoff Kizer <geoffrek@microsoft.com>
Wed, 1 Dec 2021 14:33:24 +0000 (06:33 -0800)
committerGitHub <noreply@github.com>
Wed, 1 Dec 2021 14:33:24 +0000 (09:33 -0500)
Co-authored-by: Geoffrey Kizer <geoffrek@windows.microsoft.com>
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs

index 75b83fb..c51adc8 100644 (file)
@@ -2004,7 +2004,8 @@ namespace System.Net.Http
                 if (freeIndex < list.Count)
                 {
                     // We know the connection at freeIndex is unusable, so dispose of it.
-                    toDispose ??= new List<HttpConnectionBase> { list[freeIndex] };
+                    toDispose ??= new List<HttpConnectionBase>();
+                    toDispose.Add(list[freeIndex]);
 
                     // Find the first item after the one to be removed that should be kept.
                     int current = freeIndex + 1;