franztesca
06/26/2022, 11:02 PMconflate
flow operator and throwables...
Basically, when throwing an exception from a flow
that passes through a conflated operator, the re-thrown exception is different from the original one.
It's reproducible with the following code:
@Test
fun myTest() = runBlocking {
val throwable = Throwable()
try {
flow<Unit> { throw throwable }.conflate().collect()
} catch (caught: Throwable) {
// We expect the same exception that we are throwing
assert(throwable === caught) { "Expected $throwable, found $caught" }
// Prints "Expected java.lang.Throwable, found java.lang.Throwable"
}
}
The same test without the .conflate
operator passes.
Can you confirm that what I expect is the actual intended behavior and therefore this is a bug?
I'm on :kotlin: 1.7.0
and coroutines 1.6.3
:thank-you: