Apache Lucene open-source search software
LUCENE-4162: Fix infinite loop on wrong argument in MathUtil.log
Uwe Schindlera2e8a95f6aed
diff --git a/lucene/core/src/java/org/apache/lucene/util/MathUtil.java b/lucene/core/src/java/org/apache/lucene/util/MathUtil.javaindex 46830c92195..9c8609995a9 100644--- a/lucene/core/src/java/org/apache/lucene/util/MathUtil.java+++ b/lucene/core/src/java/org/apache/lucene/util/MathUtil.java@@ -27,9 +27,14 @@ public final class MathUtil {private MathUtil() {}- /** returns x == 0 ? 0 : Math.floor(Math.log(x) / Math.log(base)) */+ /**+ * Returns {@code x <= 0 ? 0 : Math.floor(Math.log(x) / Math.log(base))}+ * @param base must be {@code > 1}+ */public static int log(long x, int base) {- assert base > 1;+ if (base <= 1) {+ throw new IllegalArgumentException("base must be > 1");+ }int ret = 0;while (x >= base) {x /= base;