You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:.
The text was updated successfully, but these errors were encountered:
This behaviour can be fixed by reordering the case labels, e.g.:
{
switch (reply)
{
case T wtv:
return wtv;
case null:
return default;
case Status.Failure fail:
throw fail.Cause;
default:
throw new ArgumentException();
}
}
private T GetResult2<T>(object reply)
{
switch (reply)
{
case Status.Failure fail:
throw fail.Cause;
case T wtv:
return wtv;
case null:
return default;
default:
throw new ArgumentException();
}
}
```
The first method returns the Failure as object but the second method rethrows the exception.
Nice catch! Yes, we should apply your fix and just re-do the case labels here. If you'd like to send in a small PR with a reproduction spec we'd be happy to merge it. We can write something ourselves too - but totally up to you.
reproduction spec we'd be happy to merge it. We can write something ourselves too - but totally up to you.
I am afraid I won't be able to write a PR with tests soon, I am really busy at work, sorry. Thanks for accepting the bug report tho, fixing it will allow us to simplify our company code.
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
:when T is object and message is Status.Failure the
case T t:
is executed instead ofcase Status.Failure f:
.The text was updated successfully, but these errors were encountered: