mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 11:50:54 +07:00
[devkit debugger] Catch ObjectCollectedException and drop threads that were collected
GitOrigin-RevId: dabbe5bd6ab19c34d92bf2976e18c15374fca8d6
This commit is contained in:
committed by
intellij-monorepo-bot
parent
274e45004c
commit
531e3b1667
@@ -72,8 +72,9 @@ private class SessionThreadsData() {
|
||||
fun setNonCancellableSection(suspendContext: SuspendContextImpl) {
|
||||
try {
|
||||
if (!isPCEAdjustmentEnabled(suspendContext)) return
|
||||
val thread = suspendContext.thread ?: return
|
||||
val state = getOrCreateThreadState(suspendContext) ?: return
|
||||
state.setNonCancellable(suspendContext, true)
|
||||
setNonCancelableSafe(state, thread, suspendContext, true)
|
||||
}
|
||||
catch (e: Exception) {
|
||||
if (logIncorrectSuspendState(e)) return
|
||||
@@ -89,9 +90,9 @@ private class SessionThreadsData() {
|
||||
if (!isPCEAdjustmentEnabled(suspendContext)) return
|
||||
val pausedThreads = suspendContext.debugProcess.suspendManager.pausedContexts
|
||||
.mapNotNull { it.thread }
|
||||
.mapNotNull { threadStates[it] }
|
||||
for (state in pausedThreads) {
|
||||
state.setNonCancellable(suspendContext, false)
|
||||
for (thread in pausedThreads) {
|
||||
val state = threadStates[thread] ?: continue
|
||||
setNonCancelableSafe(state, thread, suspendContext, false)
|
||||
}
|
||||
}
|
||||
catch (e: Exception) {
|
||||
@@ -100,6 +101,18 @@ private class SessionThreadsData() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun setNonCancelableSafe(
|
||||
state: ThreadState, thread: ThreadReferenceProxyImpl,
|
||||
suspendContext: SuspendContextImpl, value: Boolean,
|
||||
) {
|
||||
try {
|
||||
state.setNonCancellable(suspendContext, value)
|
||||
}
|
||||
catch (_: ObjectCollectedException) {
|
||||
threadStates.remove(thread)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the [com.intellij.openapi.progress.Cancellation.DebugNonCancellableState] instance
|
||||
* bounded to the current thread.
|
||||
|
||||
Reference in New Issue
Block a user