Cannot migrate to Akka typed if there are multi-jvm/multi-node tests in project

We are using akka 2.5.22 and we have been in process of migrating our project to typed for more than a week now. We replaced all our untyped actors to typed and now we are trying to replace our top level untyped actor system to typed.

We got stuck in replacing our actor system to typed because we have multi-jvm/multi-node tests in our project.

We extend MultiNodeSpec for our multi-jvm test and it happens to take untyped actor system to create actors internally via untypedSystem.actorOf. And we want to keep our top level actor system to be typed. So, When we create a typed system, adapt it to untyped and pass it to MultiNodeSpec then, the test fails with the following exception:

[error] Exception in thread "main" java.lang.UnsupportedOperationException: cannot create top-level actor from the outside on ActorSystem with custom user guardian
[error] 	at akka.actor.ActorSystemImpl.actorOf(ActorSystem.scala:786)
[error] 	at App1$.delayedEndpoint$App1$1(App1.scala:12)
[error] 	at App1$delayedInit$body.apply(App1.scala:6)
[error] 	at scala.Function0.apply$mcV$sp(Function0.scala:39)
[error] 	at scala.Function0.apply$mcV$sp$(Function0.scala:39)
[error] 	at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17)
[error] 	at scala.App.$anonfun$main$1$adapted(App.scala:80)
[error] 	at scala.collection.immutable.List.foreach(List.scala:392)
[error] 	at scala.App.main(App.scala:80)
[error] 	at scala.App.main$(App.scala:78)
[error] 	at App1$.main(App1.scala:6)
[error] 	at App1.main(App1.scala)

So, while tracing back the exception, we got to know that untypedSystem.actorOf checks if a custom guardian is wired or not, if it is then it throws the above mentioned exception and in case of untypedSystem being created from typed system will always have a guardian actor (in our case guardian actor is an actor with empty behavior).

For more details about this error please refer this discussion.

So, we feel that we are left with following options:

  • Abandon the task of migrating project to fully typed project

  • ActorSystemImpl does not throw the above mentioned error if typed system is adapted to untyped and used to create user space actor via untypedSystem.actorOf

  • MultiNodeSpec creates internal actors via untypedSystem.systemActorOf instead of untypedSystem.actorOf as systemActorOf does not throw above exception when untypedSystem is adapted from typedSystem

  • akka-multi-node-testkit gets migrated to typed and MultiNodeSpec expects typed system instead of untyped system

So, to conclude, our question is how should we proceed for our task of migrating our project to fully typed project?

1 Like

We can probably change MultiNodeSpec to use systemActorOf. Please create issue or PR. Thanks for reporting.

Sure, I will create a PR