I create a named actor, stop it and recreate it with the same name. Because stop is async, I end up with exceptions like
akka.actor.InvalidActorNameException: actor name [databaseServer] is not unique!
[info] at akka.actor.dungeon.ChildrenContainer$NormalChildrenContainer.reserve(ChildrenContainer.scala:130)
[info] at akka.actor.dungeon.Children$class.reserveChild(Children.scala:77)
[info] at akka.actor.ActorCell.reserveChild(ActorCell.scala:373)
[info] at akka.actor.dungeon.Children$class.makeChild(Children.scala:215)
[info] at akka.actor.dungeon.Children$class.attachChild(Children.scala:42)
[info] at akka.actor.ActorCell.attachChild(ActorCell.scala:373)
[info] at akka.actor.ActorSystemImpl.actorOf(ActorSystem.scala:586)
[info] at org.distributedrange.actors.StreamActor$$anonfun$2.apply(StreamActor.scala:122)
I get the same exception even if I set an AtomicBoolean to true at:
override def postStop() = {
stopped.set(true)
super.postStop()
}
and then
while (!stopped.get) {
Thread.sleep(1)
}
Is there a way to "block" and wait till the actor stops?
(don't worry about the block part, it is only for test cases)
Thanks