Make getDaemonConnection synchronized to avoid racing conditions on connection

This commit is contained in:
Ilya Chernikov
2015-10-14 12:10:31 +02:00
parent 0209cd080e
commit 5b5ec2cb04
@@ -128,9 +128,9 @@ public object KotlinCompilerRunner {
internal class DaemonConnection(public val daemon: CompileService?)
internal object getDaemonConnection {
private var connection: DaemonConnection? = null
private @Volatile var connection: DaemonConnection? = null
operator fun invoke(environment: CompilerEnvironment, messageCollector: MessageCollector): DaemonConnection? {
@Synchronized operator fun invoke(environment: CompilerEnvironment, messageCollector: MessageCollector): DaemonConnection? {
if (connection == null) {
val libPath = CompilerRunnerUtil.getLibPath(environment.kotlinPaths, messageCollector)
val compilerId = CompilerId.makeCompilerId(File(libPath, "kotlin-compiler.jar"))