withTimeout
with a long duration keeps the DefaultExecutor
thread alive for much longer than necessary
#4063
Labels
Describe the bug
What happened?
After
withTimeout
, theDefaultExecutor
thread will frequently stay around for the entire length of the timeout specified even if the actualwithTimeout
block finishes immediately. This seems to be ignoring the "keep alive" duration configured forDefaultExecutor
:kotlinx.coroutines/kotlinx-coroutines-core/jvm/src/DefaultExecutor.kt
Lines 32 to 39 in 60d2fe8
What should have happened instead?
The
DefaultExecutor
thread should only stay alive for at most one second after becoming idle according toDEFAULT_KEEP_ALIVE_MS
.Provide a Reproducer
Run this a bunch of times:
Sometimes the thread takes about one second to join as expected, but more often than not, it'll take 11 seconds instead. Seems to be the
Duration
given towithTimeout
plus one second (i.e., how long it was supposed to stay alive for) whenever that happens.The text was updated successfully, but these errors were encountered: