App context switch to allow blocking or non-blocking GetConfiguration#3106
Merged
keegan-caruso merged 14 commits intodevfrom Feb 6, 2025
Merged
App context switch to allow blocking or non-blocking GetConfiguration#3106keegan-caruso merged 14 commits intodevfrom
keegan-caruso merged 14 commits intodevfrom
Conversation
Contributor
There was a problem hiding this comment.
Copilot reviewed 5 out of 8 changed files in this pull request and generated no comments.
Files not reviewed (3)
- test/Microsoft.IdentityModel.Tokens.Tests/Telemetry/MockTelemetryClient.cs: Evaluated as low risk
- src/Microsoft.IdentityModel.Protocols/Configuration/ConfigurationManager.cs: Evaluated as low risk
- test/Microsoft.IdentityModel.Protocols.OpenIdConnect.Tests/ConfigurationManagerTelemetryTests.cs: Evaluated as low risk
Comments suppressed due to low confidence (1)
test/Microsoft.IdentityModel.TestUtils/ResetAppContextSwitchesAttribute.cs:11
- [nitpick] Consider renaming the class to 'ResetAppContextSwitches' for clarity and conciseness.
public class ResetAppContextSwitchesAttribute : BeforeAfterTestAttribute
GeoK
reviewed
Jan 30, 2025
src/Microsoft.IdentityModel.Protocols/Configuration/ConfigurationManager_Blocking.cs
Show resolved
Hide resolved
GeoK
reviewed
Jan 30, 2025
src/Microsoft.IdentityModel.Protocols/Configuration/ConfigurationManager.cs
Outdated
Show resolved
Hide resolved
GeoK
reviewed
Jan 30, 2025
src/Microsoft.IdentityModel.Protocols/Configuration/ConfigurationManager.cs
Outdated
Show resolved
Hide resolved
SummarySummary
CoverageMicrosoft.IdentityModel.JsonWebTokens - 80.3%
|
src/Microsoft.IdentityModel.Protocols/Configuration/ConfigurationManager_Blocking.cs
Show resolved
Hide resolved
src/Microsoft.IdentityModel.Protocols/Configuration/ConfigurationManager_Blocking.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.IdentityModel.Protocols/Configuration/ConfigurationManager.cs
Outdated
Show resolved
Hide resolved
0b87a5f to
2cb1b50
Compare
keegan-caruso
commented
Jan 31, 2025
2cb1b50 to
cda14f3
Compare
SummarySummary
CoverageMicrosoft.IdentityModel.JsonWebTokens - 80.3%
|
pmaytak
reviewed
Jan 31, 2025
src/Microsoft.IdentityModel.Protocols/Configuration/ConfigurationManager.cs
Show resolved
Hide resolved
src/Microsoft.IdentityModel.Protocols/Configuration/ConfigurationManager.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.IdentityModel.Protocols/Configuration/ConfigurationManager.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.IdentityModel.Protocols/Configuration/ConfigurationManager.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.IdentityModel.Protocols/Configuration/ConfigurationManager.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.IdentityModel.Protocols/Configuration/ConfigurationManager.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.IdentityModel.Protocols/Configuration/ConfigurationManager.cs
Show resolved
Hide resolved
src/Microsoft.IdentityModel.Protocols/Configuration/ConfigurationManager.cs
Show resolved
Hide resolved
SummarySummary
CoverageMicrosoft.IdentityModel.JsonWebTokens - 80.3%
|
SummarySummary
CoverageMicrosoft.IdentityModel.JsonWebTokens - 80.3%
|
pmaytak
reviewed
Feb 6, 2025
src/Microsoft.IdentityModel.Protocols/Configuration/ConfigurationManager.cs
Show resolved
Hide resolved
src/Microsoft.IdentityModel.Protocols/Configuration/ConfigurationManager.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.IdentityModel.Protocols/Configuration/ConfigurationManager.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.IdentityModel.Protocols/Configuration/ConfigurationManager.cs
Show resolved
Hide resolved
src/Microsoft.IdentityModel.Tokens/Telemetry/ITelemetryClient.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.IdentityModel.Tokens/Telemetry/TelemetryClient.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.IdentityModel.Tokens/Telemetry/TelemetryClient.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.IdentityModel.Tokens/Telemetry/TelemetryDataRecorder.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.IdentityModel.Tokens/Telemetry/TelemetryDataRecorder.cs
Outdated
Show resolved
Hide resolved
added 10 commits
February 6, 2025 09:24
- Tests need to be in a collection - Remove unneeded change
- Remove LastRefresh
This was referenced Jan 21, 2026
This was referenced Jan 30, 2026
This was referenced Feb 9, 2026
Closed
This was referenced Feb 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
App context switch to allow blocking or non-blocking GetConfiguration
Stress testing showed that the current non-blocking implementation wasn't always triggered as expected, moving to an AutoResetEvent fixed this.
How Configuration is Updated Now:
Asynchronous Updates: The configuration can be updated asynchronously using background tasks. The method. The method to trigger the background task was updated to a AutoResetEvent.
Blocking vs Non-Blocking: The AppContextSwitches.UpdateConfigAsBlocking switch determines whether the configuration update should block other requests. If this switch is enabled, the method RequestRefreshBlocking is called; otherwise, RequestRefreshBackgroundThread is used.
Telemetry: The method TelemetryForUpdate handles logging the mode of update (manual or automatic) to a telemetry client.
These changes aim to improve the efficiency and responsiveness of the configuration update process by leveraging background tasks and signals.
Adds ShutdownBackgroundTask() method to ConfigurationManager to stop the background task.
Introduce ResetAppContextSwitches to have deterministic reset per test that uses an app context, this also serializes tests.
Adds
Fixes #3082