Skip to content

Commit

Permalink
Use abs instead of Math.abs to avoid issue when hash returns Integer.…
Browse files Browse the repository at this point in the history
…MIN_VALUE.
  • Loading branch information
ijuma committed Feb 3, 2010
1 parent 4ade916 commit 0dfb70b
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/java/voldemort/routing/ConsistentRoutingStrategy.java
Expand Up @@ -80,7 +80,6 @@ public ConsistentRoutingStrategy(HashFunction hash, Collection<Node> nodes, int
* Math.abs returns Integer.MIN_VALUE if a == Integer.MIN_VALUE and this
* method returns Integer.MAX_VALUE in that case.
*/
@SuppressWarnings("unused")
private static int abs(int a) {
if(a >= 0)
return a;
Expand Down Expand Up @@ -149,7 +148,7 @@ Set<Integer> getPartitionsByNode(Node n) {
}

public List<Integer> getPartitionList(byte[] key) {
int index = Math.abs(hash.hash(key)) % (Math.max(1, this.partitionToNode.length));
int index = abs(hash.hash(key)) % (Math.max(1, this.partitionToNode.length));
return getReplicatingPartitionList(index);
}
}

0 comments on commit 0dfb70b

Please sign in to comment.