diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsKotlinCompilerRunner.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsKotlinCompilerRunner.kt index a049f3c31b7..aea4e742fd8 100644 --- a/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsKotlinCompilerRunner.kt +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsKotlinCompilerRunner.kt @@ -56,7 +56,14 @@ class JpsKotlinCompilerRunner : KotlinCompilerRunner() { @Synchronized private fun getOrCreateDaemonConnection(newConnection: ()-> CompileServiceSession?): CompileServiceSession? { - if (_jpsCompileServiceSession == null) { + // TODO: consider adding state "ping" to the daemon interface + if (_jpsCompileServiceSession == null || _jpsCompileServiceSession!!.compileService.getDaemonOptions() !is CompileService.CallResult.Good) { + _jpsCompileServiceSession?. let { + try { + it.compileService.releaseCompileSession(it.sessionId) + } + catch (_: Throwable) {} + } _jpsCompileServiceSession = newConnection() }