From 1cd14f00eba17bef39b23cc3ac4c384fbc352311 Mon Sep 17 00:00:00 2001 From: Ilya Chernikov Date: Mon, 18 Dec 2017 11:32:15 +0100 Subject: [PATCH] Ignore connection error on the (optional) daemon.clearJarCache call May fix issues with NoSuchObjectException and UnmarshalException - the stacktraces often point to this place --- .../compilerRunner/GradleKotlinCompilerRunner.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/GradleKotlinCompilerRunner.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/GradleKotlinCompilerRunner.kt index 4b89a262c69..dfdc63a7899 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/GradleKotlinCompilerRunner.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/GradleKotlinCompilerRunner.kt @@ -37,6 +37,7 @@ import java.io.ByteArrayOutputStream import java.io.File import java.io.PrintStream import java.net.URLClassLoader +import java.rmi.RemoteException internal const val KOTLIN_COMPILER_EXECUTION_STRATEGY_PROPERTY = "kotlin.compiler.execution.strategy" internal const val DAEMON_EXECUTION_STRATEGY = "daemon" @@ -212,7 +213,14 @@ internal class GradleCompilerRunner(private val project: Project) : KotlinCompil null } // todo: can we clear cache on the end of session? - daemon.clearJarCache() + // often source of the NoSuchObjectException and UnmarshalException, probably caused by the failed/crashed/exited daemon + // TODO: implement a proper logic to avoid remote calls in such cases + try { + daemon.clearJarCache() + } + catch (e: RemoteException) { + log.warn("Unable to clear jar cache after compilation, maybe daemon is already down: $e") + } logFinish(DAEMON_EXECUTION_STRATEGY) return exitCode }