Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Routers seem ignore supervision strategy #996

Closed
simonlaroche opened this issue May 20, 2015 · 4 comments · Fixed by #1000
Closed

Routers seem ignore supervision strategy #996

simonlaroche opened this issue May 20, 2015 · 4 comments · Fixed by #1000
Assignees

Comments

@simonlaroche
Copy link

If I provide a supervision strategy to a router config it never gets called on an exception from a routee.

It seems that the strategy gets overwritten be the default strategy in ActorBase.

Failing test:

public class RouterSupervisorSpec : AkkaSpec
    {
        #region Killable actor

        class KillableActor : ReceiveActor
        {
            private readonly IActorRef TestActor;

            public KillableActor(IActorRef testActor)
            {
                this.TestActor = testActor;
                this.Receive<string>(s => s == "go away", s =>
                    {
                        throw new ArgumentException("Goodbye then!");
                    });
            }
        }

        #endregion

        #region Tests

        [Fact]
        public void Routers_must_use_provided_supervisor_strategy()
        {
            var router = this.Sys.ActorOf(Props.Create(() => new KillableActor(this.TestActor))
                .WithRouter(
                new RoundRobinPool(1, null, new OneForOneStrategy(
                    exception =>
                    {
                        this.TestActor.Tell("supervised");
                        return Directive.Stop;
                    }), 
                    null)), 
                    "router1");

            router.Tell("go away");

            this.ExpectMsg("supervised", TimeSpan.FromSeconds(2));
        }

        #endregion
    }
@Aaronontheweb
Copy link
Member

Good find! would you mind submitting this failing test as a PR?

@simonlaroche
Copy link
Author

Done

@rogeralsing
Copy link
Contributor

I've found the reason for it.

        private ActorBase NewActor()
        {
            PrepareForNewActor();
            ActorBase instance=null;
            UseThreadContext(() =>
            {
                _state = _state.ClearBehaviorStack();

       //the router actor is created here, with the correct supervisor strategy

                instance = CreateNewActorInstance();

       //which is then overwritten by the props supervisor strategy (which doesnt exist in JVM)

                instance.SupervisorStrategyInternal = _props.SupervisorStrategy;
            });
            return instance;
        }

@rogeralsing
Copy link
Contributor

I've made a PR for this #1000

Horusiath pushed a commit to Horusiath/akka.net that referenced this issue Jul 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants