mirror of https://github.com/sbt/sbt.git
[2.x] Fix potential division by zero in CacheEventLog.toSummary (#8635)
Add guard to prevent division by zero when calculating hitRate. If total is 0, hitRate is set to 0.0 instead of causing NaN or Infinity.
This commit is contained in:
parent
92b0564dc6
commit
cf8899919d
|
|
@ -71,7 +71,7 @@ class CacheEventLog:
|
|||
val hits = events.view.collect { case (ActionCacheEvent.Found(id), v) => (id, v) }.toMap
|
||||
val hitCount = hits.values.sum
|
||||
val missCount = total - hitCount
|
||||
val hitRate = (hitCount.toDouble / total.toDouble)
|
||||
val hitRate = if total > 0 then (hitCount.toDouble / total.toDouble) else 0.0
|
||||
val onsiteCount = events.get(ActionCacheEvent.OnsiteTask)
|
||||
val errorCount = events.get(ActionCacheEvent.Error)
|
||||
CacheEventSummary.Data(
|
||||
|
|
|
|||
Loading…
Reference in New Issue