Warning "Inappropriate blocking method call" with coroutines, how to fix?

It’s not the compiler, but IDEA inspection.
Jetbrains is trying to make clever “guess” - if your method throws IOException, it should dispached on IO thread pool.

How to avoid warning:

  1. Remove @Throws, Kotlin don’t need it
  2. Suppress warning in IDEA with annotation @Suppress("BlockingMethodInNonBlockingContext")
  3. Tried, but not worked for me - create your own custom annotation for functions and add it to “non-blocking” list in inspection settings
1 Like