Observed behavior
Every Set*Provider call runs Init on the newly registered provider unconditionally - even when that provider instance is already active on another domain.
OpenFeature spec requirement 1.1.2.2: "Provider instances which are already active (because they have been bound to another domain or otherwise) need not be initialized again."
Expected Behavior
Binding an already-active provider to another domain skips Init and reports readiness from the provider's existing state.
Steps to reproduce
func TestRequirementMultiBound(t *testing.T) {
inited := atomic.Bool{}
sh := &stateHandlerForTests{
// Semaphore must be invoked
initF: func(e EvaluationContext) error {
if inited.Swap(true) {
return fmt.Errorf("ready initialized")
}
return nil
},
}
provider := struct {
FeatureProvider
StateHandler
}{
FeatureProvider: NoopProvider{},
StateHandler: sh,
}
api := newAPI()
t.Cleanup(func() {
_ = api.Shutdown(context.Background())
})
err := api.SetProviderAndWait(t.Context(), provider)
if err != nil {
t.Errorf("can't set default: %v", err)
}
err = api.SetProviderAndWait(t.Context(), provider, WithDomain("domain"))
if err != nil {
t.Errorf("can't set domain: %v", err)
}
}
Result:
--- FAIL: TestRequirementMultiBound (0.00s)
openfeature_test.go:88: can't set domain: failed to initialize named provider "NoopProvider" for domain "domain": ready initialized
Observed behavior
Every
Set*Providercall runsIniton the newly registered provider unconditionally - even when that provider instance is already active on another domain.OpenFeature spec requirement 1.1.2.2: "Provider instances which are already active (because they have been bound to another domain or otherwise) need not be initialized again."
Expected Behavior
Binding an already-active provider to another domain skips
Initand reports readiness from the provider's existing state.Steps to reproduce
Result:
--- FAIL: TestRequirementMultiBound (0.00s) openfeature_test.go:88: can't set domain: failed to initialize named provider "NoopProvider" for domain "domain": ready initialized