error in before results in default params

This commit is contained in:
Justin Abrahms 2022-08-05 14:38:47 -07:00
parent def7f57007
commit d71bf0851c
No known key found for this signature in database
GPG Key ID: 599E2E12011DC474
2 changed files with 3 additions and 3 deletions

View File

@ -39,8 +39,6 @@ public class OpenFeatureClient implements Client {
}
// merge of: API.context, client.context, invocation.context
// TODO: Context transformation?
HookContext<T> hookCtx = HookContext.from(key, type, this.getMetadata(), openfeatureApi.getProvider().getMetadata(), ctx, defaultValue);
List<Hook> mergedHooks = ObjectUtils.merge(provider.getProviderHooks(), flagOptions.getHooks(), clientHooks, openfeatureApi.getApiHooks());

View File

@ -385,14 +385,16 @@ public class HookSpecTest implements HookFixtures {
}
@Specification(number="4.4.5", text="If an error occurs in the before or after hooks, the error hooks MUST be invoked.")
@Specification(number="4.4.7", text="If an error occurs in the before hooks, the default value MUST be returned.")
@Test void error_hooks__before() {
Hook hook = mockBooleanHook();
doThrow(RuntimeException.class).when(hook).before(any(), any());
Client client = getClient(null);
client.getBooleanValue("key", false, new EvaluationContext(),
Boolean value = client.getBooleanValue("key", false, new EvaluationContext(),
FlagEvaluationOptions.builder().hook(hook).build());
verify(hook, times(1)).before(any(), any());
verify(hook, times(1)).error(any(), any(), any());
assertEquals(false, value, "Falls through to the default.");
}
@Specification(number="4.4.5", text="If an error occurs in the before or after hooks, the error hooks MUST be invoked.")