Working around cancellation-related exception in case of different versions of daemon and client
This commit is contained in:
+10
-1
@@ -16,8 +16,10 @@
|
||||
|
||||
package org.jetbrains.kotlin.daemon.client
|
||||
|
||||
import com.intellij.openapi.progress.ProcessCanceledException
|
||||
import org.jetbrains.kotlin.daemon.common.CompilerCallbackServicesFacade
|
||||
import org.jetbrains.kotlin.daemon.common.LoopbackNetworkInterface
|
||||
import org.jetbrains.kotlin.daemon.common.RmiFriendlyCompilationCancelledException
|
||||
import org.jetbrains.kotlin.daemon.common.SOCKET_ANY_FREE_PORT
|
||||
import org.jetbrains.kotlin.incremental.components.LookupInfo
|
||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
@@ -80,6 +82,13 @@ class CompilerCallbackServicesFacadeServer(
|
||||
override fun lookupTracker_isDoNothing(): Boolean = lookupTracker_isDoNothing
|
||||
|
||||
override fun compilationCanceledStatus_checkCanceled() {
|
||||
compilationCancelledStatus!!.checkCanceled()
|
||||
try {
|
||||
compilationCancelledStatus!!.checkCanceled()
|
||||
}
|
||||
catch (e: ProcessCanceledException) {
|
||||
// avoid passing exceptions that may have different serialVersionUID on across rmi border
|
||||
// TODO: doublecheck whether we need to distinguish different cancellation exceptions
|
||||
throw RmiFriendlyCompilationCancelledException()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-1
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.daemon.common
|
||||
import org.jetbrains.kotlin.incremental.components.LookupInfo
|
||||
import org.jetbrains.kotlin.load.kotlin.incremental.components.JvmPackagePartProto
|
||||
import org.jetbrains.kotlin.modules.TargetId
|
||||
import java.io.Serializable
|
||||
import java.rmi.Remote
|
||||
import java.rmi.RemoteException
|
||||
|
||||
@@ -81,7 +82,13 @@ interface CompilerCallbackServicesFacade : Remote {
|
||||
|
||||
// ----------------------------------------------------
|
||||
// CompilationCanceledStatus
|
||||
@Throws(RemoteException::class)
|
||||
@Throws(RemoteException::class, RmiFriendlyCompilationCancelledException::class)
|
||||
fun compilationCanceledStatus_checkCanceled(): Unit
|
||||
}
|
||||
|
||||
|
||||
class RmiFriendlyCompilationCancelledException: Exception(), Serializable {
|
||||
companion object {
|
||||
private val serialVersionUID: Long = 8228357578L // just a random number, but should never be changed to avoid deserialization problems
|
||||
}
|
||||
}
|
||||
+8
-1
@@ -20,6 +20,8 @@ import org.jetbrains.kotlin.progress.CompilationCanceledStatus
|
||||
import org.jetbrains.kotlin.daemon.common.CompilerCallbackServicesFacade
|
||||
import org.jetbrains.kotlin.daemon.common.DummyProfiler
|
||||
import org.jetbrains.kotlin.daemon.common.Profiler
|
||||
import org.jetbrains.kotlin.daemon.common.RmiFriendlyCompilationCancelledException
|
||||
import org.jetbrains.kotlin.progress.CompilationCanceledException
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
val CANCELED_STATUS_CHECK_THRESHOLD_NS = TimeUnit.MILLISECONDS.toNanos(100)
|
||||
@@ -30,7 +32,12 @@ class RemoteCompilationCanceledStatusClient(val facade: CompilerCallbackServices
|
||||
val curNanos = System.nanoTime()
|
||||
if (curNanos - lastChecked > CANCELED_STATUS_CHECK_THRESHOLD_NS) {
|
||||
profiler.withMeasure(this) {
|
||||
facade.compilationCanceledStatus_checkCanceled()
|
||||
try {
|
||||
facade.compilationCanceledStatus_checkCanceled()
|
||||
}
|
||||
catch (e: RmiFriendlyCompilationCancelledException) {
|
||||
throw CompilationCanceledException()
|
||||
}
|
||||
}
|
||||
lastChecked = curNanos
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user