Skip to content

Commit

Permalink
close #7437 - fix KeyNotFoundException in DelegatingSupervisorStrategy (
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaronontheweb authored Dec 24, 2024
1 parent 507cff4 commit 400e7cb
Showing 1 changed file with 13 additions and 9 deletions.
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))
{
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

0 comments on commit 400e7cb

Please sign in to comment.