to avoid loading serializers before ActorRefProvider has been initialized
This commit is contained in:
parent
5be3c7bf83
commit
7d67524bb5
2 changed files with 49 additions and 14 deletions
|
|
@ -13,7 +13,6 @@ import akka.testkit.typed.scaladsl.{ ActorTestKit, TestProbe }
|
|||
import akka.actor.typed.{ ActorRef, ActorRefResolver, Props, TypedAkkaSpecWithShutdown }
|
||||
import akka.serialization.SerializerWithStringManifest
|
||||
import com.typesafe.config.ConfigFactory
|
||||
|
||||
import scala.concurrent.Await
|
||||
import scala.concurrent.duration._
|
||||
|
||||
|
|
@ -62,6 +61,9 @@ object ClusterSingletonApiSpec {
|
|||
}
|
||||
|
||||
class PingSerializer(system: ExtendedActorSystem) extends SerializerWithStringManifest {
|
||||
// Reproducer of issue #24620, by eagerly creating the ActorRefResolver in serializer
|
||||
val actorRefResolver = ActorRefResolver(system.toTyped)
|
||||
|
||||
def identifier: Int = 47
|
||||
def manifest(o: AnyRef): String = o match {
|
||||
case _: Ping ⇒ "a"
|
||||
|
|
@ -70,13 +72,13 @@ object ClusterSingletonApiSpec {
|
|||
}
|
||||
|
||||
def toBinary(o: AnyRef): Array[Byte] = o match {
|
||||
case p: Ping ⇒ ActorRefResolver(system.toTyped).toSerializationFormat(p.respondTo).getBytes(StandardCharsets.UTF_8)
|
||||
case p: Ping ⇒ actorRefResolver.toSerializationFormat(p.respondTo).getBytes(StandardCharsets.UTF_8)
|
||||
case Pong ⇒ Array.emptyByteArray
|
||||
case Perish ⇒ Array.emptyByteArray
|
||||
}
|
||||
|
||||
def fromBinary(bytes: Array[Byte], manifest: String): AnyRef = manifest match {
|
||||
case "a" ⇒ Ping(ActorRefResolver(system.toTyped).resolveActorRef(new String(bytes, StandardCharsets.UTF_8)))
|
||||
case "a" ⇒ Ping(actorRefResolver.resolveActorRef(new String(bytes, StandardCharsets.UTF_8)))
|
||||
case "b" ⇒ Pong
|
||||
case "c" ⇒ Perish
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue