Added error handling to the actor creation in the different providers

This commit is contained in:
Jonas Bonér 2011-09-27 16:52:33 +02:00
parent 07012b3d62
commit 07b29c0627
2 changed files with 21 additions and 61 deletions

View file

@ -43,7 +43,7 @@ class RemoteActorRefProvider extends ActorRefProvider {
val oldFuture = actors.putIfAbsent(address, newFuture)
if (oldFuture eq null) { // we won the race -- create the actor and resolve the future
val actor =
val actor = try {
Deployer.lookupDeploymentFor(address) match {
case Some(Deploy(_, _, router, _, RemoteScope(host, port)))
// FIXME create RoutedActorRef if 'router' is specified
@ -60,13 +60,19 @@ class RemoteActorRefProvider extends ActorRefProvider {
}
case deploy None // non-remote actor
}
} catch {
case e: Exception
newFuture completeWithException e // so the other threads gets notified of error
throw e
}
newFuture.completeWithResult(actor)
actor foreach Actor.registry.register // only for ActorRegistry backward compat, will be removed later
newFuture completeWithResult actor
actor
} else { // we lost the race -- wait for future to complete
oldFuture.await.result.getOrElse(None)
oldFuture.await.resultOrException.getOrElse(None)
}
}