Is TestActorRef blocking probability relevant?

There is a warning in akka 2.3.9 documentation :

Any message is sent from TestProbeanother player who works to CallingThreadDispatcherrun the risk of blocking if this other actor can also send this probe. Implementation TestProbe.watchand TestProbe.unwatchalso send a message to Watchee, which means that it is dangerous to try to look like. TestActorReffrom TestProbe.

I tried to reproduce the described deadlock situation in the test using TestProbeand TestActorRef, since both useCallingThreadDispatcher

class DeadlockTest extends TestKit(ActorSystem()) with FunSuiteLike {
  test("deadlock attempt") {
    val b = TestProbe()
    val a = TestActorRef(new Actor {
      override def preStart() = b.ref ! "pre"
      def receive = {
        case msg =>
          sender ! msg
          context.stop(self)
      }
    })
    b.watch(a)
    b.send(a, "foo")
    b.expectMsg("pre")
    b.expectMsg("foo")
    b.expectTerminated(a)
    b.unwatch(a)
  }
}

I expected the test to hang, but it passed successfully.

Is the warning still relevant and is the probability of a deadlock high or out of date?

+4
1

, , TestProbes, , , , . - , .

, Akka Typed, , , .

0

Source: https://habr.com/ru/post/1584094/


All Articles