Merge pull request #26142 from nvollmar/wip-26141-fix-backoff-supervisor

Fixes final stop message handling #26141
This commit is contained in:
Patrik Nordwall 2018-12-21 11:17:51 +01:00 committed by GitHub
commit 6d6ac21f30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 2 deletions

View file

@ -350,7 +350,25 @@ class BackoffSupervisorSpec extends AkkaSpec with ImplicitSender with Eventually
c1 ! PoisonPill
expectTerminated(c1)
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)
}
}
}

View file

@ -436,8 +436,9 @@ private[akka] trait HandleBackoff { this: Actor ⇒
finalStopMessage match {
case None
case Some(fsm)
fsm(msg)
context.stop(self)
if (fsm(msg)) {
context.stop(self)
}
}
}
}