Added error handling to the actor creation in the different providers
This commit is contained in:
parent
07012b3d62
commit
07b29c0627
2 changed files with 21 additions and 61 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue