log failures in postStop, see #2928

This commit is contained in:
Roland 2013-01-23 23:47:15 +01:00
parent 40a67a4097
commit a80b5269e6
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)