From 8a20a375687ab6b59ee3f3bd76b5ae49769ff9d8 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Mon, 13 Feb 2012 22:27:33 +0100 Subject: [PATCH] Nulling out the actor field when the actor terminates --- .../src/main/scala/akka/actor/ActorCell.scala | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/akka-actor/src/main/scala/akka/actor/ActorCell.scala b/akka-actor/src/main/scala/akka/actor/ActorCell.scala index c22529b2c8..cfcce7ab2c 100644 --- a/akka-actor/src/main/scala/akka/actor/ActorCell.scala +++ b/akka-actor/src/main/scala/akka/actor/ActorCell.scala @@ -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 }