Use notifyAll in IOTaskRunnable.kick (CodeQL java/notify-instead-of-notify-all)#243
Merged
vharseko merged 1 commit intoJul 16, 2026
Conversation
maximthomas
approved these changes
Jul 9, 2026
…otify-all) kick() woke a waiter with notify(). Today there is only ever a single waiter - the one background thread per IOTaskRunnable that blocks in run()'s wait() - so notify() and notifyAll() are equivalent, but notify() is fragile: if another thread ever waited on the same monitor, notify() could wake the wrong one. Switch to notifyAll(). It wakes the same single waiter now (no thundering herd), and the wait loop already re-checks its conditions (shouldStop / _notified / recomputed wait time), so any extra wake-ups are handled safely.
vharseko
force-pushed
the
features/codeql-notify-all
branch
from
July 16, 2026 17:10
7433a4a to
73f26e1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves the
java/notify-instead-of-notify-allalert inIOTaskRunnable.kick()woke a blocked worker withnotify():Each
IOTaskRunnablehas exactly one background thread (created instart()),and that thread is the only one that ever calls
wait()on the monitor (inrun()), sonotify()andnotifyAll()are functionally equivalent today.However,
notify()is fragile — if any other thread ever waited on the samemonitor, it could wake the wrong one and leave the worker blocked.
Fix
Use
notifyAll(). With a single waiter it wakes exactly the same thread (nothundering herd), and the wait loop already re-checks its guards
(
shouldStop()/_notified/ recomputed wait time), so additional wake-ups arehandled correctly.
Testing
mvn -o -pl persistit/core compile— BUILD SUCCESS.