Merge pull request #29045 from akka/wip-29044-MessageAdapterSpec-patriknw
fix race condition in MessageAdapterSpec, #29044
This commit is contained in:
commit
e43dfc189f
1 changed files with 11 additions and 9 deletions
|
|
@ -6,7 +6,6 @@ package akka.actor.typed.scaladsl
|
||||||
|
|
||||||
import com.typesafe.config.ConfigFactory
|
import com.typesafe.config.ConfigFactory
|
||||||
import org.scalatest.wordspec.AnyWordSpecLike
|
import org.scalatest.wordspec.AnyWordSpecLike
|
||||||
import org.slf4j.event.Level
|
|
||||||
|
|
||||||
import akka.actor.testkit.typed.TestException
|
import akka.actor.testkit.typed.TestException
|
||||||
import akka.actor.testkit.typed.scaladsl.LogCapturing
|
import akka.actor.testkit.typed.scaladsl.LogCapturing
|
||||||
|
|
@ -17,6 +16,7 @@ import akka.actor.typed.ActorRef
|
||||||
import akka.actor.typed.Behavior
|
import akka.actor.typed.Behavior
|
||||||
import akka.actor.typed.PostStop
|
import akka.actor.typed.PostStop
|
||||||
import akka.actor.typed.Props
|
import akka.actor.typed.Props
|
||||||
|
import akka.actor.typed.internal.AdaptMessage
|
||||||
|
|
||||||
object MessageAdapterSpec {
|
object MessageAdapterSpec {
|
||||||
val config = ConfigFactory.parseString("""
|
val config = ConfigFactory.parseString("""
|
||||||
|
|
@ -271,13 +271,15 @@ class MessageAdapterSpec
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
"log wrapped message of DeadLetter" in {
|
"redirect to DeadLetter after termination" in {
|
||||||
case class Ping(sender: ActorRef[Pong])
|
case class Ping(sender: ActorRef[Pong])
|
||||||
case class Pong(greeting: String)
|
case class Pong(greeting: String)
|
||||||
case class PingReply(response: Pong)
|
case class PingReply(response: Pong)
|
||||||
|
|
||||||
val pingProbe = createTestProbe[Ping]()
|
val pingProbe = createTestProbe[Ping]()
|
||||||
|
|
||||||
|
val deadLetterProbe = testKit.createDeadLetterProbe()
|
||||||
|
|
||||||
val snitch = Behaviors.setup[PingReply] { context =>
|
val snitch = Behaviors.setup[PingReply] { context =>
|
||||||
val replyTo = context.messageAdapter[Pong](PingReply)
|
val replyTo = context.messageAdapter[Pong](PingReply)
|
||||||
pingProbe.ref ! Ping(replyTo)
|
pingProbe.ref ! Ping(replyTo)
|
||||||
|
|
@ -287,13 +289,13 @@ class MessageAdapterSpec
|
||||||
|
|
||||||
createTestProbe().expectTerminated(ref)
|
createTestProbe().expectTerminated(ref)
|
||||||
|
|
||||||
LoggingTestKit.empty
|
|
||||||
.withLogLevel(Level.INFO)
|
|
||||||
.withMessageRegex("Pong.*wrapped in.*AdaptMessage.*dead letters encountered")
|
|
||||||
.expect {
|
|
||||||
pingProbe.receiveMessage().sender ! Pong("hi")
|
pingProbe.receiveMessage().sender ! Pong("hi")
|
||||||
}
|
val deadLetter = deadLetterProbe.receiveMessage()
|
||||||
|
deadLetter.message match {
|
||||||
|
case AdaptMessage(Pong("hi"), _) => // passed through the FunctionRef
|
||||||
|
case Pong("hi") => // FunctionRef stopped
|
||||||
|
case unexpected => fail(s"Unexpected message [$unexpected], expected Pong or AdaptMessage(Pong)")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue