Skip to content

Commit 3b23c49

Browse files
committed
Cancel and join monitor job
1 parent 6ef2a48 commit 3b23c49

File tree

1 file changed

+4
-1
lines changed
  • runtime/protocol/http-client-engines/http-client-engine-okhttp/jvm/src/aws/smithy/kotlin/runtime/http/engine/okhttp

1 file changed

+4
-1
lines changed

runtime/protocol/http-client-engines/http-client-engine-okhttp/jvm/src/aws/smithy/kotlin/runtime/http/engine/okhttp/ConnectionIdleMonitor.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ internal class ConnectionIdleMonitor(val pollInterval: Duration) : ConnectionLis
2828
private val monitors = ConcurrentHashMap<Connection, Job>()
2929

3030
fun close(): Unit = runBlocking {
31-
monitors.values.forEach { it.cancelAndJoin() }
31+
val monitorJob = requireNotNull(monitorScope.coroutineContext[Job]) {
32+
"Connection idle monitor scope cannot be cancelled because it does not have a job: $this"
33+
}
34+
monitorJob.cancelAndJoin()
3235
}
3336

3437
private fun Call.callContext() =

0 commit comments

Comments
 (0)