In other words, only the *parent* of the stopped actor can safely "aha!
I've seen it stopped, so I'll start a new one with the same name".
This is documented behavior in the Actor docs :)

-- 
Konrad `ktoso` Malawski
Akka <http://akka.io> @ Lightbend <http://lightbend.com>

On 28 April 2017 at 00:17:38, Viktor Klang (viktor.kl...@gmail.com) wrote:

Hi Piotr,

the test thread having observed the termination does not mean that the user
guardian (/user) has observed it.

On Thu, Apr 27, 2017 at 4:53 PM, Piotr Droździel <piotrdma...@gmail.com>
wrote:

> Hello,
> Akka docs say:
>
>> Warning
>>
>> Keep in mind that an actor stopping and its name being deregistered are
>> separate events which happen asynchronously from each other. Therefore it
>> may be that you will find the name still in use after gracefulStop() 
>> returned.
>> In order to guarantee proper deregistration, only reuse names from within a
>> supervisor you control and only in response to a Terminated message,
>> i.e. not for top-level actors.
>>
>
> But when testing one of the actors I get InvalidActorNameException even
> after expectTerminated was successful. This is the test:
>
>
> "stop self when finished" in {
>  val fetcher = system.actorOf(EventFetcherActor.props(eventId), "name1")
>
>  watch(fetcher)
>  // interact with the actor, it will call context.stop(self) after
> interaction
>  expectTerminated(fetcher)
>
>  system.actorOf(EventFetcherActor.props(eventId), "name1") //Exception
> thrown
> }
>
> 90% of times I run it, the test passes. But what is the reason of
> failures? Can it be related to the fact that it's unit test?
>
> This is exception message I get:
> actor name [name1] is not unique!
> akka.actor.InvalidActorNameException: actor name [name1] is not unique!
> at akka.actor.dungeon.ChildrenContainer$NormalChildrenContainer.
> reserve(ChildrenContainer.scala:129)
> at akka.actor.dungeon.Children$class.reserveChild(Children.scala:130)
> at akka.actor.ActorCell.reserveChild(ActorCell.scala:374)
> at akka.actor.dungeon.Children$class.makeChild(Children.scala:268)
> at akka.actor.dungeon.Children$class.attachChild(Children.scala:46)
> --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/
> current/additional/faq.html
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>



--
Cheers,
√
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups
"Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to