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

fix KeyNotFoundException in DelegatingSupervisorStrategy #7438

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions src/core/Akka.TestKit/DelegatingSupervisorStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,19 @@ public class DelegatingSupervisorStrategy : SupervisorStrategy

protected override Directive Handle(IActorRef child, Exception exception)
{
var childDelegate = Delegates[child];
var handleMethod = typeof(SupervisorStrategy).GetMethod(
name: "Handle",
bindingAttr: BindingFlags.Instance | BindingFlags.NonPublic,
binder: Type.DefaultBinder,
types: new[] {typeof(IActorRef), typeof(Exception)},
modifiers: null);
var result = (Directive) handleMethod.Invoke(childDelegate, new object[]{ child, exception });
return result;
if(Delegates.TryGetValue(child, out var childDelegate))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check if the child IActorRef has a strategy specified at all - if not, fall back to the default.

{
var handleMethod = typeof(SupervisorStrategy).GetMethod(
name: "Handle",
bindingAttr: BindingFlags.Instance | BindingFlags.NonPublic,
binder: Type.DefaultBinder,
types: new[] {typeof(IActorRef), typeof(Exception)},
modifiers: null);
var result = (Directive) handleMethod.Invoke(childDelegate, new object[]{ child, exception });
return result;
}

return DefaultDecider.Decide(exception);
}

public override void ProcessFailure(IActorContext context, bool restart, IActorRef child, Exception cause, ChildRestartStats stats,
Expand Down
Loading