Skip to content

Conversation

@Vishalup29
Copy link
Contributor

@Vishalup29 Vishalup29 commented Dec 8, 2025

Description

Move the existing multi-provider implementation from the contrib module into the core Java SDK, mark it as experimental, and deprecate the contrib implementation.

Changes

  • Move MultiProvider (and related strategy/utility classes) from java-sdk-contrib/providers/multiprovider into the core SDK under dev.openfeature.sdk.providers.multiprovider.
  • Mark the SDK multi-provider as experimental using inline Javadoc and README documentation.
  • Add SDK tests for the multi-provider based on the existing contrib tests.
  • Update the Java SDK README.md to document the multi-provider feature and show a basic usage example.
  • Deprecate the contrib multi-provider implementation and README, pointing users to the SDK implementation.
  • Adjust exception usage to match the SDK API (use new FlagNotFoundError() rather than a message constructor).

Related Issues

Fixes #1486

Notes

  • In the SDK, FlagNotFoundError only exposes a no-arg constructor, so the ported multi-provider now throws new FlagNotFoundError() where the contrib version used a message.
  • Metadata handling has been aligned with the SDK’s existing patterns and dependency constraints to avoid introducing unnecessary dependencies.

@Vishalup29 Vishalup29 requested review from a team as code owners December 8, 2025 02:04
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Vishalup29, 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 significantly refactors the multi-provider functionality within the OpenFeature Java SDK. It transitions the multi-provider from a contrib module to a core SDK component, making it more accessible and integrated. The new implementation introduces flexible evaluation strategies and is clearly marked as experimental to manage expectations regarding API stability. This change streamlines multi-provider usage, improves test coverage, and updates documentation, while deprecating the older contrib version.

Highlights

  • Core SDK Integration: The multi-provider implementation has been moved from the contrib module into the core SDK under dev.openfeature.sdk.providers.multiprovider.
  • Experimental Status: The SDK multi-provider is now explicitly marked as experimental through Javadoc and README documentation, indicating potential future changes.
  • New Evaluation Strategies: Introduced FirstMatchStrategy and FirstSuccessfulStrategy to define how multiple providers are evaluated.
  • Enhanced Testing: Dedicated SDK tests have been added for the multi-provider, mirroring existing contrib tests.
  • Documentation Update: The Java SDK README has been updated to include documentation and usage examples for the multi-provider feature.
  • Contrib Deprecation: The previous multi-provider implementation in the contrib module has been deprecated, directing users to the new SDK version.
  • Dependency Addition: The org.json library has been added as a new dependency.
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 successfully moves the multi-provider implementation into the core SDK and marks it as experimental. The changes are well-structured, including new strategies and tests. My review focuses on a few critical resource management issues in the MultiProvider class, specifically related to ExecutorService lifecycle management. I've also provided suggestions to improve maintainability by reducing dependencies, clarifying code, and enhancing Javadoc documentation. Addressing these points will make the new experimental feature more robust and easier to maintain.

Comment on lines 141 to 185
public void shutdown() {
log.debug("shutdown begin");
for (FeatureProvider provider : providers.values()) {
try {
provider.shutdown();
} catch (Exception e) {
log.error("error shutdown provider {}", provider.getMetadata().getName(), e);
}
}
log.debug("shutdown end");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The shutdown method overrides the one from EventProvider but doesn't call super.shutdown(). This means the emitterExecutor in the parent class will not be shut down, leading to a resource leak. You should call super.shutdown() to ensure all resources are properly cleaned up.

    @Override
    public void shutdown() {
        log.debug("shutdown begin");
        for (FeatureProvider provider : providers.values()) {
            try {
                provider.shutdown();
            } catch (Exception e) {
                log.error("error shutdown provider {}", provider.getMetadata().getName(), e);
            }
        }
        log.debug("shutdown end");
        super.shutdown();
    }

Comment on lines 109 to 143
public Metadata getMetadata() {
return () -> metadataName;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Using a JSON string as the provider name is a creative workaround for the Metadata interface limitation. However, it might lead to unexpected behavior or difficult debugging if other parts of the system expect a simple name (e.g., in logs, metrics). For an experimental feature this might be acceptable, but it would be good to consider if the Metadata interface could be evolved in the future to support structured data.

@Vishalup29 Vishalup29 changed the title Issue open-feature#1486 Move multi-provider into SDK, mark as experimental, and deprecate contrib implementation. feat: move multi-provider into SDK and deprecate contrib implementation (open-feature#1486) Dec 8, 2025
@Vishalup29
Copy link
Contributor Author

@chrfwow @toddbaert Can you pls review when you get a chance?

@aepfli
Copy link
Member

aepfli commented Dec 8, 2025

Hi, thanks for your contribution and interest in the SDK! We genuinely appreciate your work on multi-provider support.

Since there's already a well-developed PR (#1500 ) addressing the same feature, having multiple PRs for the same goal creates extra effort for reviewers and can slow things down. Next time, we suggest building on the existing work - especially when significant development and review have already occurred.

A few differences to keep in mind:

  • PR feat: Add multi-provider support #1500 offers comprehensive tests, standardized exception handling, and has removed unnecessary dependencies.
  • It includes extensive review feedback covering several improvements and edge cases.

Your contributions are always welcome, but i think basing the work on the previous PR would be a good approach here. Especially to also credit the previous contributor of his base work.

Thank you for your effort, can you maybe incorporate the already existing feedback from the other pull request, or re-base your efforts based on the other one. This would be highly appreciated.

…ental, and deprecate contrib implementation.

Signed-off-by: vishalup29 <[email protected]>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 9, 2025

@Vishalup29
Copy link
Contributor Author

@aepfli Rebased and PR on top of the changes in the PR (#1500 ). it now includes all the suggestions based on the discussions on that PR. Pls take a look when you get a chance

@codecov
Copy link

codecov bot commented Dec 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.08%. Comparing base (a0305f9) to head (3cd33f4).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1765      +/-   ##
============================================
+ Coverage     92.53%   94.08%   +1.55%     
- Complexity      599      634      +35     
============================================
  Files            55       58       +3     
  Lines          1406     1504      +98     
  Branches        154      165      +11     
============================================
+ Hits           1301     1415     +114     
+ Misses           64       50      -14     
+ Partials         41       39       -2     
Flag Coverage Δ
unittests 94.08% <100.00%> (+1.55%) ⬆️

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.

@aepfli
Copy link
Member

aepfli commented Dec 9, 2025

/gemini review

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 successfully moves the multi-provider implementation from the contrib repository into the core SDK and marks it as experimental. The changes are well-implemented, including the MultiProvider class, different evaluation strategies (FirstMatchStrategy, FirstSuccessfulStrategy), and parallel initialization of providers for better performance. The error handling is robust, and the new feature is properly documented in the README.md. The test coverage for the new functionality is also comprehensive. I have one minor suggestion regarding Java naming conventions in the test packages.

@@ -0,0 +1,214 @@
package dev.openfeature.sdk.multiProvider;
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 package name dev.openfeature.sdk.multiProvider does not follow Java's package naming conventions, which recommend all-lowercase names. The corresponding production code in src/main/java/dev/openfeature/sdk/multiprovider uses the correct lowercase naming. For consistency and to adhere to standard Java practices, this package should be renamed to dev.openfeature.sdk.multiprovider.

This change should be applied to all new test files in this pull request that share this package declaration (FirstMatchStrategyTest.java, FirstSuccessfulStrategyTest.java, and MultiProviderTest.java).

Suggested change
package dev.openfeature.sdk.multiProvider;
package dev.openfeature.sdk.multiprovider;

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.

Move multi-provider into SDK

2 participants