Skip to content

Commit

Permalink
[hotfix] fix data race in drain() method in TaskMailboxImpl.java
Browse files Browse the repository at this point in the history
  • Loading branch information
raulpardo committed Feb 26, 2025
1 parent 14a5375 commit 7e3700a
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,11 @@ private Mail takeOrNull(Deque<Mail> queue, int priority) {

@Override
public List<Mail> drain() {
List<Mail> drainedMails = new ArrayList<>(batch);
batch.clear();
final ReentrantLock lock = this.lock;
lock.lock();
try {
List<Mail> drainedMails = new ArrayList<>(batch);
batch.clear();
drainedMails.addAll(queue);
queue.clear();
hasNewMail = false;
Expand Down

0 comments on commit 7e3700a

Please sign in to comment.