@@ -25,6 +25,7 @@ import kotlinx.coroutines.isActive
2525import kotlinx.coroutines.selects.onTimeout
2626import kotlinx.coroutines.selects.select
2727import java.io.IOException
28+import kotlin.random.Random
2829
2930/**
3031 * Owns the single long-lived `GET /event` SSE subscription and exposes it as a hot
@@ -131,7 +132,7 @@ class EventStreamClient(
131132 if (!isActive) break
132133 // Wait for the backoff, but allow a reconnect signal to cut it short.
133134 var signaled = false
134− val jitter = (backoffMs * 0.2 * Math.random()).toLong()
135+ val jitter = (backoffMs * 0.2 * Random.nextDouble()).toLong()
135136 select {
136137 reconnectSignal.onReceive { signaled = true }
137138 onTimeout(backoffMs + jitter) { /* normal backoff elapsed */ }