Skip to content

HttpSysRequestDelegationFeature - DelegationRule throws NullReferenceException on Dispose #26982

@NGloreous

Description

@NGloreous

Describe the bug

When disposing a DelegationRule, if the call to HttpCloseUrlGroup within UrlGroup.Dispose() fails then a NullReferenceException happens because _logger is not initialized in the constructor used by the HttpSysRequestDelegationFeature.

To Reproduce

namespace Sample
{
    public class Startup
    {
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostApplicationLifetime lifetime, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            
            var delegator = app.ServerFeatures.Get<IServerDelegationFeature>();
            var rule = delegator.CreateDelegationRule("DefaultAppPool", "http://*:80/");
            rule.Dispose();
        }
    }
}

Exceptions (if any)

System.AggregateException: One or more errors occurred. (Value cannot be null. (Parameter 'logger'))
---> System.ArgumentNullException: Value cannot be null. (Parameter 'logger')
at Microsoft.Extensions.Logging.LoggerExtensions.Log(ILogger logger, LogLevel logLevel, EventId eventId, Exception exception, String message, Object[] args)
at Microsoft.Extensions.Logging.LoggerExtensions.LogError(ILogger logger, EventId eventId, String message, Object[] args)
at Microsoft.AspNetCore.Server.HttpSys.UrlGroup.Dispose()
at Microsoft.AspNetCore.Server.HttpSys.DelegationRule.Dispose()

Metadata

Metadata

Assignees

Labels

area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsfeature-httpsys

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions