Skip to content

Ask<object> will not throw exception when the response is Status.Failure #7254

@ondravondra

Description

@ondravondra

Version Information
Version of Akka.NET? 1.5.15

Describe the bug
Ask will not throw exception when the response is Status.Failure

This is caused by the order of case statements in FutureActorRef<T>.TellInternal:

            switch (message)
            {
                case ISystemMessage msg:
                    handled = _result.TrySetException(new InvalidOperationException($"system message of type '{msg.GetType().Name}' is invalid for {nameof(FutureActorRef<T>)}"));
                    break;
                case T t:
                    handled = _result.TrySetResult(t);
                    break;
                case null:
                    handled = _result.TrySetResult(default);
                    break;
                case Status.Failure f:
                    handled = _result.TrySetException(f.Cause
                        ?? new TaskCanceledException("Task cancelled by actor via Failure message."));
                    break;

when T is object and message is Status.Failure the case T t: is executed instead of case Status.Failure f:.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions