Make getDaemonConnection synchronized to avoid racing conditions on connection

Original commit: 5b5ec2cb04
This commit is contained in:
Ilya Chernikov
2015-10-14 12:10:31 +02:00
parent ba98b64776
commit a613d67074
@@ -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"))