in test mode make sure the command queue is drained before service disposal (IDEA-340414)

GitOrigin-RevId: 52f85bce04eef57e742cbdf38de41e6e1219479c
This commit is contained in:
Eugene Zhuravlev
2024-02-19 13:44:15 +01:00
committed by intellij-monorepo-bot
parent 102cab878d
commit bc423766d1

View File

@@ -117,7 +117,8 @@ import org.jetbrains.jps.model.java.compiler.JavaCompilers;
import org.jvnet.winp.Priority;
import org.jvnet.winp.WinProcess;
import javax.tools.*;
import javax.tools.JavaCompiler;
import javax.tools.ToolProvider;
import java.awt.*;
import java.io.File;
import java.io.IOException;
@@ -1128,6 +1129,17 @@ public final class BuildManager implements Disposable {
public void dispose() {
stopListening();
myAutomakeTrigger.cancel();
if (IS_UNIT_TEST_MODE) {
// wait until command queue with already submitted tasks is drained
CountDownLatch latch = new CountDownLatch(1);
runCommand(() -> latch.countDown());
try {
latch.await();
}
catch (InterruptedException e) {
LOG.info(e);
}
}
myRequestsProcessor.cancel();
}