From ebe41abf6b0252a4c87f2674cbdb4c57fad3cb72 Mon Sep 17 00:00:00 2001 From: Ivan Pavlov Date: Sun, 28 May 2023 04:51:27 +0700 Subject: [PATCH] fix #3648 added Ability to set DebugProbes.enableCreationStackTraces using system property --- kotlinx-coroutines-core/jvm/src/debug/AgentPremain.kt | 5 ----- .../jvm/src/debug/internal/DebugProbesImpl.kt | 4 +++- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/kotlinx-coroutines-core/jvm/src/debug/AgentPremain.kt b/kotlinx-coroutines-core/jvm/src/debug/AgentPremain.kt index fb5c5b1b06..85c6257dd6 100644 --- a/kotlinx-coroutines-core/jvm/src/debug/AgentPremain.kt +++ b/kotlinx-coroutines-core/jvm/src/debug/AgentPremain.kt @@ -21,16 +21,11 @@ import java.security.* @IgnoreJRERequirement // Never touched on Android internal object AgentPremain { - private val enableCreationStackTraces = runCatching { - System.getProperty("kotlinx.coroutines.debug.enable.creation.stack.trace")?.toBoolean() - }.getOrNull() ?: DebugProbesImpl.enableCreationStackTraces - @JvmStatic @Suppress("UNUSED_PARAMETER") fun premain(args: String?, instrumentation: Instrumentation) { AgentInstallationType.isInstalledStatically = true instrumentation.addTransformer(DebugProbesTransformer) - DebugProbesImpl.enableCreationStackTraces = enableCreationStackTraces DebugProbesImpl.install() installSignalHandler() } diff --git a/kotlinx-coroutines-core/jvm/src/debug/internal/DebugProbesImpl.kt b/kotlinx-coroutines-core/jvm/src/debug/internal/DebugProbesImpl.kt index a7432ef658..b0e3b54f6c 100644 --- a/kotlinx-coroutines-core/jvm/src/debug/internal/DebugProbesImpl.kt +++ b/kotlinx-coroutines-core/jvm/src/debug/internal/DebugProbesImpl.kt @@ -40,7 +40,9 @@ internal object DebugProbesImpl { private val sequenceNumber = atomic(0L) public var sanitizeStackTraces: Boolean = true - public var enableCreationStackTraces: Boolean = true + public var enableCreationStackTraces: Boolean = runCatching { + System.getProperty("kotlinx.coroutines.debug.enable.creation.stack.trace")?.toBoolean() + }.getOrNull() ?: true /* * Substitute for service loader, DI between core and debug modules.