Commit 4c7db65
committed
fix: replace signal() with signalAll() to satisfy SpotBugs MDM_SIGNAL_NOT_SIGNALALL
SpotBugs flags all four Condition.signal() calls in ThreadSafeQueue as Medium
severity bugs (MDM_SIGNAL_NOT_SIGNALALL). In a multi-producer/multi-consumer
scenario, signal() wakes only one waiting thread, which can cause deadlock when
multiple producers or consumers are blocked on the same condition variable.
Using signalAll() ensures all waiting threads are notified and can re-check
their loop condition, preventing the lost-wakeup problem that occurs when a
single signal wakes a thread that cannot make progress.
This change affects enqueue(), dequeue(), offer(), and poll() methods where
notEmpty.signal() and notFull.signal() are replaced with notEmpty.signalAll()
and notFull.signalAll() respectively.1 parent 301b1e8 commit 4c7db65
1 file changed
Lines changed: 4 additions & 4 deletions
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
| 63 | + | |
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
| 111 | + | |
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | | - | |
| 133 | + | |
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| |||
0 commit comments