Skip to content

Commit d71bf08

Browse files
committed
error in before results in default params
1 parent def7f57 commit d71bf08

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/main/java/dev/openfeature/javasdk/OpenFeatureClient.java

-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ private <T> FlagEvaluationDetails<T> evaluateFlag(FlagValueType type, String key
3939
}
4040

4141
// merge of: API.context, client.context, invocation.context
42-
43-
// TODO: Context transformation?
4442
HookContext<T> hookCtx = HookContext.from(key, type, this.getMetadata(), openfeatureApi.getProvider().getMetadata(), ctx, defaultValue);
4543

4644
List<Hook> mergedHooks = ObjectUtils.merge(provider.getProviderHooks(), flagOptions.getHooks(), clientHooks, openfeatureApi.getApiHooks());

src/test/java/dev/openfeature/javasdk/HookSpecTest.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -385,14 +385,16 @@ public void finallyAfter(HookContext<Boolean> ctx, Map<String, Object> hints) {
385385
}
386386

387387
@Specification(number="4.4.5", text="If an error occurs in the before or after hooks, the error hooks MUST be invoked.")
388+
@Specification(number="4.4.7", text="If an error occurs in the before hooks, the default value MUST be returned.")
388389
@Test void error_hooks__before() {
389390
Hook hook = mockBooleanHook();
390391
doThrow(RuntimeException.class).when(hook).before(any(), any());
391392
Client client = getClient(null);
392-
client.getBooleanValue("key", false, new EvaluationContext(),
393+
Boolean value = client.getBooleanValue("key", false, new EvaluationContext(),
393394
FlagEvaluationOptions.builder().hook(hook).build());
394395
verify(hook, times(1)).before(any(), any());
395396
verify(hook, times(1)).error(any(), any(), any());
397+
assertEquals(false, value, "Falls through to the default.");
396398
}
397399

398400
@Specification(number="4.4.5", text="If an error occurs in the before or after hooks, the error hooks MUST be invoked.")

0 commit comments

Comments
 (0)