diff --git a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java index d385c671dae7..cdb2f77c0238 100644 --- a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java +++ b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java @@ -672,12 +672,13 @@ public class BuildManager implements Disposable { return null; } - final DelegateFuture _future = new DelegateFuture<>(); + final DelegateFuture _future = new DelegateFuture<>(); // by using the same queue that processes events we ensure that // the build will be aware of all events that have happened before this request runCommand(new Runnable() { @Override public void run() { + final Pair, OSProcessHandler> preloaded = takePreloadedProcess(projectPath); final RequestFuture preloadedFuture = preloaded != null? preloaded.first : null; final boolean usingPreloadedProcess = preloadedFuture != null; @@ -692,7 +693,8 @@ public class BuildManager implements Disposable { sessionId = UUID.randomUUID(); } - final RequestFuture future = usingPreloadedProcess? preloadedFuture : new RequestFuture(handler, sessionId, new CancelBuildSessionAction()); + final RequestFuture future = usingPreloadedProcess? preloadedFuture : new RequestFuture<>(handler, sessionId, new CancelBuildSessionAction()); + _future.setDelegate(future); if (!usingPreloadedProcess && (future.isCancelled() || project.isDisposed())) { // in case of preloaded process the process was already running, so the handler will be notified upon process termination @@ -739,7 +741,7 @@ public class BuildManager implements Disposable { } try { - Future buildFuture = projectTaskQueue.submit(new Runnable() { + projectTaskQueue.submit(new Runnable() { @Override public void run() { Throwable execFailure = null; @@ -776,7 +778,7 @@ public class BuildManager implements Disposable { } }); } - catch (Throwable e) { + catch(Throwable e) { LOG.info(e); } } @@ -841,9 +843,6 @@ public class BuildManager implements Disposable { } } }); - TaskFutureAdapter adapter = new TaskFutureAdapter<>(buildFuture); - boolean set = _future.setDelegate(adapter); - assert set; } catch (Throwable e) { handleProcessExecutionFailure(sessionId, e);