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

PipeTo creates an invalid Status.Failure object if task is cancelled #1521

Closed
akoshelev opened this issue Dec 9, 2015 · 6 comments
Closed

Comments

@akoshelev
Copy link

The following code cause problems if tresult is cancelled

if (tresult.IsCanceled || tresult.IsFaulted)

 if (tresult.IsCanceled || tresult.IsFaulted)
                    recipient.Tell(failure != null
                        ? failure((Exception)tresult.Exception)
                        // if tresult is cancelled, tresult.Exception == null
                        : new Status.Failure((Exception)tresult.Exception), sender);
...

If user does not handle this message in recipient actor and akka.actor.debug.unhandled = true, NullReferenceException is thrown, as UnhandledMessageForwarder calls message.ToString()

Status.Failure does not check the input parameter and ToString() overload calls Cause.ToString() w/o checking for null.

return "Failure: " + Cause.ToString();

What'd be the correct way to fix this? I see a couple of possible fixes:

  • Create a TaskCancelledException inside PipeToSupport class
  • Extend Status.Failure and allow to create an instance without specifying an exception - maybe indicate that task was cancelled by passing a task instance
@rogeralsing
Copy link
Contributor

Extend Status.Failure and allow to create an instance without specifying an exception - maybe indicate that task was cancelled by passing a task instance

Do note that the Failure class could be passed between nodes, and thus needs to serialize well.
So if we give it an overload for failed Task then we need to extract the exception information from it so that we do not hold a reference to the task itself.
Maybe I'm stating the obvious here but whatever solution we go for, Failure needs to be serialization friendly.

@Aaronontheweb
Copy link
Member

Create a TaskCancelledException inside PipeToSupport class

I've refactored to this method to do this like 3 times, but then I remember that the way it's designed currently is consistent with the JVM design and even enforced via unit test.

Frankly I think the JVM design here is pretty shitty - just throw an exception.

@akoshelev
Copy link
Author

What if we just create a TaskCancelledException there? It won't break current design, although looks a bit weird, and I see similar code in other modules

query.Client.Tell(new Status.Failure(new TimeoutException("Deadline passed")));

@guessmyname
Copy link

Hello. Any word on a fix for this issue? I'm getting the same issue.
I would be happy to work on this bug. Just let me know how I should approach the fix.
Thanks.
Brad

@Horusiath
Copy link
Contributor

Related: #3320

@Aaronontheweb
Copy link
Member

Resolved via #5123

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants