Problem: manually shutdown AppScheduledExecutorService to allow compiler stop properly
Without such shutdown console program that gets PSI file will hang forever. Introduced in https://github.com/JetBrains/intellij-community/commit/446b80077aed71e2384301ae993cf44416bf9a83 Stack example: java.lang.Thread.State: RUNNABLE at com.intellij.util.concurrency.AppDelayQueue.<init>(AppDelayQueue.java:37) at com.intellij.util.concurrency.AppScheduledExecutorService.<init>(AppScheduledExecutorService.java:50) at com.intellij.util.concurrency.AppScheduledExecutorService$Holder.<clinit>(AppScheduledExecutorService.java:41) at com.intellij.util.concurrency.AppScheduledExecutorService.getInstance(AppScheduledExecutorService.java:46) at com.intellij.util.concurrency.AppExecutorUtil.getAppScheduledExecutorService(AppExecutorUtil.java:39) at com.intellij.concurrency.JobScheduler.getScheduler(JobScheduler.java:43) at com.intellij.psi.impl.source.AstPathPsiMap.<clinit>(AstPathPsiMap.java:45) at com.intellij.psi.impl.source.PsiFileImpl.<init>(PsiFileImpl.java:76) at com.intellij.extapi.psi.PsiFileBase.<init>(PsiFileBase.java:39) at org.jetbrains.kotlin.psi.KtFile.<init>(KtFile.java:48) at org.jetbrains.kotlin.parsing.KotlinParserDefinition.createFile(KotlinParserDefinition.kt:73) at com.intellij.psi.SingleRootFileViewProvider.createFile(SingleRootFileViewProvider.java:407) at com.intellij.psi.SingleRootFileViewProvider.createFile(SingleRootFileViewProvider.java:348) at com.intellij.psi.SingleRootFileViewProvider.createFile(SingleRootFileViewProvider.java:326) at com.intellij.psi.SingleRootFileViewProvider.getPsiInner(SingleRootFileViewProvider.java:171) at com.intellij.psi.SingleRootFileViewProvider.getPsi(SingleRootFileViewProvider.java:155) at com.intellij.psi.impl.PsiFileFactoryImpl.trySetupPsiForFile(PsiFileFactoryImpl.java:121) at com.intellij.psi.impl.PsiFileFactoryImpl.createFileFromText(PsiFileFactoryImpl.java:100) at com.intellij.psi.impl.PsiFileFactoryImpl.createFileFromText(PsiFileFactoryImpl.java:56) at org.jetbrains.kotlin.psi.KtPsiFactory.doCreateFile(KtPsiFactory.kt:174) at org.jetbrains.kotlin.psi.KtPsiFactory.createFile(KtPsiFactory.kt:178) at org.jetbrains.kotlin.preprocessor.Preprocessor.processFileSingleEvaluator(Preprocessor.kt:82) at org.jetbrains.kotlin.preprocessor.Preprocessor.processDirectorySingleEvaluator(Preprocessor.kt:105) at org.jetbrains.kotlin.preprocessor.Preprocessor.processDirectorySingleEvaluator(Preprocessor.kt:135) at org.jetbrains.kotlin.preprocessor.Preprocessor.processSources(Preprocessor.kt:74) at org.jetbrains.kotlin.preprocessor.PreprocessorCLI.main(PreprocessorCLI.kt:35)
This commit is contained in:
@@ -20,6 +20,8 @@ import com.google.common.base.Predicates;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.util.concurrency.AppExecutorUtil;
|
||||
import com.intellij.util.concurrency.AppScheduledExecutorService;
|
||||
import com.sampullara.cli.Args;
|
||||
import kotlin.Pair;
|
||||
import kotlin.collections.ArraysKt;
|
||||
@@ -303,9 +305,16 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
||||
// We depend on swing (indirectly through PSI or something), so we want to declare headless mode,
|
||||
// to avoid accidentally starting the UI thread
|
||||
System.setProperty("java.awt.headless", "true");
|
||||
ExitCode exitCode = doMainNoExit(compiler, args);
|
||||
if (exitCode != OK) {
|
||||
System.exit(exitCode.getCode());
|
||||
try {
|
||||
ExitCode exitCode = doMainNoExit(compiler, args);
|
||||
|
||||
if (exitCode != OK) {
|
||||
System.exit(exitCode.getCode());
|
||||
}
|
||||
}
|
||||
finally {
|
||||
AppScheduledExecutorService service = (AppScheduledExecutorService) AppExecutorUtil.getAppScheduledExecutorService();
|
||||
service.shutdownAppScheduledExecutorService();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -95,6 +95,7 @@ import org.jetbrains.kotlin.script.*
|
||||
import org.jetbrains.kotlin.utils.PathUtil
|
||||
import org.jetbrains.kotlin.utils.ifEmpty
|
||||
import java.io.File
|
||||
import java.lang.IllegalStateException
|
||||
import java.util.*
|
||||
|
||||
class KotlinCoreEnvironment private constructor(
|
||||
|
||||
Reference in New Issue
Block a user