-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Make KestrelConfigurationLoader.Load safe to re-call #48137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
If it is called again and nothing has changed, it should do nothing. Part of dotnet#45801
| // Any endpoints that were removed from the last time endpoints were loaded are returned. | ||
| internal (List<ListenOptions>, List<ListenOptions>) Reload() | ||
| { | ||
| _reloadToken = Configuration.GetReloadToken(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| _reloadToken = Configuration.GetReloadToken(); | |
| _reloadToken = ReloadOnChange ? Configuration.GetReloadToken() : NullChangeToken.Singleton; |
We should not grab the token on load if KestrelConfigurationLoader.ReloadOnChange is false. That's what the is DoesNotReloadOnConfigurationChangeByDefault test is about. Normally it's true if you have a "default" host like WebApplication.
You'll need to add using Microsoft.Extensions.FileProviders too. Not the best namespace there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't change the existing IChangeToken handling, so I believe that test is still passing. I intentionally decoupled rebind-on-change from determine-if-reloading-would-be-redundant, but I'm open to discussion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why am I pulling in Microsoft.Extensions.FileProviders?
src/Servers/Kestrel/Kestrel/test/KestrelConfigurationLoaderTests.cs
Outdated
Show resolved
Hide resolved
src/Servers/Kestrel/Kestrel/test/KestrelConfigurationLoaderTests.cs
Outdated
Show resolved
Hide resolved
...so that `Load` can retain its current behavior. Also, only consume the change token when `ReloadOnChange` is true.
halter73
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
So that configuration-based certs will be considered, if necessary. Largely salvaged from dotnet#48056 Builds on dotnet#48137 Fixes dotnet#45801
If it is called again and nothing has changed, it should do nothing.
Part of #45801