File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
model-client/src/jvmMain/kotlin/org/modelix/model/client Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -152,6 +152,7 @@ class RestWebModelClient @JvmOverloads constructor(
152
152
}
153
153
private var clientIdInternal: Int = 0
154
154
private val coroutineScope = CoroutineScope (Dispatchers .Default )
155
+ private var watchdogJob: Job ? = null
155
156
private val client = (providedClient ? : HttpClient (CIO )).config {
156
157
this .followRedirects = false
157
158
install(HttpTimeout ) {
@@ -264,7 +265,7 @@ class RestWebModelClient @JvmOverloads constructor(
264
265
private var connectionStatusListeners: Set <ConnectionStatusListener > = emptySet()
265
266
266
267
private fun startConnectionWatchdog () {
267
- coroutineScope.launch {
268
+ watchdogJob = coroutineScope.launch {
268
269
while (isActive) {
269
270
try {
270
271
connectNow()
@@ -274,7 +275,7 @@ class RestWebModelClient @JvmOverloads constructor(
274
275
delay(3 .seconds)
275
276
}
276
277
} catch (e: CancellationException ) {
277
- break
278
+ throw e
278
279
} catch (e: Exception ) {
279
280
LOG .debug(" " , e)
280
281
if (connectionStatus == ConnectionStatus .CONNECTED ) {
@@ -361,6 +362,7 @@ class RestWebModelClient @JvmOverloads constructor(
361
362
listeners.clear()
362
363
}
363
364
coroutineScope.cancel(" model client disposed" )
365
+ watchdogJob?.cancel(" model client disposed" )
364
366
}
365
367
366
368
override fun getPendingSize (): Int = pendingWrites.get()
You can’t perform that action at this time.
0 commit comments