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

Complete removal of deprecated Job.cancel(cause) #975

Closed
elizarov opened this issue Feb 7, 2019 · 1 comment
Closed

Complete removal of deprecated Job.cancel(cause) #975

elizarov opened this issue Feb 7, 2019 · 1 comment

Comments

@elizarov
Copy link
Contributor

elizarov commented Feb 7, 2019

See #481 for original motivation. Now, with introduction of CompletableJob (#607) we need to complete the process of Job.cancel(cause) removal, however, it poses the following challenges:

  • It is used in all integrations based on AbstractCoroutine (CompletableFuture, ListenableFuture, Rx integrations) to exceptionally terminate AbstractCoroutine on the failure of the primitive that integration is performed with either directly by calling cancel(cause) or via an internal function handleCoroutineException.

  • Deferred.asCompletableFuture() uses it for a two-way cancellation integration:

future.whenComplete { _, exception -> cancel(exception) }
elizarov added a commit that referenced this issue Mar 1, 2019
Job/ReceiveChannel/BroadcastChannel.cancel(Throwable) is now hidden and
cannot be invoked from a newly compiled code. This function had broken
semantics when used with an arbitrary exception. A safe replacement
is available in the form of cancel(CancellationException) where
CancellationException can be used to supply additional information
for debugging purposes.

Fixes #975
@elizarov
Copy link
Contributor Author

elizarov commented Mar 1, 2019

After some prototype, I'm leaving cancel(cause: CancellationException? = null) function. This way, you can still add additional details as a cancellation cause, but now it is clear that it is going to be a CancellationException and you cannot cause the coroutine you don't control to fail.

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

1 participant