Skip to content

Commit d14afda

Browse files
committed
Do join weakRefCleanerThread in DebugProbes.uninstall
Otherwise, multiple pairs of install + uninstall may leave multiple cleanup threads in the state when the map is already cleaned up, but its size is not Fixes #3028
1 parent 4680014 commit d14afda

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

kotlinx-coroutines-core/jvm/src/debug/internal/ConcurrentWeakMap.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ internal class ConcurrentWeakMap<K : Any, V: Any>(
7373
while (true) {
7474
cleanWeakRef(weakRefQueue.remove() as HashedWeakRef<*>)
7575
}
76-
} catch(e: InterruptedException) {
76+
} catch (e: InterruptedException) {
7777
Thread.currentThread().interrupt()
7878
}
7979
}

kotlinx-coroutines-core/jvm/src/debug/internal/DebugProbesImpl.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,10 @@ internal object DebugProbesImpl {
102102
}
103103

104104
private fun stopWeakRefCleanerThread() {
105-
weakRefCleanerThread?.interrupt()
105+
val thread = weakRefCleanerThread ?: return
106106
weakRefCleanerThread = null
107+
thread.interrupt()
108+
thread.join()
107109
}
108110

109111
public fun hierarchyToString(job: Job): String = coroutineStateLock.write {

0 commit comments

Comments
 (0)