Skip to content

Fix a test that was flaky because of BlockHound #2572

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions kotlinx-coroutines-debug/src/CoroutinesBlockHoundIntegration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class CoroutinesBlockHoundIntegration : BlockHoundIntegration {
allowBlockingWhenEnqueuingTasks()
allowServiceLoaderInvocationsOnInit()
allowBlockingCallsInReflectionImpl()
allowBlockingCallsInDebugProbes()
/* The predicates that define that BlockHound should only report blocking calls from threads that are part of
the coroutine thread pool and currently execute a CPU-bound coroutine computation. */
addDynamicThreadPredicate { isSchedulerWorker(it) }
Expand Down Expand Up @@ -48,6 +49,17 @@ public class CoroutinesBlockHoundIntegration : BlockHoundIntegration {
}
}

/**
* Allow blocking calls inside [kotlinx.coroutines.debug.internal.DebugProbesImpl].
*/
private fun BlockHound.Builder.allowBlockingCallsInDebugProbes() {
for (method in listOf("install", "uninstall", "hierarchyToString", "dumpCoroutinesInfo", "dumpDebuggerInfo",
"dumpCoroutinesSynchronized", "updateRunningState", "updateState"))
{
allowBlockingCallsInside("kotlinx.coroutines.debug.internal.DebugProbesImpl", method)
}
}

/**
* Allows blocking inside [kotlinx.coroutines.internal.ThreadSafeHeap].
*/
Expand Down