From a0e38bc13a6f2be1dcaab88865fb187b454f7c41 Mon Sep 17 00:00:00 2001 From: Kostya Bats Date: Mon, 4 Nov 2024 14:40:01 +0300 Subject: [PATCH] pcms: fix possible issues with DataLoader.cached lateinit var --- .../ktor/src/main/kotlin/org/icpclive/cds/ktor/DataLoader.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cds/ktor/src/main/kotlin/org/icpclive/cds/ktor/DataLoader.kt b/src/cds/ktor/src/main/kotlin/org/icpclive/cds/ktor/DataLoader.kt index 3893479d..fffd2097 100644 --- a/src/cds/ktor/src/main/kotlin/org/icpclive/cds/ktor/DataLoader.kt +++ b/src/cds/ktor/src/main/kotlin/org/icpclive/cds/ktor/DataLoader.kt @@ -107,8 +107,8 @@ public fun DataLoader.cached(interval: Duration) = object : DataLoade lateinit var cache: T override suspend fun load(): T { if (nextLoad?.hasPassedNow() != false) { - nextLoad = TimeSource.Monotonic.markNow() + interval cache = this@cached.load() + nextLoad = TimeSource.Monotonic.markNow() + interval } else { logger(DataLoader::class.java).info { "Not loading because of cache"