Merge pull request #26142 from nvollmar/wip-26141-fix-backoff-supervisor
Fixes final stop message handling #26141
This commit is contained in:
commit
6d6ac21f30
2 changed files with 21 additions and 2 deletions
|
|
@ -350,7 +350,25 @@ class BackoffSupervisorSpec extends AkkaSpec with ImplicitSender with Eventually
|
||||||
c1 ! PoisonPill
|
c1 ! PoisonPill
|
||||||
expectTerminated(c1)
|
expectTerminated(c1)
|
||||||
expectTerminated(supervisor)
|
expectTerminated(supervisor)
|
||||||
|
}
|
||||||
|
|
||||||
|
"supervisor must not stop when final stop message has not been received" in {
|
||||||
|
val stopMessage = "stop"
|
||||||
|
val supervisorWatcher = TestProbe()
|
||||||
|
val supervisor: ActorRef = create(onStopOptions(maxNrOfRetries = 100).withFinalStopMessage(_ == stopMessage))
|
||||||
|
supervisor ! BackoffSupervisor.GetCurrentChild
|
||||||
|
val c1 = expectMsgType[BackoffSupervisor.CurrentChild].ref.get
|
||||||
|
watch(c1)
|
||||||
|
watch(supervisor)
|
||||||
|
supervisorWatcher.watch(supervisor)
|
||||||
|
|
||||||
|
c1 ! PoisonPill
|
||||||
|
expectTerminated(c1)
|
||||||
|
supervisor ! "ping"
|
||||||
|
supervisorWatcher.expectNoMessage(20.millis) // supervisor must not terminate
|
||||||
|
|
||||||
|
supervisor ! stopMessage
|
||||||
|
expectTerminated(supervisor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -436,9 +436,10 @@ private[akka] trait HandleBackoff { this: Actor ⇒
|
||||||
finalStopMessage match {
|
finalStopMessage match {
|
||||||
case None ⇒
|
case None ⇒
|
||||||
case Some(fsm) ⇒
|
case Some(fsm) ⇒
|
||||||
fsm(msg)
|
if (fsm(msg)) {
|
||||||
context.stop(self)
|
context.stop(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue