https://kotlinlang.org logo
#coroutines
Title
# coroutines
k

ken_kentan

06/09/2020, 9:00 AM
I'm planning to call method in suspend function that will throw IOException. In this case, IDE warn it as
Inappropriate blocking method call
. So, Should not I call method(will throw IOE) in suspend function?
Copy code
suspend fun foo() {
    // warning: Inappropriate blocking method call
    throwIoException()

    withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
        // warning: Inappropriate blocking method call
        throwIoException()
    }
}

@Throws(IOException::class)
fun throwIoException() {
    // something blocking process
}
o

octylFractal

06/09/2020, 9:03 AM
doing it in IO dispatcher is fine
really IntelliJ shouldn't be warning there (second time, first time is valid) , and just like in the other thread it works for me without a warning, but apparently some how this is different for you
k

ken_kentan

06/09/2020, 9:06 AM
I see. But, IDE still warn when wrap as
withContext(<http://Dispatchers.IO|Dispatchers.IO>)
. So you mean that IDE is wrong?
o

octylFractal

06/09/2020, 9:07 AM
yes
k

ken_kentan

06/09/2020, 9:08 AM
Is it (still warn in withContext) occurring just my environment only..?
o

octylFractal

06/09/2020, 9:10 AM
probably, I don't have my ide on hand right now but I have only seen the issue with flowOn, never withContext
k

ken_kentan

06/09/2020, 9:11 AM
I see... 🤔
e

EyeCon

06/09/2020, 1:07 PM
I have the same issue, see my response to the previous thread.
3 Views