From 43febd0b6513b1d323bb5ebea800b6691cd9698d Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Fri, 16 Mar 2012 16:54:00 +0100 Subject: [PATCH] Making sure that we only publish the truth about watch/unwatch --- akka-actor/src/main/scala/akka/actor/ActorCell.scala | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/akka-actor/src/main/scala/akka/actor/ActorCell.scala b/akka-actor/src/main/scala/akka/actor/ActorCell.scala index c22b636901..382086ebbc 100644 --- a/akka-actor/src/main/scala/akka/actor/ActorCell.scala +++ b/akka-actor/src/main/scala/akka/actor/ActorCell.scala @@ -555,13 +555,15 @@ private[akka] class ActorCell( def resume(): Unit = if (isNormal) dispatcher resume this def link(subject: ActorRef): Unit = if (!isTerminating) { - system.deathWatch.subscribe(self, subject) - if (system.settings.DebugLifecycle) system.eventStream.publish(Debug(self.path.toString, clazz(actor), "now monitoring " + subject)) + if (system.deathWatch.subscribe(self, subject)) { + if (system.settings.DebugLifecycle) system.eventStream.publish(Debug(self.path.toString, clazz(actor), "now monitoring " + subject)) + } } def unlink(subject: ActorRef): Unit = if (!isTerminating) { - system.deathWatch.unsubscribe(self, subject) - if (system.settings.DebugLifecycle) system.eventStream.publish(Debug(self.path.toString, clazz(actor), "stopped monitoring " + subject)) + if (system.deathWatch.unsubscribe(self, subject)) { + if (system.settings.DebugLifecycle) system.eventStream.publish(Debug(self.path.toString, clazz(actor), "stopped monitoring " + subject)) + } } def terminate() {