minor: replace Pair with data class in daemon client connectAndLease call
backport from 1.0.7
This commit is contained in:
+5
-4
@@ -50,6 +50,7 @@ object KotlinCompilerClient {
|
||||
|
||||
val verboseReporting = System.getProperty(COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY) != null
|
||||
|
||||
data class ServiceWithSession(val service: CompileService, val sessionId: Int)
|
||||
|
||||
fun connectToCompileService(compilerId: CompilerId,
|
||||
daemonJVMOptions: DaemonJVMOptions,
|
||||
@@ -81,7 +82,7 @@ object KotlinCompilerClient {
|
||||
reportingTargets,
|
||||
autostart,
|
||||
leaseSession = false,
|
||||
sessionAliveFlagFile = null)?.first
|
||||
sessionAliveFlagFile = null)?.service
|
||||
|
||||
|
||||
fun connectAndLease(compilerId: CompilerId,
|
||||
@@ -92,19 +93,19 @@ object KotlinCompilerClient {
|
||||
autostart: Boolean,
|
||||
leaseSession: Boolean,
|
||||
sessionAliveFlagFile: File? = null
|
||||
): Pair<CompileService, Int>? = connectLoop(reportingTargets) {
|
||||
): ServiceWithSession? = connectLoop(reportingTargets) {
|
||||
val (service, newJVMOptions) = tryFindSuitableDaemonOrNewOpts(File(daemonOptions.runFilesPath), compilerId, daemonJVMOptions, { cat, msg -> reportingTargets.report(cat, msg) })
|
||||
if (service != null) {
|
||||
// the newJVMOptions could be checked here for additional parameters, if needed
|
||||
service.registerClient(clientAliveFlagFile.absolutePath)
|
||||
reportingTargets.report(DaemonReportCategory.DEBUG, "connected to the daemon")
|
||||
if (!leaseSession) service to CompileService.NO_SESSION
|
||||
if (!leaseSession) ServiceWithSession(service, CompileService.NO_SESSION)
|
||||
else {
|
||||
val sessionId = service.leaseCompileSession(sessionAliveFlagFile?.absolutePath)
|
||||
if (sessionId is CompileService.CallResult.Dying)
|
||||
null
|
||||
else
|
||||
service to sessionId.get()
|
||||
ServiceWithSession(service, sessionId.get())
|
||||
}
|
||||
} else {
|
||||
reportingTargets.report(DaemonReportCategory.DEBUG, "no suitable daemon found")
|
||||
|
||||
@@ -425,13 +425,13 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
|
||||
val daemonWithSession = KotlinCompilerClient.connectAndLease(compilerId, flagFile, daemonJVMOptions, daemonOptions,
|
||||
DaemonReportingTargets(out = System.err), autostart = true,
|
||||
leaseSession = true, sessionAliveFlagFile = sessionFlagFile)
|
||||
if (daemonWithSession?.first == null) {
|
||||
if (daemonWithSession?.service == null) {
|
||||
fail("failed to connect daemon:\n${logFile.readLines().joinToString("\n")}\n------")
|
||||
}
|
||||
val jar = tmpdir.absolutePath + File.separator + "hello.$threadNo.jar"
|
||||
val res = KotlinCompilerClient.compile(
|
||||
daemonWithSession!!.first,
|
||||
daemonWithSession.second,
|
||||
daemonWithSession!!.service,
|
||||
daemonWithSession.sessionId,
|
||||
CompileService.TargetPlatform.JVM,
|
||||
arrayOf(File(getHelloAppBaseDir(), "hello.kt").absolutePath, "-d", jar),
|
||||
outStreams[threadNo])
|
||||
|
||||
+2
-2
@@ -191,7 +191,7 @@ class SourceSectionsTest : TestCaseWithTmpdir() {
|
||||
messageCollector.clear()
|
||||
val outputs = arrayListOf<OutputMessageUtil.Output>()
|
||||
|
||||
val code = KotlinCompilerClient.compile(daemonWithSession!!.first, daemonWithSession.second, CompileService.TargetPlatform.JVM,
|
||||
val code = KotlinCompilerClient.compile(daemonWithSession!!.service, daemonWithSession.sessionId, CompileService.TargetPlatform.JVM,
|
||||
args, messageCollector,
|
||||
{ outFile, srcFiles -> outputs.add(OutputMessageUtil.Output(srcFiles, outFile)) },
|
||||
reportSeverity = ReportSeverity.DEBUG)
|
||||
@@ -205,7 +205,7 @@ class SourceSectionsTest : TestCaseWithTmpdir() {
|
||||
}
|
||||
}
|
||||
finally {
|
||||
daemonWithSession!!.first.shutdown()
|
||||
daemonWithSession!!.service.shutdown()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user