mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-14 18:05:27 +07:00
IJPL-158517 ensure dumpCoroutines never throws
GitOrigin-RevId: e6217b2c4aa6c4ec1ec7f5f101a2d02e32356cce
This commit is contained in:
committed by
intellij-monorepo-bot
parent
6e41cff151
commit
d6190127db
@@ -48,16 +48,24 @@ fun enableCoroutineDump(): Result<Unit> {
|
||||
*/
|
||||
//@JvmOverloads
|
||||
fun dumpCoroutines(scope: CoroutineScope? = null, stripDump: Boolean = true, deduplicateTrees: Boolean = true): String? {
|
||||
if (!isCoroutineDumpEnabled()) {
|
||||
return null
|
||||
try {
|
||||
if (!isCoroutineDumpEnabled()) {
|
||||
return null
|
||||
}
|
||||
val charset = StandardCharsets.UTF_8.name()
|
||||
val outputStream = ByteArrayOutputStream()
|
||||
PrintStream(BufferedOutputStream(outputStream), true, charset).use { out ->
|
||||
val jobTree = jobTrees(scope).toList()
|
||||
dumpCoroutines(jobTree, out, stripDump, deduplicateTrees)
|
||||
}
|
||||
return outputStream.toString(charset)
|
||||
} catch (e: Throwable) {
|
||||
// if there is an unexpected exception, we won't be able to provide meaningful information anyway,
|
||||
// but the exception should not prevent other diagnostic tools from collecting data
|
||||
return "Coroutine dump has failed: ${e.message}\n" +
|
||||
"Please report this issue to the developers.\n" +
|
||||
e.stackTraceToString()
|
||||
}
|
||||
val charset = StandardCharsets.UTF_8.name()
|
||||
val outputStream = ByteArrayOutputStream()
|
||||
PrintStream(BufferedOutputStream(outputStream), true, charset).use { out ->
|
||||
val jobTree = jobTrees(scope).toList()
|
||||
dumpCoroutines(jobTree, out, stripDump, deduplicateTrees)
|
||||
}
|
||||
return outputStream.toString(charset)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user