Skip to content

Commit 9cfe8bb

Browse files
author
Oleksandr Dzhychko
committed
fix(model-client): rethrow CancellationException
CancellationException is a special exception that is expected when the coroutines scope is cancelled.
1 parent 08c61aa commit 9cfe8bb

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

model-client/src/commonMain/kotlin/org/modelix/model/client2/ReplicatedModel.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import org.modelix.model.lazy.CLTree
1717
import org.modelix.model.lazy.CLVersion
1818
import org.modelix.model.operations.OTBranch
1919
import org.modelix.model.server.api.ModelQuery
20+
import kotlin.coroutines.cancellation.CancellationException
2021

2122
class ReplicatedModel(val client: IModelClientV2, val branchRef: BranchReference, val query: ModelQuery? = null) {
2223
private val scope = CoroutineScope(Dispatchers.Default)
@@ -62,6 +63,9 @@ class ReplicatedModel(val client: IModelClientV2, val branchRef: BranchReference
6263
} as CLVersion
6364
remoteVersionReceived(newRemoteVersion)
6465
nextDelayMs = 0
66+
} catch (ex: CancellationException) {
67+
LOG.debug { "Stop to poll branch $branchRef after disposing." }
68+
throw ex
6569
} catch (ex: Throwable) {
6670
LOG.error(ex) { "Failed to poll branch $branchRef" }
6771
nextDelayMs = (nextDelayMs * 3 / 2).coerceIn(1000, 30000)

0 commit comments

Comments
 (0)