What happens when an actor of a future throws an exception?
According to the Akka documentation at http://doc.akka.io/docs/akka/snapshot/scala/futures.html:
It doesn't matter if an Actor or the dispatcher is completing the Future, if an Exception is caught the Future will contain it instead of a valid result. If a Future does contain an Exception, calling Await.result will cause it to be thrown again so it can be handled properly.
I am not sure this is what I am seeing when running this piece of code:
class Worker extends Actor {
def receive = {
case i: Int => throw new RuntimeException
}
}
implicit val system = ActorSystem("MySystem")
val worker = system.actorOf(Props(new Worker), name="worker")
implicit val timeout = Timeout(5 minutes)
val future = worker ? 0
val res = Await.result(future, 10 seconds)
According to the documentation, Await.result should throw the exception again, but what I am getting is a TimeoutException! Can someone clarify on this?