Fix ReceiveTimeout issue with NotInfluenceReceiveTimeout #24770
This commit is contained in:
parent
f750f73e1f
commit
00f07c2429
2 changed files with 19 additions and 4 deletions
|
|
@ -113,5 +113,23 @@ class ReceiveTimeoutSpec extends AkkaSpec {
|
|||
ticks.cancel()
|
||||
system.stop(timeoutActor)
|
||||
}
|
||||
|
||||
"get timeout while receiving only NotInfluenceReceiveTimeout messages" taggedAs TimingTest in {
|
||||
val timeoutLatch = TestLatch(2)
|
||||
|
||||
val timeoutActor = system.actorOf(Props(new Actor {
|
||||
context.setReceiveTimeout(1 second)
|
||||
|
||||
def receive = {
|
||||
case ReceiveTimeout ⇒
|
||||
self ! TransperentTick
|
||||
timeoutLatch.countDown()
|
||||
case TransperentTick ⇒
|
||||
}
|
||||
}))
|
||||
|
||||
Await.ready(timeoutLatch, TestLatch.DefaultTimeout)
|
||||
system.stop(timeoutActor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,16 +26,13 @@ private[akka] trait ReceiveTimeout { this: ActorCell ⇒
|
|||
|
||||
final def checkReceiveTimeout() {
|
||||
val recvtimeout = receiveTimeoutData
|
||||
//Only reschedule if desired and there are currently no more messages to be processed
|
||||
if (!mailbox.hasMessages) recvtimeout._1 match {
|
||||
recvtimeout._1 match {
|
||||
case f: FiniteDuration ⇒
|
||||
recvtimeout._2.cancel() //Cancel any ongoing future
|
||||
val task = system.scheduler.scheduleOnce(f, self, akka.actor.ReceiveTimeout)(this.dispatcher)
|
||||
receiveTimeoutData = (f, task)
|
||||
case _ ⇒ cancelReceiveTimeout()
|
||||
}
|
||||
else cancelReceiveTimeout()
|
||||
|
||||
}
|
||||
|
||||
override final def cancelReceiveTimeout(): Unit =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue