Inspectopedia 2024.3 Help

RunBlocking in coroutine

Reports runBlocking builders that can be reached from coroutines.

Coroutines share threads for execution. When a runBlocking builder is called from a coroutine it blocks the underlying thread and prevents other coroutines from using this resource. This can result in performance issues and in bad cases thread starvation.

It provides a potential callstack from coroutine primitive (suspend function or builder) to runBlocking builder.

Example:

suspend fun main() { foo() } fun foo() { runBlocking { suspendFunction() } }

Potential solution:

suspend fun main() { foo() } suspend fun foo() { suspendFunction() }

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

RunBlocking
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | Kotlin | Coroutine inspections

Use the explore functions with overrides option to configure analysis for virtual functions:

  • Use the No option to skip analysis for a function with overrides.

  • Use the Yes, excluding overrides option to only explore the function in the defined callee type.

  • Use the Yes, including overrides option to explore the function and all overrides.

Inspection options

Here you can find the description of settings available for the RunBlocking in coroutine inspection, and the reference of their default values.

Explore functions with overrides

Default setting: Yes, excluding overrides

Other available settings:

  • No

  • Yes, including overrides

Inspection Details

By default bundled with:

IntelliJ IDEA 2024.3, Qodana for JVM 2024.3,

Can be installed with plugin:

Kotlin, 243.23126-IJ

Last modified: 03 December 2024