Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Ensure same lock is used to read and write Dictionary in AppContext #2729

Merged
merged 1 commit into from
Jan 20, 2016
Merged

Ensure same lock is used to read and write Dictionary in AppContext #2729

merged 1 commit into from
Jan 20, 2016

Conversation

JonHanna
Copy link

Fixes #2727

isEnabled = overrideValue;

// Update the switch in the dictionary to mark it as 'checked for override'
SetSwitch(switchName, isEnabled);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just explicitly set the value here. Calling SetSwitch is going to go through a lot more checks and code before it sets the value.

@AlexGhiondea
Copy link

@JonHanna thanks for doing this!

Unfortunatelly, what you see here is not the entire code that uses AppContext and makes some assumptions about they way it is implemented.

With that in mind, for this change, I would like to keep it as surgical as possible in order to not break some of the assumptions made by the rest of the code.

I know it is difficult to fix something when you can't see all the parts.

@JonHanna
Copy link
Author

I think the code in that file should have been enough to realise that that was a bad commit. I broke my rule about always waiting a few minutes before clicking "Create Pull Request", and I never don't regret it when I break that rule.

A more restrained update has been made.

@AlexGhiondea
Copy link

Thank you for the update! LGTM!

I am going to work on getting some of our tests for AppContext into the open to try and help with validating the changes to it!

@@ -157,11 +156,13 @@ public static void SetSwitch(string switchName, bool isEnabled)
if (switchName.Length == 0)
throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "switchName");

lock (s_syncLock)
SwitchValueState switchValue = (isEnabled ? SwitchValueState.HasTrueValue : SwitchValueState.HasFalseValue)
| SwitchValueState.HasLookedForOverride

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a missing trailing ';' which is causing the build break.

@JonHanna
Copy link
Author

Test Ubuntu x64 Release Build and Test

AlexGhiondea added a commit that referenced this pull request Jan 20, 2016
Ensure same lock is used to read and write Dictionary in AppContext
@AlexGhiondea AlexGhiondea merged commit b8a59ae into dotnet:master Jan 20, 2016
@JonHanna JonHanna deleted the fix_2727 branch January 20, 2016 08:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants