Hi, I am not getting how Exception propagation is ...
# coroutines
n
Hi, I am not getting how Exception propagation is happening. Here is a pseudo code and test
Copy code
fun populate(hotels: List<Hotel>) {
        
        val context = newFixedThreadPoolContext(threadpoolCoreSize, "thread-geo")

          context.use { c ->
                val jobs = hotels.map { hotel ->
                    launch(c) {
                        repo.suspendableFun()
                    }
                }
                runBlocking(c) {
                    jobs.forEach({ it.join() })
                }
            }
  }
and
Copy code
@Test(expectedExceptions = [RuntimeException::class])
    fun `populate should throw exceptionIn`() = runBlocking {
        //and
        given(repo.suspendableFun()).willThrow(RuntimeException(""))

        //when
        victim.populate(hotelList())

        //then
        //The exception is thrown
    }
i
Try to replace
suspendFun
with
suspendableFun
.
n
it’s the same, sorry
i was just simplifying the code to post here
i
Yes, I reproduced the problem. Will file the issue shortly. Thank you!
BTW, if I throw the exception in suspendableFun, without mocking it, the exception is propagated as expected.
n
oh, so it’s a genuine bug 🙂 I was thinking i am doing something wrong 🙂
@Ilmir Usmanov [JB] can you give me the ticket number once you’ve created it?
i
n
thanks @Ilmir Usmanov [JB]