Skip to content

Commit 80b24e9

Browse files
committed
Fixes issue with blocking and BatchingExecutor
BatchingExecutor has a thread local with internal runnables for Future/Promise. In blockOn method this threadLocal was set to Nil and if there are tasks to execute, it passed to Batch to execute immediately. Howerver, run method of Batch class requires that thread local must be null. It produces IllegalArgumentException and all unexecuted tasks are lost at this point (having Promise/Future onComplete callback never called, meaning - it will never be completed). Fixes scala/bug#9304
1 parent 10f6889 commit 80b24e9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/src/scala/concurrent/BatchingExecutor.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ private[concurrent] trait BatchingExecutor extends Executor {
6060
parentBlockContext = prevBlockContext
6161

6262
@tailrec def processBatch(batch: List[Runnable]): Unit = batch match {
63-
case Nil => ()
63+
case null | Nil => ()
6464
case head :: tail =>
6565
_tasksLocal set tail
6666
try {
@@ -91,7 +91,7 @@ private[concurrent] trait BatchingExecutor extends Executor {
9191
// if we know there will be blocking, we don't want to keep tasks queued up because it could deadlock.
9292
{
9393
val tasks = _tasksLocal.get
94-
_tasksLocal set Nil
94+
_tasksLocal set null
9595
if ((tasks ne null) && tasks.nonEmpty)
9696
unbatchedExecute(new Batch(tasks))
9797
}

0 commit comments

Comments
 (0)