Nulling out the actor field when the actor terminates

This commit is contained in:
Viktor Klang 2012-02-13 22:27:33 +01:00
parent 68d0e2612d
commit 8a20a37568

View file

@ -388,8 +388,6 @@ private[akka] class ActorCell(
failedActor.preRestart(cause, if (c ne null) Some(c.message) else None)
} finally {
clearActorFields()
currentMessage = null
actor = null
}
}
actor = freshActor // assign it here so if preStart fails, we can null out the sef-refs next call
@ -559,9 +557,8 @@ private[akka] class ActorCell(
if (system.settings.DebugLifecycle)
system.eventStream.publish(Debug(self.path.toString, clazz(actor), "stopped")) // FIXME: can actor be null?
} finally {
currentMessage = null
clearActorFields()
if (a ne null) a.clearBehaviorStack()
clearActorFields()
}
}
}
@ -601,7 +598,11 @@ private[akka] class ActorCell(
}
}
final def clearActorFields(): Unit = setActorFields(context = null, self = system.deadLetters)
final def clearActorFields(): Unit = {
setActorFields(context = null, self = system.deadLetters)
currentMessage = null
actor = null
}
final def setActorFields(context: ActorContext, self: ActorRef) {
@tailrec
@ -629,8 +630,5 @@ private[akka] class ActorCell(
}
}
private def clazz(o: AnyRef): Class[_] = {
if (o eq null) this.getClass
else o.getClass
}
private final def clazz(o: AnyRef): Class[_] = if (o eq null) this.getClass else o.getClass
}