File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
kotlinx-coroutines-core/common Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -394,6 +394,7 @@ private fun <T> Flow<T>.timeoutInternal(
394394 value.onSuccess {
395395 downStream.emit(it)
396396 }.onClosed {
397+ it?.let { throw it }
397398 return @onReceiveCatching false
398399 }
399400 return @onReceiveCatching true
Original file line number Diff line number Diff line change @@ -237,6 +237,17 @@ class TimeoutTest : TestBase() {
237237 testImmediateTimeout(- 1 .seconds)
238238 }
239239
240+ @Test
241+ fun testClosing () = runTest {
242+ assertFailsWith<TestException > {
243+ channelFlow<Int > { close(TestException ()) }
244+ .timeout(Duration .INFINITE )
245+ .collect {
246+ expectUnreached()
247+ }
248+ }
249+ }
250+
240251 private fun testImmediateTimeout (timeout : Duration ) {
241252 expect(1 )
242253 val flow = emptyFlow<Int >().timeout(timeout)
You can’t perform that action at this time.
0 commit comments