Skip to content

Commit 494e023

Browse files
committed
Kotlin#316 Better way to set CoroutineContext#DEBUG value
- make `CoroutineContext#DEBUG_PROPERTY_NAME` public, also move `"on"`, `"off"`, `"auto"` to public constants as well
1 parent e1a5652 commit 494e023

File tree

1 file changed

+7
-4
lines changed
  • core/kotlinx-coroutines-core/src/main/kotlin/kotlinx/coroutines/experimental

1 file changed

+7
-4
lines changed

core/kotlinx-coroutines-core/src/main/kotlin/kotlinx/coroutines/experimental/CoroutineContext.kt

+7-4
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,18 @@ import kotlin.coroutines.experimental.AbstractCoroutineContextElement
2121
import kotlin.coroutines.experimental.ContinuationInterceptor
2222
import kotlin.coroutines.experimental.CoroutineContext
2323

24-
private const val DEBUG_PROPERTY_NAME = "kotlinx.coroutines.debug"
24+
const val DEBUG_PROPERTY_NAME = "kotlinx.coroutines.debug"
25+
const val DEBUG_PROPERTY_VALUE_AUTO = "auto"
26+
const val DEBUG_PROPERTY_VALUE_ON = "on"
27+
const val DEBUG_PROPERTY_VALUE_OFF = "off"
2528

2629
private val DEBUG = run {
2730
val value = try { System.getProperty(DEBUG_PROPERTY_NAME) }
2831
catch (e: SecurityException) { null }
2932
when (value) {
30-
"auto", null -> CoroutineId::class.java.desiredAssertionStatus()
31-
"on", "" -> true
32-
"off" -> false
33+
DEBUG_PROPERTY_VALUE_AUTO, null -> CoroutineId::class.java.desiredAssertionStatus()
34+
DEBUG_PROPERTY_VALUE_ON, "" -> true
35+
DEBUG_PROPERTY_VALUE_OFF -> false
3336
else -> error("System property '$DEBUG_PROPERTY_NAME' has unrecognized value '$value'")
3437
}
3538
}

0 commit comments

Comments
 (0)