diff --git a/platform/core-impl/src/com/intellij/openapi/progress/impl/ProgressRunner.java b/platform/core-impl/src/com/intellij/openapi/progress/impl/ProgressRunner.java index 2169ce800fce..d398a05a651c 100644 --- a/platform/core-impl/src/com/intellij/openapi/progress/impl/ProgressRunner.java +++ b/platform/core-impl/src/com/intellij/openapi/progress/impl/ProgressRunner.java @@ -440,12 +440,12 @@ public final class ProgressRunner { @NotNull CompletableFuture progressIndicatorFuture ) { CompletableFuture resultFuture = new CompletableFuture<>(); - ChildContext childContextAndJob = Propagation.createChildContext(); - CoroutineContext childContext = childContextAndJob.getContext(); - CompletableJob childJob = childContextAndJob.getJob(); - if (childJob != null) { + ChildContext childContext = Propagation.createChildContext(); + CoroutineContext context = childContext.getContext(); + CompletableJob job = childContext.getJob(); + if (job != null) { // cancellation of the Job cancels the future - childJob.invokeOnCompletion(true, true, (throwable) -> { + job.invokeOnCompletion(true, true, (throwable) -> { if (throwable != null) { resultFuture.completeExceptionally(throwable); } @@ -458,11 +458,11 @@ public final class ProgressRunner { return; } Runnable runnable = new ProgressRunnable<>(resultFuture, task, progressIndicator); - Runnable contextRunnable = childContext.equals(EmptyCoroutineContext.INSTANCE) ? runnable : (ContextAwareRunnable)() -> { - CoroutineContext effectiveContext = childContext.plus(asContextElement(progressIndicator.getModalityState())); + Runnable contextRunnable = context.equals(EmptyCoroutineContext.INSTANCE) ? runnable : (ContextAwareRunnable)() -> { + CoroutineContext effectiveContext = context.plus(asContextElement(progressIndicator.getModalityState())); try (AccessToken ignored = ThreadContext.installThreadContext(effectiveContext, false)) { - if (childJob != null) { - Propagation.runAsCoroutine(childJob, runnable); + if (job != null) { + Propagation.runAsCoroutine(job, runnable); } else { runnable.run();