Skip to content

Commit

Permalink
Revert "BlockHound integration (#1821)"
Browse files Browse the repository at this point in the history
This reverts commit ed7c668.
  • Loading branch information
qwwdfsad committed Mar 17, 2020
1 parent 6802f7b commit aa86ff3
Show file tree
Hide file tree
Showing 21 changed files with 65 additions and 276 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Expand Up @@ -8,8 +8,8 @@ apply from: rootProject.file("gradle/experimental.gradle")
def rootModule = "kotlinx.coroutines"
def coreModule = "kotlinx-coroutines-core"
// Not applicable for Kotlin plugin
def sourceless = ['kotlinx.coroutines', 'site', 'kotlinx-coroutines-bom', 'integration-testing']
def internal = ['kotlinx.coroutines', 'site', 'benchmarks', 'js-stub', 'stdlib-stubs', 'integration-testing']
def sourceless = ['kotlinx.coroutines', 'site', 'kotlinx-coroutines-bom', 'publication-validator']
def internal = ['kotlinx.coroutines', 'site', 'benchmarks', 'js-stub', 'stdlib-stubs', 'publication-validator']
// Not published
def unpublished = internal + ['example-frontend-js', 'android-unit-tests']

Expand Down
4 changes: 1 addition & 3 deletions gradle.properties
Expand Up @@ -14,15 +14,13 @@ knit_version=0.1.3
html_version=0.6.8
lincheck_version=2.5.3
dokka_version=0.9.16-rdev-2-mpp-hacks
byte_buddy_version=1.10.7
byte_buddy_version=1.9.3
reactor_vesion=3.2.5.RELEASE
reactive_streams_version=1.0.2
rxjava2_version=2.2.8
javafx_version=11.0.2
javafx_plugin_version=0.0.8
binary_compatibility_validator_version=0.2.2
blockhound_version=1.0.2.RELEASE
jna_version=5.5.0

# Android versions
android_version=4.1.1.4
Expand Down
14 changes: 0 additions & 14 deletions integration-testing/README.md

This file was deleted.

77 changes: 0 additions & 77 deletions integration-testing/build.gradle

This file was deleted.

20 changes: 0 additions & 20 deletions integration-testing/src/debugAgentTest/kotlin/DebugAgentTest.kt

This file was deleted.

17 changes: 0 additions & 17 deletions kotlinx-coroutines-core/jvm/src/scheduling/CoroutineScheduler.kt
Expand Up @@ -951,20 +951,3 @@ internal class CoroutineScheduler(
TERMINATED
}
}

/**
* Checks if the thread is part of a thread pool that supports coroutines.
* This function is needed for integration with BlockHound.
*/
@Suppress("UNUSED")
@JvmName("isSchedulerWorker")
internal fun isSchedulerWorker(thread: Thread) = thread is CoroutineScheduler.Worker

/**
* Checks if the thread is running a CPU-bound task.
* This function is needed for integration with BlockHound.
*/
@Suppress("UNUSED")
@JvmName("mayNotBlock")
internal fun mayNotBlock(thread: Thread) = thread is CoroutineScheduler.Worker &&
thread.state == CoroutineScheduler.WorkerState.CPU_ACQUIRED
5 changes: 0 additions & 5 deletions kotlinx-coroutines-debug/README.md
Expand Up @@ -13,11 +13,6 @@ suspension stacktraces.
Additionally, it is possible to process the list of such coroutines via [DebugProbes.dumpCoroutinesInfo] or dump isolated parts
of coroutines hierarchy referenced by a [Job] or [CoroutineScope] instances using [DebugProbes.printJob] and [DebugProbes.printScope] respectively.

This module also provides an automatic [BlockHound](https://github.com/reactor/BlockHound) integration
that detects when a blocking operation was called in a coroutine context that prohibits it. In order to use it,
please follow the BlockHound [quick start guide](
https://github.com/reactor/BlockHound/blob/1.0.2.RELEASE/docs/quick_start.md).

### Using in your project

Add `kotlinx-coroutines-debug` to your project test dependencies:
Expand Down
5 changes: 0 additions & 5 deletions kotlinx-coroutines-debug/api/kotlinx-coroutines-debug.api
Expand Up @@ -8,11 +8,6 @@ public final class kotlinx/coroutines/debug/CoroutineInfo {
public fun toString ()Ljava/lang/String;
}

public final class kotlinx/coroutines/debug/CoroutinesBlockHoundIntegration : reactor/blockhound/integration/BlockHoundIntegration {
public fun <init> ()V
public fun applyTo (Lreactor/blockhound/BlockHound$Builder;)V
}

public final class kotlinx/coroutines/debug/DebugProbes {
public static final field INSTANCE Lkotlinx/coroutines/debug/DebugProbes;
public final fun dumpCoroutines (Ljava/io/PrintStream;)V
Expand Down
6 changes: 1 addition & 5 deletions kotlinx-coroutines-debug/build.gradle
Expand Up @@ -22,10 +22,6 @@ dependencies {
compileOnly "junit:junit:$junit_version"
shadowDeps "net.bytebuddy:byte-buddy:$byte_buddy_version"
shadowDeps "net.bytebuddy:byte-buddy-agent:$byte_buddy_version"
compileOnly "io.projectreactor.tools:blockhound:$blockhound_version"
testCompile "io.projectreactor.tools:blockhound:$blockhound_version"
runtime "net.java.dev.jna:jna:$jna_version"
runtime "net.java.dev.jna:jna-platform:$jna_version"
}

jar {
Expand All @@ -39,5 +35,5 @@ shadowJar {
classifier null
// Shadow only byte buddy, do not package kotlin stdlib
configurations = [project.configurations.shadowDeps]
relocate('net.bytebuddy', 'kotlinx.coroutines.repackaged.net.bytebuddy')
relocate 'net.bytebuddy', 'kotlinx.coroutines.repackaged.net.bytebuddy'
}

This file was deleted.

16 changes: 0 additions & 16 deletions kotlinx-coroutines-debug/src/CoroutinesBlockHoundIntegration.kt

This file was deleted.

2 changes: 1 addition & 1 deletion kotlinx-coroutines-debug/src/internal/DebugProbesImpl.kt
Expand Up @@ -57,7 +57,7 @@ internal object DebugProbesImpl {
public fun install(): Unit = coroutineStateLock.write {
if (++installations > 1) return

ByteBuddyAgent.install(ByteBuddyAgent.AttachmentProvider.ForEmulatedAttachment.INSTANCE)
ByteBuddyAgent.install()
val cl = Class.forName("kotlin.coroutines.jvm.internal.DebugProbesKt")
val cl2 = Class.forName("kotlinx.coroutines.debug.DebugProbesKt")

Expand Down
73 changes: 0 additions & 73 deletions kotlinx-coroutines-debug/test/BlockHoundTest.kt

This file was deleted.

13 changes: 5 additions & 8 deletions kotlinx-coroutines-debug/test/CoroutinesDumpTest.kt
Expand Up @@ -39,7 +39,7 @@ class CoroutinesDumpTest : DebugTestBase() {

@Test
fun testRunningCoroutine() = runBlocking {
val deferred = async(Dispatchers.IO) {
val deferred = async(Dispatchers.Default) {
activeMethod(shouldSuspend = false)
assertTrue(true)
}
Expand Down Expand Up @@ -70,7 +70,7 @@ class CoroutinesDumpTest : DebugTestBase() {

@Test
fun testRunningCoroutineWithSuspensionPoint() = runBlocking {
val deferred = async(Dispatchers.IO) {
val deferred = async(Dispatchers.Default) {
activeMethod(shouldSuspend = true)
yield() // tail-call
}
Expand Down Expand Up @@ -100,7 +100,7 @@ class CoroutinesDumpTest : DebugTestBase() {

@Test
fun testCreationStackTrace() = runBlocking {
val deferred = async(Dispatchers.IO) {
val deferred = async(Dispatchers.Default) {
activeMethod(shouldSuspend = true)
}

Expand Down Expand Up @@ -129,7 +129,7 @@ class CoroutinesDumpTest : DebugTestBase() {

@Test
fun testFinishedCoroutineRemoved() = runBlocking {
val deferred = async(Dispatchers.IO) {
val deferred = async(Dispatchers.Default) {
activeMethod(shouldSuspend = true)
}

Expand All @@ -149,10 +149,7 @@ class CoroutinesDumpTest : DebugTestBase() {
if (shouldSuspend) yield()
notifyCoroutineStarted()
while (coroutineContext[Job]!!.isActive) {
try {
Thread.sleep(60_000)
} catch (_ : InterruptedException) {
}
runCatching { Thread.sleep(60_000) }
}
}

Expand Down
Expand Up @@ -133,7 +133,7 @@ class RunningThreadStackMergeTest : DebugTestBase() {
}

private fun CoroutineScope.launchEscapingCoroutineWithoutContext() {
launch(Dispatchers.IO) {
launch(Dispatchers.Default) {
suspendingFunctionWithoutContext()
assertTrue(true)
}
Expand Down

0 comments on commit aa86ff3

Please sign in to comment.