Restructuring the ordering of recreating actor instances so it's more safe if the constructor fails on recreate
This commit is contained in:
parent
950b11850a
commit
4c06b559bc
1 changed files with 12 additions and 11 deletions
|
|
@ -331,20 +331,21 @@ private[akka] class ActorCell(
|
|||
|
||||
case failedActor if recreation ⇒
|
||||
val reason = new Exception("CRASHED") //FIXME TODO stash away the exception that caused the failure and reuse that? <------- !!!!!!!!!! RED RED RED
|
||||
try {
|
||||
if (Actor.debugLifecycle) EventHandler.debug(failedActor, "restarting")
|
||||
val freshActor = newActor()
|
||||
clearActorContext()
|
||||
if (failedActor ne null) {
|
||||
val c = currentMessage //One read only plz
|
||||
if (Actor.debugLifecycle) EventHandler.debug(failedActor, "restarting")
|
||||
val freshActor = newActor()
|
||||
if (failedActor ne null) {
|
||||
val c = currentMessage //One read only plz
|
||||
try {
|
||||
failedActor.preRestart(reason, if (c ne null) Some(c.message) else None)
|
||||
} finally {
|
||||
clearActorContext()
|
||||
currentMessage = null
|
||||
actor = null
|
||||
}
|
||||
actor = freshActor // assign it here so if preStart fails, we can null out the sef-refs next call
|
||||
freshActor.postRestart(reason)
|
||||
if (Actor.debugLifecycle) EventHandler.debug(freshActor, "restarted")
|
||||
} finally {
|
||||
currentMessage = null
|
||||
}
|
||||
actor = freshActor // assign it here so if preStart fails, we can null out the sef-refs next call
|
||||
freshActor.postRestart(reason)
|
||||
if (Actor.debugLifecycle) EventHandler.debug(freshActor, "restarted")
|
||||
|
||||
dispatcher.resume(this) //FIXME should this be moved down?
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue