Skip to content

feat: supply bound domain to provider initialization#1982

Open
jonathannorris wants to merge 8 commits into
mainfrom
feat/domain-scoped-provider-init
Open

feat: supply bound domain to provider initialization#1982
jonathannorris wants to merge 8 commits into
mainfrom
feat/domain-scoped-provider-init

Conversation

@jonathannorris

@jonathannorris jonathannorris commented Jul 2, 2026

Copy link
Copy Markdown
Member

Summary

  • Add optional domain parameter to provider initialize and pass the bound domain from the provider mutator (spec 1.1.2.2, 2.4.1)
  • Add isDomainScoped() provider declaration and reject binding a domain-scoped instance to more than one domain (spec 2.4.3, 1.1.8.1)
  • Forward domain through MultiProvider initialize (child providers receive null)
  • Add spec conformance tests, including backward compatibility for providers that only override single-arg initialize

Motivation

Unblocks OFREP static-context providers that need the bound domain at init time to scope persisted cache keys per open-feature/spec#393 and protocol ADR 0009.

Parallel implementation in js-sdk: open-feature/js-sdk#1433.

Notes

  • Non-breaking: domain is an optional second parameter via a default method on FeatureProvider
  • Non-domain-scoped providers retain existing behavior (single instance can back multiple domains; initialize runs once)
  • Legacy providers that only implement initialize(context) remain compatible; the extra domain argument is ignored if unused
  • Default provider is initialized with a null domain; named clients receive the bound domain string

Related Issues

Fixes #1981

Relates to: open-feature/spec#393, open-feature/js-sdk#1433

Test plan

  • InitializeBehaviorSpecTest verifies domain is passed at init (2.4.1)
  • DomainScopedProviderSpecTest covers 1.1.8.1 and 2.4.3
  • mvn test passes after rebase onto main

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@jonathannorris, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 39 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1ed25245-8171-47d3-9ab8-bdc9ecbb1468

📥 Commits

Reviewing files that changed from the base of the PR and between 4a23ee9 and 620d811.

📒 Files selected for processing (3)
  • src/test/java/dev/openfeature/sdk/DomainScopedProviderSpecTest.java
  • src/test/java/dev/openfeature/sdk/ProviderInitializeBackwardCompatibilityTest.java
  • src/test/java/dev/openfeature/sdk/multiprovider/MultiProviderTest.java
📝 Walkthrough

Walkthrough

Adds a domain-aware initialize(EvaluationContext, domain) overload and isDomainScoped() default method to FeatureProvider, propagates the bound domain through FeatureProviderStateManager, ProviderRepository, and MultiProvider, enforces single-domain binding for domain-scoped providers, and updates related tests.

Changes

Domain-scoped provider initialization

Layer / File(s) Summary
Provider contract: domain overload and isDomainScoped
src/main/java/dev/openfeature/sdk/FeatureProvider.java
Adds a default initialize(EvaluationContext, @nullable String domain) method delegating to the existing overload, and a default isDomainScoped() returning false.
State manager domain propagation
src/main/java/dev/openfeature/sdk/FeatureProviderStateManager.java, src/test/java/dev/openfeature/sdk/FeatureProviderStateManagerTest.java
Adds an initialize(EvaluationContext, domain) overload that forwards domain to the delegate; the existing method delegates to it. Tests verify domain forwarding.
Repository binding validation and initialization
src/main/java/dev/openfeature/sdk/ProviderRepository.java
Adds validateDomainScopedBinding to reject binding a domain-scoped provider to more than one domain and passes domain through to initializeProvider.
MultiProvider domain forwarding
src/main/java/dev/openfeature/sdk/multiprovider/MultiProvider.java, src/test/java/dev/openfeature/sdk/multiprovider/MultiProviderTest.java
Adds a domain-aware initialize overload forwarding domain to each child provider concurrently, with tests for both two-arg and legacy single-arg providers.
Domain-scoped spec tests
src/test/java/dev/openfeature/sdk/DomainScopedProviderSpecTest.java
New test suite covering rejection of multi-domain binding, allowed same-domain rebinding, multi-domain binding for non-scoped providers, and domain delivery during initialization.
Backward compatibility tests
src/test/java/dev/openfeature/sdk/ProviderInitializeBackwardCompatibilityTest.java
New test suite verifying default method delegation and SDK/state-manager behavior for legacy single-arg providers.
Existing test matcher updates
src/test/java/dev/openfeature/sdk/InitializeBehaviorSpecTest.java, OpenFeatureAPITest.java, ProviderRepositoryTest.java, e2e/steps/ProviderSteps.java, fixtures/ProviderFixture.java, vmlens/ProviderRepositoryCT.java
Updates Mockito stubbing/verifications to match the new two-argument initialize signature.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant ProviderRepository
  participant FeatureProviderStateManager
  participant FeatureProvider

  Caller->>ProviderRepository: setProvider(domain, provider)
  ProviderRepository->>ProviderRepository: validateDomainScopedBinding(domain, provider, existing)
  alt provider already bound to another domain
    ProviderRepository-->>Caller: throw IllegalArgumentException
  else binding allowed
    ProviderRepository->>FeatureProviderStateManager: initialize(context, domain)
    FeatureProviderStateManager->>FeatureProvider: initialize(context, domain)
  end
Loading

Possibly related issues

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main change: passing the bound domain into provider initialization.
Description check ✅ Passed The description is directly related to the implemented domain-aware initialization and domain-scoped provider behavior.
Linked Issues check ✅ Passed The changes satisfy #1981 by forwarding domain to initialize, adding domain-scoped declaration, enforcing single-domain binding, and covering tests.
Out of Scope Changes check ✅ Passed The modified files are all in scope for domain-aware initialization, provider scoping, and the associated compatibility and behavior tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.85714% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.30%. Comparing base (a7d4e8a) to head (620d811).

Files with missing lines Patch % Lines
...n/java/dev/openfeature/sdk/ProviderRepository.java 89.47% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1982      +/-   ##
============================================
+ Coverage     92.23%   93.30%   +1.07%     
- Complexity      669      683      +14     
============================================
  Files            59       59              
  Lines          1635     1658      +23     
  Branches        186      191       +5     
============================================
+ Hits           1508     1547      +39     
+ Misses           80       65      -15     
+ Partials         47       46       -1     
Flag Coverage Δ
unittests 93.30% <92.85%> (+1.07%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 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.

@jonathannorris jonathannorris force-pushed the feat/domain-scoped-provider-init branch from e2beebe to e7ad946 Compare July 3, 2026 15:05
Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com>
Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com>
Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com>
Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com>
Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com>
Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com>
Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com>
@jonathannorris jonathannorris force-pushed the feat/domain-scoped-provider-init branch from e7ad946 to 4a23ee9 Compare July 3, 2026 15:07
@jonathannorris jonathannorris marked this pull request as ready for review July 3, 2026 15:15
@jonathannorris jonathannorris requested review from a team as code owners July 3, 2026 15:15
@jonathannorris jonathannorris requested a review from Copilot July 3, 2026 15:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds domain-awareness to provider initialization and introduces an opt-in “domain-scoped” provider declaration that the SDK enforces to prevent a single provider instance from being bound to multiple domains, aligning the Java SDK with updated OpenFeature spec requirements.

Changes:

  • Add FeatureProvider.initialize(EvaluationContext, @Nullable String domain) default method and isDomainScoped() declaration.
  • Pass the bound domain through provider initialization paths (repository/state manager, MultiProvider) and enforce domain-scoped single-domain binding.
  • Add/adjust conformance and backward-compatibility tests for legacy single-arg providers and domain-scoped binding rules.

Reviewed changes

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

Show a summary per file
File Description
src/main/java/dev/openfeature/sdk/FeatureProvider.java Adds optional domain initialize overload + isDomainScoped() declaration.
src/main/java/dev/openfeature/sdk/ProviderRepository.java Passes domain into initialization and enforces domain-scoped binding constraints.
src/main/java/dev/openfeature/sdk/FeatureProviderStateManager.java Forwards domain into provider initialization while preserving one-time init behavior.
src/main/java/dev/openfeature/sdk/multiprovider/MultiProvider.java Adds two-arg initialize and forwards domain during child initialization.
src/test/java/dev/openfeature/sdk/InitializeBehaviorSpecTest.java Updates spec tests to assert domain (or null) is passed on init.
src/test/java/dev/openfeature/sdk/DomainScopedProviderSpecTest.java Adds spec tests for domain-scoped binding restrictions and domain receipt.
src/test/java/dev/openfeature/sdk/ProviderInitializeBackwardCompatibilityTest.java Adds explicit backward-compat coverage for legacy single-arg providers.
src/test/java/dev/openfeature/sdk/ProviderRepositoryTest.java Updates repository tests to expect two-arg initialize with proper domain/null.
src/test/java/dev/openfeature/sdk/vmlens/ProviderRepositoryCT.java Updates concurrency tests to stub/verify two-arg initialize.
src/test/java/dev/openfeature/sdk/OpenFeatureAPITest.java Updates API tests to verify two-arg initialize is called with null domain.
src/test/java/dev/openfeature/sdk/multiprovider/MultiProviderTest.java Adds tests for MultiProvider domain forwarding and legacy child providers.
src/test/java/dev/openfeature/sdk/FeatureProviderStateManagerTest.java Adds test ensuring domain is forwarded into delegate init.
src/test/java/dev/openfeature/sdk/e2e/steps/ProviderSteps.java Updates e2e mocking to stub two-arg initialize for named clients.
src/test/java/dev/openfeature/sdk/fixtures/ProviderFixture.java Updates fixture to throw from two-arg initialize (nullable domain).

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

Comment on lines +207 to +208
boolean currentlyDefault = isDefaultProvider(newProvider);
List<String> boundNamedDomains = getDomainsForProvider(newProvider);
Comment on lines 112 to 116
Collection<Callable<Void>> tasks = new ArrayList<>(providers.size());
for (FeatureProvider provider : providers.values()) {
tasks.add(() -> {
provider.initialize(evaluationContext);
provider.initialize(evaluationContext, domain);
return null;

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (5)
src/test/java/dev/openfeature/sdk/InitializeBehaviorSpecTest.java (2)

93-101: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate test body flagged by SonarCloud (named-provider case).

mustPassBoundDomainWhenInitializingANamedProvider duplicates mustCallInitializeFunctionOfTheNewlyRegisteredNamedProviderBeforeUsingItForFlagEvaluation verbatim. Same consolidation suggestion as the default-provider pair above applies here.

Also applies to: 109-115

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/test/java/dev/openfeature/sdk/InitializeBehaviorSpecTest.java` around
lines 93 - 101, The named-provider test body is duplicated and should be
consolidated to match the shared pattern used for the default-provider case.
Update mustPassBoundDomainWhenInitializingANamedProvider and
mustCallInitializeFunctionOfTheNewlyRegisteredNamedProviderBeforeUsingItForFlagEvaluation
in InitializeBehaviorSpecTest so only one test covers the initialize-on-set
behavior, or extract the common setup/assertion into a shared helper and keep
distinct assertions only where behavior differs.

Source: Linters/SAST tools


40-47: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate test body flagged by SonarCloud.

mustPassNullDomainWhenInitializingTheDefaultProvider is byte-identical to mustCallInitializeFunctionOfTheNewlyRegisteredProviderBeforeUsingItForFlagEvaluation above it. Consider extracting the shared assertion into a private helper so both @Specification-tagged tests stay for traceability without duplicated code.

♻️ Suggested consolidation
+    private void assertInitializeCalledWithDomain(FeatureProvider featureProvider, Object domainMatcher) {
+        // shared verification helper
+    }

Or simply merge both @Specification annotations onto a single test method.

Also applies to: 55-61

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/test/java/dev/openfeature/sdk/InitializeBehaviorSpecTest.java` around
lines 40 - 47, The two `@Specification` tests in InitializeBehaviorSpecTest are
duplicate bodies, so consolidate the shared setup/assertion into a private
helper or merge the annotations onto one test method. Keep the existing test
names or metadata only as needed for traceability, and update both
mustCallInitializeFunctionOfTheNewlyRegisteredProviderBeforeUsingItForFlagEvaluation
and mustPassNullDomainWhenInitializingTheDefaultProvider to delegate to the
shared logic instead of repeating the same mock/verify sequence.

Source: Linters/SAST tools

src/test/java/dev/openfeature/sdk/DomainScopedProviderSpecTest.java (2)

95-110: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Test doesn't verify DOMAIN_B initialization was actually invoked.

allowsBindingNonDomainScopedProviderToMultipleDomains only verifies initialize(any(), eq(DOMAIN_A)). To actually confirm the provider was initialized for both domains (the point of the test), also assert the DOMAIN_B call occurred.

♻️ Suggested fix
         assertThat(api.getProvider(DOMAIN_A)).isSameAs(provider);
         assertThat(api.getProvider(DOMAIN_B)).isSameAs(provider);
         verify(provider, times(1)).initialize(any(), eq(DOMAIN_A));
+        verify(provider, times(1)).initialize(any(), eq(DOMAIN_B));
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/test/java/dev/openfeature/sdk/DomainScopedProviderSpecTest.java` around
lines 95 - 110, The test allows a non-domain-scoped provider to be bound to two
domains, but it only verifies initialization for DOMAIN_A. Update
allowsBindingNonDomainScopedProviderToMultipleDomains in
DomainScopedProviderSpecTest to also assert that the provider’s initialize path
was invoked for DOMAIN_B, using the existing provider mock and initialization
verification so the test confirms both domain bindings.

27-31: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Missing teardown to shut down OpenFeatureAPI instances.

Each test constructs a new OpenFeatureAPI() instance in @BeforeEach, and setProvider dispatches initialization work to an internal executor owned by that instance. Without an @AfterEach calling api.shutdown(), each test leaves behind an unshut-down executor/thread pool for the lifetime of the JVM running the suite.

♻️ Suggested fix
     `@BeforeEach`
     void setupTest() {
         api = new OpenFeatureAPI();
         api.setProvider(new NoOpProvider());
     }
+
+    `@AfterEach`
+    void tearDown() {
+        api.shutdown();
+    }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/test/java/dev/openfeature/sdk/DomainScopedProviderSpecTest.java` around
lines 27 - 31, The test setup creates a new OpenFeatureAPI and assigns a
provider, but the instance-owned executor is never shut down, leaving background
threads running after each test. Add an `@AfterEach` teardown in
DomainScopedProviderSpecTest that calls api.shutdown() on the same api
initialized in setupTest, and ensure this cleanup runs even when setup or
assertions fail. Use the existing OpenFeatureAPI and setupTest symbols to place
the teardown alongside the current lifecycle methods.
src/test/java/dev/openfeature/sdk/ProviderInitializeBackwardCompatibilityTest.java (1)

54-63: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Misleading test name: asserts count == 2, not "once".

singleArgOverrideIsOnlyInvokedOnce calls provider.initialize(ctx, DOMAIN) twice directly (bypassing the FeatureProviderStateManager idempotency guard) and asserts the count is 2. The name suggests the opposite of what's asserted, and it's easy to conflate with the similarly-named onlyInvokesLegacySingleArgProviderOncePerStateManagerInit test (lines 142-152), which asserts count == 1 via the state-manager guard. Consider renaming to clarify that each direct call to the default two-arg method triggers exactly one delegated single-arg call (e.g., eachCallDelegatesExactlyOnceToSingleArgOverride).

✏️ Suggested rename
-        `@DisplayName`("single-arg override is only invoked once per initialization")
-        void singleArgOverrideIsOnlyInvokedOnce() throws Exception {
+        `@DisplayName`("each call to the two-arg default delegates exactly once to the single-arg override")
+        void eachCallDelegatesExactlyOnceToSingleArgOverride() throws Exception {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/test/java/dev/openfeature/sdk/ProviderInitializeBackwardCompatibilityTest.java`
around lines 54 - 63, Rename the misleading test in
ProviderInitializeBackwardCompatibilityTest so its name matches the asserted
behavior: the current singleArgOverrideIsOnlyInvokedOnce method calls
initialize(new ImmutableContext(), DOMAIN) twice and expects
singleArgInitCount() to be 2, so update the test name to reflect that each
direct two-arg initialize call delegates exactly once to the single-arg
override. Make sure it stays clearly distinct from the state-manager-backed
onlyInvokesLegacySingleArgProviderOncePerStateManagerInit test.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/java/dev/openfeature/sdk/FeatureProvider.java`:
- Line 5: The production code in FeatureProvider imports
javax.annotation.Nullable, but the project is missing a compile-scope dependency
that provides it, which can break the main module build. Update pom.xml to add
jsr305 or an equivalent compile-time dependency so the Nullable import in
FeatureProvider resolves during production compilation and is available without
relying on test-only or transitive scope.

---

Nitpick comments:
In `@src/test/java/dev/openfeature/sdk/DomainScopedProviderSpecTest.java`:
- Around line 95-110: The test allows a non-domain-scoped provider to be bound
to two domains, but it only verifies initialization for DOMAIN_A. Update
allowsBindingNonDomainScopedProviderToMultipleDomains in
DomainScopedProviderSpecTest to also assert that the provider’s initialize path
was invoked for DOMAIN_B, using the existing provider mock and initialization
verification so the test confirms both domain bindings.
- Around line 27-31: The test setup creates a new OpenFeatureAPI and assigns a
provider, but the instance-owned executor is never shut down, leaving background
threads running after each test. Add an `@AfterEach` teardown in
DomainScopedProviderSpecTest that calls api.shutdown() on the same api
initialized in setupTest, and ensure this cleanup runs even when setup or
assertions fail. Use the existing OpenFeatureAPI and setupTest symbols to place
the teardown alongside the current lifecycle methods.

In `@src/test/java/dev/openfeature/sdk/InitializeBehaviorSpecTest.java`:
- Around line 93-101: The named-provider test body is duplicated and should be
consolidated to match the shared pattern used for the default-provider case.
Update mustPassBoundDomainWhenInitializingANamedProvider and
mustCallInitializeFunctionOfTheNewlyRegisteredNamedProviderBeforeUsingItForFlagEvaluation
in InitializeBehaviorSpecTest so only one test covers the initialize-on-set
behavior, or extract the common setup/assertion into a shared helper and keep
distinct assertions only where behavior differs.
- Around line 40-47: The two `@Specification` tests in InitializeBehaviorSpecTest
are duplicate bodies, so consolidate the shared setup/assertion into a private
helper or merge the annotations onto one test method. Keep the existing test
names or metadata only as needed for traceability, and update both
mustCallInitializeFunctionOfTheNewlyRegisteredProviderBeforeUsingItForFlagEvaluation
and mustPassNullDomainWhenInitializingTheDefaultProvider to delegate to the
shared logic instead of repeating the same mock/verify sequence.

In
`@src/test/java/dev/openfeature/sdk/ProviderInitializeBackwardCompatibilityTest.java`:
- Around line 54-63: Rename the misleading test in
ProviderInitializeBackwardCompatibilityTest so its name matches the asserted
behavior: the current singleArgOverrideIsOnlyInvokedOnce method calls
initialize(new ImmutableContext(), DOMAIN) twice and expects
singleArgInitCount() to be 2, so update the test name to reflect that each
direct two-arg initialize call delegates exactly once to the single-arg
override. Make sure it stays clearly distinct from the state-manager-backed
onlyInvokesLegacySingleArgProviderOncePerStateManagerInit test.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0adbf73e-e6cd-4ba9-bd5d-9c956a5fc975

📥 Commits

Reviewing files that changed from the base of the PR and between a7d4e8a and 4a23ee9.

📒 Files selected for processing (14)
  • src/main/java/dev/openfeature/sdk/FeatureProvider.java
  • src/main/java/dev/openfeature/sdk/FeatureProviderStateManager.java
  • src/main/java/dev/openfeature/sdk/ProviderRepository.java
  • src/main/java/dev/openfeature/sdk/multiprovider/MultiProvider.java
  • src/test/java/dev/openfeature/sdk/DomainScopedProviderSpecTest.java
  • src/test/java/dev/openfeature/sdk/FeatureProviderStateManagerTest.java
  • src/test/java/dev/openfeature/sdk/InitializeBehaviorSpecTest.java
  • src/test/java/dev/openfeature/sdk/OpenFeatureAPITest.java
  • src/test/java/dev/openfeature/sdk/ProviderInitializeBackwardCompatibilityTest.java
  • src/test/java/dev/openfeature/sdk/ProviderRepositoryTest.java
  • src/test/java/dev/openfeature/sdk/e2e/steps/ProviderSteps.java
  • src/test/java/dev/openfeature/sdk/fixtures/ProviderFixture.java
  • src/test/java/dev/openfeature/sdk/multiprovider/MultiProviderTest.java
  • src/test/java/dev/openfeature/sdk/vmlens/ProviderRepositoryCT.java


import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nullable;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Confirm javax.annotation.Nullable already used in main sources and declared as a compile dependency
echo "== existing usages in main sources =="
rg -n "javax\.annotation\.Nullable" src/main --type=java

echo "== build dependency declarations =="
fd -e gradle -e xml pom.xml build.gradle build.gradle.kts | xargs -r rg -n -i "jsr305|spotbugs-annotations|javax.annotation" || true

Repository: open-feature/java-sdk

Length of output: 789


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== repository build files =="
git ls-files | rg '(^|/)(build\.gradle(\.kts)?|pom\.xml|settings\.gradle(\.kts)?)$'

echo
echo "== dependency mentions =="
for f in $(git ls-files | rg '(^|/)(build\.gradle(\.kts)?|pom\.xml)$'); do
  echo "--- $f ---"
  rg -n -i 'jsr305|spotbugs-annotations|javax\.annotation|annotation\.api|com\.google\.code\.findbugs' "$f" || true
done

Repository: open-feature/java-sdk

Length of output: 340


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== build file contents around dependency blocks =="
for f in $(git ls-files | rg '(^|/)(build\.gradle(\.kts)?|pom\.xml)$'); do
  echo "--- $f ---"
  wc -l "$f"
  if [[ "$f" == *pom.xml ]]; then
    rg -n -A3 -B3 '<dependency>|<groupId>|<artifactId>|<scope>' "$f" | sed -n '1,220p'
  else
    rg -n -A3 -B3 'dependencies\s*\{|implementation|api|compileOnly|testImplementation|jsr305|spotbugs-annotations|javax\.annotation' "$f" | sed -n '1,260p'
  fi
done

Repository: open-feature/java-sdk

Length of output: 8120


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== build files =="
git ls-files | rg '(^|/)(build\.gradle(\.kts)?|pom\.xml)$' || true

echo
echo "== dependency declarations mentioning annotation providers =="
for f in $(git ls-files | rg '(^|/)(build\.gradle(\.kts)?|pom\.xml)$' || true); do
  echo "--- $f ---"
  rg -n -i 'jsr305|spotbugs-annotations|javax\.annotation|annotation\.api|findbugs' "$f" || true
done

Repository: open-feature/java-sdk

Length of output: 365


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== candidate files =="
git ls-files | rg '(^|/)(build\.gradle(\.kts)?|gradle\.properties|settings\.gradle(\.kts)?|pom\.xml)$'

echo
echo "== spot check main build file(s) =="
for f in $(git ls-files | rg '(^|/)build\.gradle(\.kts)?$'); do
  echo "--- $f ---"
  sed -n '1,260p' "$f"
done

Repository: open-feature/java-sdk

Length of output: 226


Add a compile-scope provider for javax.annotation.Nullable
Production sources import this annotation, but pom.xml doesn’t declare a matching dependency. Add jsr305 or an equivalent compile dependency to avoid a main-module build break.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/java/dev/openfeature/sdk/FeatureProvider.java` at line 5, The
production code in FeatureProvider imports javax.annotation.Nullable, but the
project is missing a compile-scope dependency that provides it, which can break
the main module build. Update pom.xml to add jsr305 or an equivalent
compile-time dependency so the Nullable import in FeatureProvider resolves
during production compilation and is available without relying on test-only or
transitive scope.

Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com>
@sonarqubecloud

sonarqubecloud Bot commented Jul 3, 2026

Copy link
Copy Markdown

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.

Supply the bound domain to provider initialization

2 participants