[platform] IJPL-158412: Do not fill stacktrace on cancellation of NonBlockingReadAction

GitOrigin-RevId: b415918b261915f230005e9c1cec5428156ec315
This commit is contained in:
Konstantin Nisht
2024-07-18 09:47:42 +02:00
committed by intellij-monorepo-bot
parent e5bd548bb2
commit 522b9404d5
2 changed files with 5 additions and 3 deletions

View File

@@ -329,7 +329,9 @@ public final class NonBlockingReadActionImpl<T> implements NonBlockingReadAction
// We need to abort the job only in the first case, but not in the second one.
// Because in the case of `setResult` there can be a UI callback, and we need to cancel Job strictly after the callback finishes.
if (!isSucceeded()) {
cancelJob(new CancellationException());
// we must not create CancellationException here,
// because filling the stacktrace causes performance degradation
cancelJob(null);
}
cleanupIfNeeded();
return result;

View File

@@ -727,7 +727,7 @@ class CancellationPropagationTest {
}
@RepeatedTest(1000)
fun `synchronous non-blocking read action is awaited`() = runBlocking {
fun `synchronous non-blocking read action is awaited`() = timeoutRunBlocking {
val dummyDisposable = Disposer.newDisposable()
var allowedToCompleteRA by AtomicReference(false)
val readActionCompletedSemaphore = Semaphore(1)
@@ -761,7 +761,7 @@ class CancellationPropagationTest {
.submit(executor)
}
Disposer.dispose(dummyDisposable)
// if NBRA is not properly canceled, we would have a leaking Job, and `blockingContextScope would never finish`
// if NBRA is not properly canceled, we would have a leaking Job, and `blockingContextScope` would never finish
job.join()
}