Skip to content

Commit

Permalink
Fix false positive in WorkQueue.addLast (#2968)
Browse files Browse the repository at this point in the history
Fixes #2937
  • Loading branch information
dkhalanskyjb committed Nov 16, 2021
1 parent 4b85eb6 commit e2a6827
Showing 1 changed file with 9 additions and 0 deletions.
Expand Up @@ -19,6 +19,7 @@ public class CoroutinesBlockHoundIntegration : BlockHoundIntegration {
allowServiceLoaderInvocationsOnInit()
allowBlockingCallsInReflectionImpl()
allowBlockingCallsInDebugProbes()
allowBlockingCallsInWorkQueue()
// Stacktrace recovery cache is guarded by lock
allowBlockingCallsInside("kotlinx.coroutines.internal.ExceptionsConstructorKt", "tryCopyException")
/* The predicates that define that BlockHound should only report blocking calls from threads that are part of
Expand Down Expand Up @@ -62,6 +63,14 @@ public class CoroutinesBlockHoundIntegration : BlockHoundIntegration {
}
}

/**
* Allow blocking calls inside [kotlinx.coroutines.scheduling.WorkQueue]
*/
private fun BlockHound.Builder.allowBlockingCallsInWorkQueue() {
/** uses [Thread.yield] in a benign way. */
allowBlockingCallsInside("kotlinx.coroutines.scheduling.WorkQueue", "addLast")
}

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

0 comments on commit e2a6827

Please sign in to comment.