Skip to content

Conversation

jkotas
Copy link
Member

@jkotas jkotas commented Sep 30, 2025

Fixes #109904

@Copilot Copilot AI review requested due to automatic review settings September 30, 2025 02:17
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a race condition in Microsoft.Extensions.Configuration tests where variable initialization and null checks were creating potential null reference exceptions during concurrent operations. The fix removes unnecessary null checks and initialization tracking variables, simplifying the code to use a do-while loop pattern that guarantees at least one execution.

Key changes:

  • Removed redundant null initialization and tracking variables
  • Replaced while loops with do-while loops to ensure variables are always assigned before assertions
  • Removed temporary instrumentation code that was added for debugging the race condition

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
ConfigurationTests.cs Simplified loop logic by removing optionsInitialized tracking and null initialization, using do-while pattern
EnvironmentVariablesTest.cs Removed debugging instrumentation code and applied same race condition fix with do-while pattern

Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-extensions-configuration
See info in area-owners.md if you want to be subscribed.

Copy link
Member

@tarekgh tarekgh left a comment

Choose a reason for hiding this comment

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

Thanks for fixing the issue and knowing the underlying reason causing the test failure!

@jkotas jkotas merged commit 617c885 into dotnet:main Sep 30, 2025
87 of 90 checks passed
@jkotas jkotas deleted the issue-109904 branch September 30, 2025 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test failure: Microsoft.Extensions.Configuration.EnvironmentVariables.Test.EnvironmentVariablesTest.BindingDoesNotThrowIfReloadedDuringBinding
2 participants