Skip to content

Commit

Permalink
Re-evaluate predicate in FnCondition.whenReadyIf as the predicate may…
Browse files Browse the repository at this point in the history
… have changed while awaiting the condition (#502) (#510)

Co-authored-by: Thilo-Alexander Ginkel <tg@tgbyte.de>
  • Loading branch information
swallez and ginkel committed Feb 13, 2023
1 parent 013608d commit 93e176c
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ public <T> T whenReadyIf(BooleanSupplier canRun, Supplier<T> fn) {
}
condition.awaitUninterruptibly();
}

if (canRun != null && !canRun.getAsBoolean()) {
return null;
}

return fn.get();
} finally {
lock.unlock();
Expand Down

0 comments on commit 93e176c

Please sign in to comment.