Merge pull request #1054 from akka/wip-2928-log-postStop-failures-∂π

log failures in postStop, see #2928
This commit is contained in:
Roland Kuhn 2013-01-24 04:45:34 -08:00
commit 04cf9dea0d
2 changed files with 13 additions and 1 deletions

View file

@ -119,6 +119,16 @@ class ActorLifeCycleSpec extends AkkaSpec with BeforeAndAfterEach with ImplicitS
system.stop(supervisor) system.stop(supervisor)
} }
"log failues in postStop" in {
val a = system.actorOf(Props(new Actor {
def receive = Actor.emptyBehavior
override def postStop { throw new Exception("hurrah") }
}))
EventFilter[Exception]("hurrah", occurrences = 1) intercept {
a ! PoisonPill
}
}
"clear the behavior stack upon restart" in { "clear the behavior stack upon restart" in {
case class Become(recv: ActorContext Receive) case class Become(recv: ActorContext Receive)
val a = system.actorOf(Props(new Actor { val a = system.actorOf(Props(new Actor {

View file

@ -199,7 +199,9 @@ private[akka] trait FaultHandling { this: ActorCell ⇒
* specific order. * specific order.
*/ */
try if (a ne null) a.postStop() try if (a ne null) a.postStop()
finally try dispatcher.detach(this) catch {
case NonFatal(e) publish(Error(e, self.path.toString, clazz(a), e.getMessage))
} finally try dispatcher.detach(this)
finally try parent.sendSystemMessage(ChildTerminated(self)) finally try parent.sendSystemMessage(ChildTerminated(self))
finally try parent ! NullMessage // read ScalaDoc of NullMessage to see why finally try parent ! NullMessage // read ScalaDoc of NullMessage to see why
finally try tellWatchersWeDied(a) finally try tellWatchersWeDied(a)