IDEA-371736 DebuggerManagerThreadImpl.startLongProcessAndFork throws ObjectCollectedException

GitOrigin-RevId: 29c88437f2c1464561c6f4554cc415af06f2763a
This commit is contained in:
Egor Ushakov
2025-04-28 16:17:31 +00:00
committed by intellij-monorepo-bot
parent 25271b21be
commit b621704a81
@@ -357,21 +357,33 @@ public final class DebuggerUtilsImpl extends DebuggerUtilsEx {
}
catch (ObjectCollectedException oce) {
if (--retries < 0) {
LOG.error("Retries exhausted, apply suspend-all evaluation");
if (evaluationContext.getSuspendContext() instanceof SuspendContextImpl suspendContextImpl) {
VirtualMachineProxyImpl virtualMachineProxy = suspendContextImpl.getVirtualMachineProxy();
virtualMachineProxy.suspend();
try {
return processor.apply(valueComputable.compute());
} finally {
virtualMachineProxy.resume();
}
}
else {
throw oce;
}
return suspendAllAndEvaluate(valueComputable, processor, evaluationContext);
}
}
catch (EvaluateException e) {
if (e.getCause() instanceof ObjectCollectedException) {
if (--retries < 0) {
return suspendAllAndEvaluate(valueComputable, processor, evaluationContext);
}
}
else {
throw e;
}
}
}
}
private static <R, T> R suspendAllAndEvaluate(@NotNull ThrowableComputable<? extends T, ? extends EvaluateException> valueComputable,
@NotNull Function<? super T, ? extends R> processor,
@NotNull EvaluationContext evaluationContext) throws EvaluateException {
LOG.error("Retries exhausted, applying suspend-all evaluation");
VirtualMachineProxyImpl virtualMachineProxy = ((EvaluationContextImpl)evaluationContext).getSuspendContext().getVirtualMachineProxy();
virtualMachineProxy.suspend();
try {
return processor.apply(valueComputable.compute());
}
finally {
virtualMachineProxy.resume();
}
}