diff --git a/akka-actor-tests/src/test/scala/akka/actor/dispatch/ActorModelSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/dispatch/ActorModelSpec.scala index 755e122ec1..318120a2a4 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/dispatch/ActorModelSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/dispatch/ActorModelSpec.scala @@ -379,9 +379,18 @@ abstract class ActorModelSpec extends AkkaSpec { val a = newTestActor(dispatcher) val f1 = a ? Reply("foo") val f2 = a ? Reply("bar") - val f3 = a ? Interrupt + val f3 = try { + a ? Interrupt + } catch { + // CallingThreadDispatcher throws IE directly + case ie: InterruptedException ⇒ new KeptPromise(Left(ActorInterruptedException(ie))) + } val f4 = a ? Reply("foo2") - val f5 = a ? Interrupt + val f5 = try { + a ? Interrupt + } catch { + case ie: InterruptedException ⇒ new KeptPromise(Left(ActorInterruptedException(ie))) + } val f6 = a ? Reply("bar2") assert(f1.get === "foo") diff --git a/akka-testkit/src/main/scala/akka/testkit/CallingThreadDispatcher.scala b/akka-testkit/src/main/scala/akka/testkit/CallingThreadDispatcher.scala index dc27e036a9..726d371cbf 100644 --- a/akka-testkit/src/main/scala/akka/testkit/CallingThreadDispatcher.scala +++ b/akka-testkit/src/main/scala/akka/testkit/CallingThreadDispatcher.scala @@ -187,7 +187,8 @@ class CallingThreadDispatcher(_app: AkkaApplication, val name: String = "calling * it is suspendSwitch and resumed. */ @tailrec - private def runQueue(mbox: CallingThreadMailbox, queue: NestingQueue) { + private def runQueue(mbox: CallingThreadMailbox, queue: NestingQueue, interruptedex: InterruptedException = null) { + var intex = interruptedex; assert(queue.isActive) mbox.lock.lock val recurse = try { @@ -214,6 +215,7 @@ class CallingThreadDispatcher(_app: AkkaApplication, val name: String = "calling case ie: InterruptedException ⇒ app.eventHandler.error(this, ie) Thread.currentThread().interrupt() + intex = ie true case e ⇒ app.eventHandler.error(this, e) @@ -230,7 +232,12 @@ class CallingThreadDispatcher(_app: AkkaApplication, val name: String = "calling mbox.lock.unlock } if (recurse) { - runQueue(mbox, queue) + runQueue(mbox, queue, intex) + } else { + if (intex ne null) { + Thread.interrupted // clear flag + throw intex + } } } }