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 exception types for channels to ensure transparency & reporting #1158

Merged
merged 2 commits into from
Apr 30, 2019

Conversation

elizarov
Copy link
Contributor

  • ReceiveChannel.cancel always closes channel with CancellationException,
    so sending or receiving from a cancelled channel produces the
    corresponding CancellationException.
  • Cancelling produce builder has similar effect, but an more specific
    instance of JobCancellationException is created.
  • This ensure that produce/consumeEach pair is transparent with respect
    to cancellation and can be used to build "identity" transformation
    of the flow (the corresponding test is added).
  • ClosedSendChannelException is now a subclass of IllegalStateException,
    so that trying to send to a channel that was closed normally is
    reported as program error and is not eaten (test is added).

Fixes #957
Fixes #1128

* ReceiveChannel.cancel always closes channel with CancellationException,
  so sending or receiving from a cancelled channel produces the
  corresponding CancellationException.
* Cancelling produce builder has similar effect, but an more specific
  instance of JobCancellationException is created.
* This ensure that produce/consumeEach pair is transparent with respect
  to cancellation and can be used to build "identity" transformation
  of the flow (the corresponding test is added).
* ClosedSendChannelException is now a subclass of IllegalStateException,
  so that trying to send to a channel that was closed normally is
  reported as program error and is not eaten (test is added).

Fixes #957
Fixes #1128
@elizarov elizarov force-pushed the channel-exceptions branch from 03f2424 to 58a5585 Compare April 30, 2019 03:00
    * Documentation improved
    * Better exception message
    * Simplified flowOn implementation
    * Avoid exception instantiation on happy path in zip
Copy link
Contributor

@qwwdfsad qwwdfsad left a comment

Choose a reason for hiding this comment

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

Pushed minor changes, please take a look.
LGTM

@elizarov elizarov merged commit e569bd3 into develop Apr 30, 2019
@elizarov elizarov deleted the channel-exceptions branch April 30, 2019 13:57
zach-klippenstein added a commit to square/workflow that referenced this pull request Jun 13, 2019
 - Breakage in `CoroutineWorkflow` was caused by Kotlin/kotlinx.coroutines#1158.
 - Breakage in `ReactorAsWorkflowIntegrationTest` was probably caused by Kotlin/kotlinx.coroutines#1239.
zach-klippenstein added a commit to square/workflow that referenced this pull request Jun 13, 2019
 - Some things that were `@FlowPreview` have been graduated to `@ExperimentalCoroutinesApi`.
 - Breakage in `CoroutineWorkflow` was caused by Kotlin/kotlinx.coroutines#1158.
 - Breakage in `ReactorAsWorkflowIntegrationTest` was probably caused by Kotlin/kotlinx.coroutines#1239.
zach-klippenstein added a commit to square/workflow that referenced this pull request Jun 26, 2019
 - Some things that were `@FlowPreview` have been graduated to `@ExperimentalCoroutinesApi`.
 - Breakage in `CoroutineWorkflow` was caused by Kotlin/kotlinx.coroutines#1158.
 - Breakage in `ReactorAsWorkflowIntegrationTest` was probably caused by Kotlin/kotlinx.coroutines#1239.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants