Skip to content

Commit

Permalink
JT-78303: Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimir-zatsepin committed Jan 16, 2024
1 parent bc5264c commit f232207
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class CaffeinePersistentCache<K, V> 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
}
}
Expand Down

0 comments on commit f232207

Please sign in to comment.