Skip to content

feat: provider wrapper to support state race fix#1892

Draft
toddbaert wants to merge 1 commit intomainfrom
poc/fix-provider-init-race
Draft

feat: provider wrapper to support state race fix#1892
toddbaert wants to merge 1 commit intomainfrom
poc/fix-provider-init-race

Conversation

@toddbaert
Copy link
Member

WIP

@toddbaert toddbaert requested review from a team as code owners March 11, 2026 17:39
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a mechanism for feature providers to manage their own state, rather than the SDK managing it on their behalf. This is achieved through a new StateManagingProvider interface and modifications to the FeatureProviderStateManager to delegate state management when appropriate. This change is intended to address potential race conditions and improve the overall robustness of state management in the OpenFeature SDK.

Highlights

  • State Management: Introduces a StateManagingProvider interface to allow providers to manage their own state, rather than relying on the SDK to manage it.
  • Provider Wrapper: Modifies FeatureProviderStateManager to check if the delegate provider manages its own state, and if so, defers state management to the delegate.
  • Race Condition Fix: Aims to address a potential race condition where the SDK's state management could conflict with a provider's internal state management.
Changelog
  • FeatureProviderStateManager.java
    • Delegate state management to providers that implement StateManagingProvider.
  • StateManagingProvider.java
    • Introduce StateManagingProvider interface.
Activity
  • Introduced StateManagingProvider interface.
  • Modified FeatureProviderStateManager to support providers managing their own state.
  • Addressed potential race conditions in state management.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a StateManagingProvider interface to allow providers to manage their own state, which helps in fixing potential race conditions with state management. The FeatureProviderStateManager is updated to respect this new interface, delegating state management to the provider if it implements StateManagingProvider. The changes are logical and well-implemented. I have one suggestion to improve code quality by avoiding a call to a deprecated method.


public ProviderState getState() {
if (delegateManagesState) {
return delegate.getState();
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The getState() method on FeatureProvider is deprecated. To avoid potential compiler warnings and to make the code clearer, it's better to cast the delegate to StateManagingProvider before calling getState(). This makes it explicit that you are using the non-deprecated method from the StateManagingProvider interface.

Suggested change
return delegate.getState();
return ((StateManagingProvider) delegate).getState();

@codecov
Copy link

codecov bot commented Mar 11, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.53%. Comparing base (597501a) to head (36f076d).

Files with missing lines Patch % Lines
...v/openfeature/sdk/FeatureProviderStateManager.java 50.00% 2 Missing and 6 partials ⚠️
...n/java/dev/openfeature/sdk/ProviderRepository.java 50.00% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1892      +/-   ##
============================================
+ Coverage     92.15%   92.53%   +0.38%     
- Complexity      647      651       +4     
============================================
  Files            58       58              
  Lines          1568     1581      +13     
  Branches        176      184       +8     
============================================
+ Hits           1445     1463      +18     
+ Misses           76       64      -12     
- Partials         47       54       +7     
Flag Coverage Δ
unittests 92.53% <50.00%> (+0.38%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@toddbaert toddbaert marked this pull request as draft March 11, 2026 17:53
@toddbaert toddbaert force-pushed the poc/fix-provider-init-race branch from 1111da6 to 36f076d Compare March 11, 2026 17:56
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant