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 } diff --git a/akka-actor/src/main/scala/akka/dispatch/BalancingDispatcher.scala b/akka-actor/src/main/scala/akka/dispatch/BalancingDispatcher.scala index ec675f7b5b..a7f03db5a0 100644 --- a/akka-actor/src/main/scala/akka/dispatch/BalancingDispatcher.scala +++ b/akka-actor/src/main/scala/akka/dispatch/BalancingDispatcher.scala @@ -95,8 +95,7 @@ class BalancingDispatcher( override protected[akka] def dispatch(receiver: ActorCell, invocation: Envelope) = { messageQueue.enqueue(receiver.self, invocation) - registerForExecution(receiver.mailbox, false, false) - teamWork() + if (!registerForExecution(receiver.mailbox, false, false)) teamWork() } protected def teamWork(): Unit = if (attemptTeamWork) {