I think that is how it is implemented. Exception from preStart results in
clearing the actor field and throwing ActorInitializationException:
https://github.com/akka/akka/blob/master/akka-actor/src/main/scala/akka/actor/ActorCell.scala#L599

Default supervision will result in stop, but postStop is not called because
the actor field was cleared:
https://github.com/akka/akka/blob/master/akka-actor/src/main/scala/akka/actor/dungeon/FaultHandling.scala#L210

On Wed, Mar 30, 2016 at 10:59 AM, Endre Varga <[email protected]>
wrote:

>
>
> On Sun, Mar 27, 2016 at 5:52 PM, Stanislav Savulchik <
> [email protected]> wrote:
>
>> Hi, everyone!
>>
>> I've discovered that Actor's postStop method doesn't get invoked if
>> exception occurs during actor initialization via preStart method. Does
>> anyone know if it is the correct behavior? I expected that the failed actor
>> could close some resources in postStop.
>>
>
> Do you have a reproducer for this? I would also expect postStop to be at
> least attempted to be called.
>
>
>> P.S. The behavior differs when a failure occurs during regular vs. system
>> message processing and supervisor decides to Stop the failed child. It
>> seems inconsistent to me.
>>
>
> What do you mean here? Can you provide a small example to show this?
>
>
>> --
>> >>>>>>>>>> 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 [email protected].
>> To post to this group, send email to [email protected].
>> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Patrik Nordwall
Akka Tech Lead
Lightbend <http://www.lightbend.com/> -  Reactive apps on the JVM
Twitter: @patriknw

[image: Lightbend] <http://www.lightbend.com/>

-- 
>>>>>>>>>>      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 [email protected].
To post to this group, send email to [email protected].
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