Skip to content

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Sep 27, 2021

Backport of #37039 to release/6.0

/cc @halter73

Customer Impact

This PR addresses two major issues:

  1. Given config sources that can only be loaded once (such as those backed by Stream), WebApplicationBuilder.Build() throws an InvalidOperationException.

    var builder = WebApplication.CreateBuilder();
    
    using Stream jsonStream = await GetJsonConfig();
    builder.Configuration.AddJsonStream(jsonStream);
    
    using var app = builder.Build();
    
    // ...
    Unhandled exception. System.InvalidOperationException: StreamConfigurationProviders cannot be loaded more than once.
       at Microsoft.Extensions.Configuration.StreamConfigurationProvider.Load()
       at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList`1 providers)
       at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
       at Microsoft.Extensions.Hosting.HostBuilder.BuildAppConfiguration()
       at Microsoft.Extensions.Hosting.HostBuilder.Build()
       at Microsoft.AspNetCore.Builder.WebApplicationBuilder.Build()
       at Program.<Main>$(String[] args) in C:\dev\halter73\NewTemplate\Program.cs:line 12
    
  2. Changes to configuration sources after build are not observed. This means that if appsettings.json is modified from:

    {
      "Logging": {
        "LogLevel": {
          "Default": "Warning"
        }
      }
    }

    to:

    {
      "Logging": {
        "LogLevel": {
          "Default": "Debug"
        }
      }
    }

    while the application is running, only logs with severity warning and higher will be logged until the application is restarted.

    After this change, a file change notification correctly updates the default log level to Debug and debug-level logs are emitted immediately.

Regression

The inability to notice configuration source changes was a regression between rc1 and rc2.

Testing

Manual testing. Added both end-to-end and unit regression tests.

Risk

Low. This change has undergone significant testing and review.

@github-actions github-actions bot requested a review from Tratcher as a code owner September 27, 2021 22:22
@ghost ghost added the area-runtime label Sep 27, 2021
@halter73 halter73 force-pushed the backport/pr-37039-to-release/6.0 branch from 15cf9da to 4d2a608 Compare October 4, 2021 19:18
@github-actions github-actions bot requested a review from Pilchie as a code owner October 4, 2021 19:18
@BrennanConroy BrennanConroy added the Servicing-approved Shiproom has approved the issue label Oct 5, 2021
@BrennanConroy BrennanConroy merged commit 3af938c into release/6.0 Oct 5, 2021
@BrennanConroy BrennanConroy deleted the backport/pr-37039-to-release/6.0 branch October 5, 2021 20:21
@ghost ghost added this to the 6.0.0 milestone Oct 5, 2021
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions Servicing-approved Shiproom has approved the issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants