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

Properly check identity of caught AbortFlowException in Flow.first op… #2057

Merged
merged 3 commits into from May 27, 2020

Conversation

qwwdfsad
Copy link
Member

…erator.

It fixes two problems:
* NoSuchElementException can be thrown during cancellation sequence (see FirstJvmTest that reproduces this problem with explanation)
* Cancellation can be accidentally suppressed and flow activity can be prolonged

Fixes #2051

@qwwdfsad qwwdfsad requested a review from elizarov May 25, 2020 14:18
@qwwdfsad qwwdfsad marked this pull request as ready for review May 25, 2020 14:19
…erator.

It fixes two problems:
    * NoSuchElementException can be thrown during cancellation sequence (see FirstJvmTest that reproduces this problem with explanation)
    * Cancellation can be accidentally suppressed and flow activity can be prolonged

Fixes #2051
Copy link
Contributor

@elizarov elizarov left a comment

Choose a reason for hiding this comment

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

It is great, but there is a lot of copy-paste between different terminal operators in this code. Now their source is hard to read. I suggest to introduce new (experimental) terminal operator collectWhile that will contain all the "abort exception magic" and rewrite all size-limited operators from the firstXxx family using collectWhile, keeping their source easy to read.

@qwwdfsad qwwdfsad merged commit adbbbaa into develop May 27, 2020
@qwwdfsad qwwdfsad deleted the first-suppressed-afe branch May 27, 2020 08:57
recheej pushed a commit to recheej/kotlinx.coroutines that referenced this pull request Dec 28, 2020
Kotlin#2057)

It fixes two problems:
    * NoSuchElementException can be thrown during cancellation sequence (see FirstJvmTest that reproduces this problem with explanation)
    * Cancellation can be accidentally suppressed and flow activity can be prolonged

Fixes Kotlin#2051
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.

None yet

2 participants