Make daemon session retrieval more robust to the daemon failures

Original commit: f83dc0a067
This commit is contained in:
Ilya Chernikov
2017-12-18 12:34:11 +01:00
parent 76d6413702
commit c1da2e287d
@@ -56,7 +56,14 @@ class JpsKotlinCompilerRunner : KotlinCompilerRunner<JpsCompilerEnvironment>() {
@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<DaemonOptions>) {
_jpsCompileServiceSession?. let {
try {
it.compileService.releaseCompileSession(it.sessionId)
}
catch (_: Throwable) {}
}
_jpsCompileServiceSession = newConnection()
}