An InterruptedException is caught and neither rethrown nor the thread's interrupt flag restored

tx0/kotlin:interrupt-status-lostrecommendedwarningreliability/concurrencydepth fastbug, concurrency

What it finds

Catching InterruptedException clears the interrupt flag of the thread. Code higher up that checks the flag to stop no longer sees the request. The usual handling is to throw again or to call Thread.currentThread().interrupt().

From the rule's source, interrupt_status_lost.rs.

Example from the rule's tests
fun pause(ms: Long) {    try {        Thread.sleep(ms)    } catch (e: InterruptedException) {tx0 reports: the interrupt request is dropped        log(e)    }    try {        Thread.sleep(ms)    } catch (e: InterruptedException) {        Thread.currentThread().interrupt()    }    try {        Thread.sleep(ms)    } catch (e: InterruptedException) {        throw IllegalStateException(e)    }}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/kotlin:interrupt-status-lost" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/kotlin:interrupt-status-lost] reason="..."

tx0 explain tx0/kotlin:interrupt-status-lost shows the same in the terminal. Found a false positive? Report it.