You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make exception handling in AbstractContinuation consistent: always prefer exception thrown from coroutine as exceptional reason, add cancellation cause as suppressed exception
Add workaround to work with suppressed exceptions in tests
Copy file name to clipboardExpand all lines: common/kotlinx-coroutines-core-common/src/main/kotlin/kotlinx/coroutines/experimental/AbstractContinuation.kt
+14-9Lines changed: 14 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -234,7 +234,12 @@ internal abstract class AbstractContinuation<in T>(
234
234
} else {
235
235
/*
236
236
* If already cancelled block is resumed with an exception,
237
-
* then we should properly merge them to avoid information loss
237
+
* then we should properly merge them to avoid information loss.
238
+
*
239
+
* General rule:
240
+
* Thrown exception always becomes a result and cancellation reason
241
+
* is added to suppressed exceptions if necessary.
242
+
* Basic duplicate/cycles check is performed
238
243
*/
239
244
val update:CompletedExceptionally
240
245
@@ -244,15 +249,15 @@ internal abstract class AbstractContinuation<in T>(
244
249
* ```
245
250
* T1: ctxJob.cancel(e1) // -> cancelling
246
251
* T2:
247
-
* withContext(ctx) {
252
+
* withContext(ctx, Mode.ATOMIC) {
248
253
* // -> resumed with cancellation exception
249
254
* }
250
255
* ```
251
256
*/
252
257
if (proposedUpdate.cause isCancellationException) {
253
258
// Keep original cancellation cause and try add to suppressed exception from proposed cancel
0 commit comments