Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/main/java/dev/openfeature/sdk/HookSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public void setHookContexts(
}
}

// S2789: Hook is user-implemented; defensive null check against non-conforming impls returning null.
@SuppressWarnings("java:S2789")
public void executeBeforeHooks(HookSupportData data) {
// These traverse backwards from normal.
List<Pair<Hook, HookContext>> hooks = data.getHooks();
Expand All @@ -56,10 +58,8 @@ public void executeBeforeHooks(HookSupportData data) {
var hook = hookContextPair.getKey();
var hookContext = hookContextPair.getValue();

Optional<EvaluationContext> returnedEvalContext = Optional.ofNullable(
hook.before(hookContext, data.getHints()))
.orElse(Optional.empty());
if (returnedEvalContext.isPresent()) {
Optional<EvaluationContext> returnedEvalContext = hook.before(hookContext, data.getHints());
if (returnedEvalContext != null && returnedEvalContext.isPresent()) {
Comment thread
toddbaert marked this conversation as resolved.
var returnedContext = returnedEvalContext.get();
// yes, we want to check for reference equality here, this prevents recursive layered contexts
if (returnedContext != hookContext.getCtx() && !returnedContext.isEmpty()) {
Expand Down
Loading