Skip to content

Conversation

@jonathannorris
Copy link
Member

@jonathannorris jonathannorris commented Jan 19, 2026

Fix static OpenFeatureProvider field in DevCycleLocalClient

Problem

DevCycleLocalClient used a static field for openFeatureProvider, causing all client instances to share the same provider. This is incorrect when clients have different configurations.

Solution

Changed openFeatureProvider from a static field to an instance field, and added thread-safe lazy initialization.

Changes

  • private static DevCycleProviderprivate DevCycleProvider (instance field)
  • Added synchronized to getOpenFeatureProvider() method for thread safety
  • Platform data is now set on every call to getOpenFeatureProvider() to ensure correct SDK tracking

Thread Safety

The synchronized method ensures that only one DevCycleProvider instance is created per client, even when multiple threads call getOpenFeatureProvider() concurrently.

The static field caused all DevCycleLocalClient instances to share the
same DevCycleProvider, which is incorrect when clients have different
configurations. This aligns with DevCycleCloudClient's implementation.
@jonathannorris jonathannorris requested a review from a team as a code owner January 19, 2026 03:59
Copilot AI review requested due to automatic review settings January 19, 2026 03:59
Copy link
Contributor

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 design issue where the openFeatureProvider field in DevCycleLocalClient was incorrectly declared as static, causing all client instances to share the same provider. The fix changes it to an instance field so each client has its own provider, and removes the now-unnecessary class-level synchronization.

Changes:

  • Changed openFeatureProvider from static to instance field in DevCycleLocalClient
  • Removed class-level synchronized block that was protecting the static field initialization
  • Simplified the lazy initialization logic while maintaining the platform data setup

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Use volatile + double-checked locking to prevent race condition when
multiple threads call getOpenFeatureProvider() concurrently.
@jonathannorris jonathannorris marked this pull request as draft January 19, 2026 04:19
@jonathannorris jonathannorris marked this pull request as ready for review January 19, 2026 04:20
Use synchronized method instead of volatile + double-checked locking.
Set platform data on every call rather than only on first access.
@jonathannorris jonathannorris marked this pull request as draft January 19, 2026 04:24
@jonathannorris jonathannorris marked this pull request as ready for review January 19, 2026 04:24
Copy link
Contributor

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

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


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Contributor

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

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


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants