-
Notifications
You must be signed in to change notification settings - Fork 124
Fix session manager bug #581
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
Merged
+108
−8
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6c598af
fix bug that session manager will be skipped if feature definition is…
zhiyuanliang-ms 3363030
add test
zhiyuanliang-ms 11b9273
always set evaluation result to session manager
zhiyuanliang-ms 698240f
Merge branch 'main' into zhiyuanliang/fix-session-manager
zhiyuanliang-ms File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
| // | ||
| using Microsoft.FeatureManagement; | ||
| using System.Collections.Concurrent; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace Tests.FeatureManagement | ||
| { | ||
| class TestSessionManager : ISessionManager | ||
| { | ||
| private readonly ConcurrentDictionary<string, bool> _session = new ConcurrentDictionary<string, bool>(); | ||
|
|
||
| public Task SetAsync(string featureName, bool enabled) | ||
| { | ||
| _session[featureName] = enabled; | ||
|
|
||
| return Task.CompletedTask; | ||
| } | ||
|
|
||
| public Task<bool?> GetAsync(string featureName) | ||
| { | ||
| if (_session.TryGetValue(featureName, out bool enabled)) | ||
| { | ||
| return Task.FromResult<bool?>(enabled); | ||
| } | ||
|
|
||
| return Task.FromResult<bool?>(null); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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 also think that if there is no value in the session manager, then it should be written to what the feature manager returns, i.e. the default value.
FeatureManagement-Dotnet/src/Microsoft.FeatureManagement/FeatureManager.cs
Lines 275 to 278 in 57f5f93
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.
The current logic is that if feature definition is not null, then feature manager will do the feature evaluation and the result will be set to session manager.
Did I miss something?
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.
It doesn't matter whether a feature definition exists; if the feature manager returns a result and doesn't throw an exception, the same result must be set in the session manager.
Test case
Step 4 is currently missing.
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 believe this is the current behavior (when feature definition is not null).
We introduced the bug in v4. The bug is when feature definition is null, the result won't be set to session manage, I explained it in this 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.
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 see. Updated. Thanks!