From b2a4b74f9e70eb3209ad0f736052ea02c113fcad Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Sun, 17 Jan 2021 14:43:23 -0500 Subject: Fix a bug upon early server startup in which percentiles would throw an out of bounds exception (#92) --- .../src/main/java/me/lucko/spark/common/util/RollingAverage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spark-common/src/main/java/me/lucko/spark') diff --git a/spark-common/src/main/java/me/lucko/spark/common/util/RollingAverage.java b/spark-common/src/main/java/me/lucko/spark/common/util/RollingAverage.java index 1e5e8b2..aa56f26 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/util/RollingAverage.java +++ b/spark-common/src/main/java/me/lucko/spark/common/util/RollingAverage.java @@ -99,7 +99,7 @@ public class RollingAverage { } sortedSamples.sort(null); - int rank = (int) Math.ceil((percentile / 100d) * sortedSamples.size()); + int rank = (int) Math.ceil((percentile / 100d) * (sortedSamples.size() - 1)); return sortedSamples.get(rank).doubleValue(); } -- cgit