[release/5.0] Fix null ref in UrlGroup.Dispose due to logger not set (#28494)

* Fix null ref in UrlGroup.Dispose due to logger not set

* PR Feedback: make _logger readonly

Co-authored-by: Nolan Glore <nglore@microsoft.com>
This commit is contained in:
Sourabh Shirhatti 2020-12-09 13:00:16 -08:00 committed by GitHub
parent 894f4cabae
commit 050c257590
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 3 deletions

View File

@ -24,7 +24,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
{
try
{
UrlGroup = new UrlGroup(this, UrlPrefix.Create(urlPrefix));
UrlGroup = new UrlGroup(this, UrlPrefix.Create(urlPrefix), logger);
}
catch
{

View File

@ -16,8 +16,9 @@ namespace Microsoft.AspNetCore.Server.HttpSys
private static readonly int RequestPropertyInfoSize =
Marshal.SizeOf<HttpApiTypes.HTTP_BINDING_INFO>();
private readonly ILogger _logger;
private ServerSession _serverSession;
private ILogger _logger;
private bool _disposed;
private bool _created;
@ -40,8 +41,10 @@ namespace Microsoft.AspNetCore.Server.HttpSys
Id = urlGroupId;
}
internal unsafe UrlGroup(RequestQueue requestQueue, UrlPrefix url)
internal unsafe UrlGroup(RequestQueue requestQueue, UrlPrefix url, ILogger logger)
{
_logger = logger;
ulong urlGroupId = 0;
_created = false;
var statusCode = HttpApi.HttpFindUrlGroupId(

View File

@ -326,6 +326,10 @@ namespace Microsoft.AspNetCore.Server.HttpSys
internal unsafe void Delegate(DelegationRule destination)
{
if (destination == null)
{
throw new ArgumentNullException(nameof(destination));
}
if (Request.HasRequestBodyStarted)
{
throw new InvalidOperationException("This request cannot be delegated, the request body has already started.");