Skip to content

Commit 771d922

Browse files
Nindshalter73
authored andcommitted
Allow use of a default MemoryPoolFeature when IMemoryPoolFeature not set on ConnectionContext
This facilitates the use of other Transports other than sockets. When kestrel bound to MemoryTransport (Bedrock davidfowl/BedrockFramework#65) a NullReferenceException is thrown since the MemoryPoolFeature is not set on the ConnectionContext set in that Transport
1 parent ed6ca53 commit 771d922

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Servers/Kestrel/Core/src/Middleware/HttpConnectionMiddleware.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4+
using System.Buffers;
45
using System.Net;
56
using System.Threading.Tasks;
67
using Microsoft.AspNetCore.Connections;
@@ -33,7 +34,7 @@ public Task OnConnectionAsync(ConnectionContext connectionContext)
3334
Protocols = _protocols,
3435
ServiceContext = _serviceContext,
3536
ConnectionFeatures = connectionContext.Features,
36-
MemoryPool = memoryPoolFeature.MemoryPool,
37+
MemoryPool = memoryPoolFeature?.MemoryPool ?? System.Buffers.MemoryPool<byte>.Shared,
3738
Transport = connectionContext.Transport,
3839
LocalEndPoint = connectionContext.LocalEndPoint as IPEndPoint,
3940
RemoteEndPoint = connectionContext.RemoteEndPoint as IPEndPoint
@@ -43,5 +44,6 @@ public Task OnConnectionAsync(ConnectionContext connectionContext)
4344

4445
return connection.ProcessRequestsAsync(_application);
4546
}
47+
4648
}
4749
}

0 commit comments

Comments
 (0)