Browse Source

HADOOP-5255. Fix use of Math.abs to avoid overflow. Contributed by Jonathan Ellis.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@746166 13f79535-47bb-0310-9956-ffa450edef68
Christopher Douglas 16 years ago
parent
commit
bb56687819
2 changed files with 4 additions and 1 deletions
  1. 3 0
      CHANGES.txt
  2. 1 1
      src/core/org/apache/hadoop/util/bloom/HashFunction.java

+ 3 - 0
CHANGES.txt

@@ -798,6 +798,9 @@ Release 0.20.0 - Unreleased
     HADOOP-4692. Namenode in infinite loop for replicating/deleting corrupt
     HADOOP-4692. Namenode in infinite loop for replicating/deleting corrupt
     blocks. (hairong)
     blocks. (hairong)
 
 
+    HADOOP-5255. Fix use of Math.abs to avoid overflow. (Jonathan Ellis via
+    cdouglas)
+
 Release 0.19.1 - Unreleased
 Release 0.19.1 - Unreleased
 
 
   IMPROVEMENTS
   IMPROVEMENTS

+ 1 - 1
src/core/org/apache/hadoop/util/bloom/HashFunction.java

@@ -112,7 +112,7 @@ public final class HashFunction {
       int[] result = new int[nbHash];
       int[] result = new int[nbHash];
       for (int i = 0, initval = 0; i < nbHash; i++) {
       for (int i = 0, initval = 0; i < nbHash; i++) {
 	  initval = hashFunction.hash(b, initval);
 	  initval = hashFunction.hash(b, initval);
-	  result[i] = Math.abs(initval) % maxValue;
+	  result[i] = Math.abs(initval % maxValue);
       }
       }
       return result;
       return result;
   }
   }