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 Akka.Util.Result edge case #7433

Merged
merged 2 commits into from
Dec 23, 2024

Conversation

Arkatufus
Copy link
Contributor

@Arkatufus Arkatufus commented Dec 23, 2024

Fixes #7432

Changes

  • Make sure that Akka.Util.Result<T>.FromTask() checks for edge cases
  • Change Akka.Util.Result<T>.FromTask() behavior, it will now throw if the Task argument is not completed.

Checklist

For significant changes, please ensure that the following have been completed (delete if not relevant):

Copy link
Contributor Author

@Arkatufus Arkatufus left a comment

Choose a reason for hiding this comment

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

Self-review

Comment on lines +146 to +158
if (task.IsCanceled && task.Exception is null)
{
try
{
_ = task.GetAwaiter().GetResult();
}
catch(Exception e)
{
return new Result<T>(e);
}

throw new InvalidOperationException("Should never reach this line!");
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fix, detect edge case where a Task is cancelled and its Exception property is null.

Copy link
Member

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor Author

@Arkatufus Arkatufus left a comment

Choose a reason for hiding this comment

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

Self-review

Comment on lines +140 to +141
if(!task.IsCompleted)
throw new ArgumentException("Task is not completed. Result.FromTask only accepts completed tasks.", nameof(task));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

New behavior, .FromTask() did not check if the Task argument is completed or not, it should only accept completed tasks

@Aaronontheweb Aaronontheweb enabled auto-merge (squash) December 23, 2024 16:01
Copy link
Member

@Aaronontheweb Aaronontheweb left a comment

Choose a reason for hiding this comment

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

LGTM

@Aaronontheweb Aaronontheweb merged commit 8bbffcd into akkadotnet:dev Dec 23, 2024
10 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stream upstream error propagation can fail in async calls
2 participants