From f2322072c3d1c4cee17af7b17d9dc23e4e221bd7 Mon Sep 17 00:00:00 2001 From: Vladimir Zatsepin Date: Wed, 17 Jan 2024 00:55:32 +0400 Subject: [PATCH] JT-78303: Fix test --- .../jetbrains/exodus/core/cache/CaffeinePersistentCache.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/src/main/kotlin/jetbrains/exodus/core/cache/CaffeinePersistentCache.kt b/utils/src/main/kotlin/jetbrains/exodus/core/cache/CaffeinePersistentCache.kt index 778064d1f..4bfbe81e6 100644 --- a/utils/src/main/kotlin/jetbrains/exodus/core/cache/CaffeinePersistentCache.kt +++ b/utils/src/main/kotlin/jetbrains/exodus/core/cache/CaffeinePersistentCache.kt @@ -51,7 +51,7 @@ class CaffeinePersistentCache private constructor( fun put(version: Version, value: V) { map.compute(version) { _, prevValue -> val toSubtract = prevValue?.let(weigher) ?: 0 - totalWeightRef.updateAndGet { it + weigher(value) - toSubtract } + totalWeightRef.updateAndGet { (it + weigher(value) - toSubtract).coerceAtLeast(0) } value } }