You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2012/06/21 18:49:46 UTC

svn commit: r1352613 - in /lucene/dev/branches/branch_4x: ./ lucene/ lucene/core/ lucene/core/src/java/org/apache/lucene/util/MathUtil.java

Author: uschindler
Date: Thu Jun 21 16:49:45 2012
New Revision: 1352613

URL: http://svn.apache.org/viewvc?rev=1352613&view=rev
Log:
Merged revision(s) 1352609 from lucene/dev/trunk:
LUCENE-4162: Fix infinite loop on wrong argument in MathUtil.log

Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/lucene/   (props changed)
    lucene/dev/branches/branch_4x/lucene/core/   (props changed)
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/MathUtil.java

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/MathUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/MathUtil.java?rev=1352613&r1=1352612&r2=1352613&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/MathUtil.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/MathUtil.java Thu Jun 21 16:49:45 2012
@@ -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;