/* Ċ Ġ* ĠCopyright Ġ 2 0 1 6 - 2 0 1 8 ĠJetBrains Ġs . r . o . ĠUse Ġof Ġthis Ġsource Ġcode Ġis Ġgoverned Ġby Ġthe ĠApache Ġ 2 . 0 Ġlicense . Ċ Ġ*/ Ċ Ċ @ file : Suppress (" Deferred Result Unused ", Ġ" DE PREC ATION ") Ċ Ċ package Ġkotlinx . coroutines . exceptions Ċ Ċ import Ġkotlinx . coroutines .* Ċ import Ġkotlinx . coroutines . channels .* Ċ import Ġorg . junit .* Ċ import Ġkotlin . coroutines .* Ċ Ċ class ĠStack Trace Recovery Nested Channels Test Ġ: ĠTest Base () Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġchannel Ġ= ĠChannel < Int >( 0 ) ĊĊĠĠĠ Ġprivate Ġsuspend Ġfun Ġsend WithContext ( ctx : ĠCor outine Context ) Ġ= Ġwith Context ( ctx ) Ġ{ ĊĠĠĠĠĠĠĠ Ġsend In Channel () ĊĠĠĠĠĠĠĠ Ġyield () Ġ// ĠT CE ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġsuspend Ġfun Ġsend In Channel () Ġ{ ĊĠĠĠĠĠĠĠ Ġchannel . send ( 4 2 ) ĊĠĠĠĠĠĠĠ Ġyield () Ġ// ĠT CE ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġsuspend Ġfun Ġsend From Scope () Ġ= Ġcoroutine Scope Ġ{ ĊĠĠĠĠĠĠĠ Ġsend WithContext ( wrapper Dispatcher ( coroutine Context )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Offer With Current Context () Ġ= Ġrun Test Ġ{ ĊĠĠĠĠĠĠĠ Ġchannel . close ( Recover able Test Exception ()) ĊĊĠĠĠĠĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġyield () Ġ// ĠWill Ġbe Ġfixed Ġin Ġ 1 . 3 . 2 0 Ġafter ĠK T - 2 7 1 9 0 ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsend WithContext ( coroutine Context ) ĊĠĠĠĠĠĠĠ Ġ} Ġcatch Ġ( e : ĠException ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify StackTrace ( e , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" kotlin x . coroutines . Recover able Test Exception \ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . exceptions . StackTrace Recovery Nested Channels Test \$ test Offer With Current Context \$ 1 . invoke Suspend ( StackTrace Recovery Nested Channels Test . kt : 3 4 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ t ( Coroutine Ġboundary )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . channels . Abstract Send Channel . offer ( Abstract Channel . kt : 1 8 0 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . channels . Abstract Send Channel . send ( Abstract Channel . kt : 1 6 8 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . exceptions . StackTrace Recovery Nested Channels Test . send In Channel ( StackTrace Recovery Nested Channels Test . kt : 2 4 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . exceptions . StackTrace Recovery Nested Channels Test \$ send WithContext \$ 2 . invoke Suspend ( StackTrace Recovery Nested Channels Test . kt : 1 9 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . exceptions . StackTrace Recovery Nested Channels Test \$ send WithContext \$ 2 . invoke ( StackTrace Recovery Nested Channels Test . kt )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . intr insics . Un dis patched Kt . start Un dis patched Or Return ( Un dis patched . kt : 8 5 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . Builders Kt __ Builders _ common Kt . with Context ( Builders . common . kt : 1 4 6 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . Builders Kt . with Context ( Unknown ĠSource )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . exceptions . StackTrace Recovery Nested Channels Test . send WithContext ( StackTrace Recovery Nested Channels Test . kt : 1 8 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . exceptions . StackTrace Recovery Nested Channels Test \$ test Offer With Current Context \$ 1 . invoke Suspend ( StackTrace Recovery Nested Channels Test . kt : 3 7 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" Cause d Ġby : Ġkotlinx . coroutines . Recover able Test Exception \ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . exceptions . StackTrace Recovery Nested Channels Test \$ test Offer With Current Context \$ 1 . invoke Suspend ( StackTrace Recovery Nested Channels Test . kt : 3 4 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlin . coroutines . jvm . internal . Base Continuation Impl . resume With ( Continuation Impl . kt : 3 2 )\ n ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Offer WithContext Wrapped () Ġ= Ġrun Test Ġ{ ĊĠĠĠĠĠĠĠ Ġchannel . close ( Recover able Test Exception ()) ĊĊĠĠĠĠĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsend WithContext ( wrapper Dispatcher ( coroutine Context )) ĊĠĠĠĠĠĠĠ Ġ} Ġcatch Ġ( e : ĠException ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify StackTrace ( e , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" kotlin x . coroutines . Recover able Test Exception \ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . exceptions . StackTrace Recovery Nested Channels Test \$ test Offer WithContext Wrapped \$ 1 . invoke Suspend ( StackTrace Recovery Nested Channels Test . kt : 5 9 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ t ( Coroutine Ġboundary )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . channels . Abstract Send Channel . offer ( Abstract Channel . kt : 1 8 0 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . channels . Abstract Send Channel . send ( Abstract Channel . kt : 1 6 8 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . exceptions . StackTrace Recovery Nested Channels Test . send In Channel ( StackTrace Recovery Nested Channels Test . kt : 2 4 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . exceptions . StackTrace Recovery Nested Channels Test \$ send WithContext \$ 2 . invoke Suspend ( StackTrace Recovery Nested Channels Test . kt : 1 9 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . exceptions . StackTrace Recovery Nested Channels Test \$ test Offer WithContext Wrapped \$ 1 . invoke Suspend ( StackTrace Recovery Nested Channels Test . kt : 6 2 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" Cause d Ġby : Ġkotlinx . coroutines . Recover able Test Exception \ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . exceptions . StackTrace Recovery Nested Channels Test \$ test Offer WithContext Wrapped \$ 1 . invoke Suspend ( StackTrace Recovery Nested Channels Test . kt : 5 9 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlin . coroutines . jvm . internal . Base Continuation Impl . resume With ( Continuation Impl . kt : 3 2 )") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Offer From Scope () Ġ= Ġrun Test Ġ{ ĊĠĠĠĠĠĠĠ Ġchannel . close ( Recover able Test Exception ()) ĊĊĠĠĠĠĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsend From Scope () ĊĠĠĠĠĠĠĠ Ġ} Ġcatch Ġ( e : ĠException ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify StackTrace ( e , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" kotlin x . coroutines . Recover able Test Exception \ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . exceptions . StackTrace Recovery Nested Channels Test \$ test Offer From Scope \$ 1 . invoke Suspend ( StackTrace Recovery Nested Channels Test . kt : 8 1 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ t ( Coroutine Ġboundary )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . channels . Abstract Send Channel . offer ( Abstract Channel . kt : 1 8 0 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . channels . Abstract Send Channel . send ( Abstract Channel . kt : 1 6 8 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . exceptions . StackTrace Recovery Nested Channels Test . send In Channel ( StackTrace Recovery Nested Channels Test . kt : 2 4 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . exceptions . StackTrace Recovery Nested Channels Test \$ send WithContext \$ 2 . invoke Suspend ( StackTrace Recovery Nested Channels Test . kt : 1 9 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . exceptions . StackTrace Recovery Nested Channels Test \$ send From Scope \$ 2 . invoke Suspend ( StackTrace Recovery Nested Channels Test . kt : 2 8 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . exceptions . StackTrace Recovery Nested Channels Test \$ test Offer From Scope \$ 1 . invoke Suspend ( StackTrace Recovery Nested Channels Test . kt : 8 4 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" Cause d Ġby : Ġkotlinx . coroutines . Recover able Test Exception \ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . exceptions . StackTrace Recovery Nested Channels Test \$ test Offer From Scope \$ 1 . invoke Suspend ( StackTrace Recovery Nested Channels Test . kt : 8 1 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlin . coroutines . jvm . internal . Base Continuation Impl . resume With ( Continuation Impl . kt : 3 2 )") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// ĠS low Ġpath Ġvia Ġsus pending Ġsend ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Send From Scope () Ġ= Ġrun Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdeferred Ġ= Ġasync Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġexpect ( 1 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġsend From Scope () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġcatch Ġ( e : ĠException ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġverify StackTrace ( e , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" kotlin x . coroutines . Recover able Test Exception \ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . exceptions . StackTrace Recovery Nested Channels Test \$ test Send From Scope \$ 1 . invoke Suspend ( StackTrace Recovery Nested Channels Test . kt : 1 1 8 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ t ( Coroutine Ġboundary )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . channels . Abstract Send Channel . offer ( Abstract Channel . kt : 1 8 0 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . channels . Abstract Send Channel . send ( Abstract Channel . kt : 1 6 8 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . exceptions . StackTrace Recovery Nested Channels Test . send In Channel ( StackTrace Recovery Nested Channels Test . kt : 2 4 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . exceptions . StackTrace Recovery Nested Channels Test \$ send WithContext \$ 2 . invoke Suspend ( StackTrace Recovery Nested Channels Test . kt : 1 9 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . exceptions . StackTrace Recovery Nested Channels Test \$ send From Scope \$ 2 . invoke Suspend ( StackTrace Recovery Nested Channels Test . kt : 2 9 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . exceptions . StackTrace Recovery Nested Channels Test \$ test Send From Scope \$ 1 \$ deferred \$ 1 . invoke Suspend ( StackTrace Recovery Nested Channels Test . kt : 1 0 9 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" Cause d Ġby : Ġkotlinx . coroutines . Recover able Test Exception \ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlinx . coroutines . exceptions . StackTrace Recovery Nested Channels Test \$ test Send From Scope \$ 1 . invoke Suspend ( StackTrace Recovery Nested Channels Test . kt : 1 1 8 )\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"\ tat Ġkotlin . coroutines . jvm . internal . Base Continuation Impl . resume With ( Continuation Impl . kt : 3 2 )") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġyield () ĊĠĠĠĠĠĠĠ Ġexpect ( 2 ) ĊĠĠĠĠĠĠĠ Ġ// ĠCancel Ġis Ġan Ġanalog ue Ġof Ġ` produce ` Ġfailure , Ġjust Ġa Ġsh orthand ĊĠĠĠĠĠĠĠ Ġchannel . cancel ( Recover able Test Exception ()) ĊĠĠĠĠĠĠĠ Ġfinish ( 3 ) ĊĠĠĠĠĠĠĠ Ġdeferred . await () ĊĠĠĠ Ġ} Ċ } Ċ