You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by sl...@apache.org on 2011/06/15 13:55:28 UTC
svn commit: r1136006 - in /cassandra/branches/cassandra-0.8: CHANGES.txt
src/java/org/apache/cassandra/utils/MerkleTree.java
Author: slebresne
Date: Wed Jun 15 11:55:28 2011
New Revision: 1136006
URL: http://svn.apache.org/viewvc?rev=1136006&view=rev
Log:
Avoids infinite loop when initializing a merkle tree
patch by slebresne; reviewed by stuhood for CASSANDRA-2758
Modified:
cassandra/branches/cassandra-0.8/CHANGES.txt
cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/utils/MerkleTree.java
Modified: cassandra/branches/cassandra-0.8/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/CHANGES.txt?rev=1136006&r1=1136005&r2=1136006&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.8/CHANGES.txt Wed Jun 15 11:55:28 2011
@@ -56,6 +56,7 @@
* fix ConcurrentModificationException in repair when dealing with 0.7 node
(CASSANDRA-2767)
* use threadsafe collections for StreamInSession (CASSANDRA-2766)
+ * avoid infinite loop when creating merkle tree (CASSANDRA-2758)
0.8.0-final
Modified: cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/utils/MerkleTree.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/utils/MerkleTree.java?rev=1136006&r1=1136005&r2=1136006&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/utils/MerkleTree.java (original)
+++ cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/utils/MerkleTree.java Wed Jun 15 11:55:28 2011
@@ -178,8 +178,11 @@ public class MerkleTree implements Seria
return new Leaf();
Token midpoint = partitioner.midpoint(left, right);
- Hashable lchild = midpoint.equals(left) ? new Leaf() : initHelper(left, midpoint, inc(depth), max);
- Hashable rchild = midpoint.equals(right) ? new Leaf() : initHelper(midpoint, right, inc(depth), max);
+ if (midpoint.equals(left) || midpoint.equals(right))
+ return new Leaf();
+
+ Hashable lchild = initHelper(left, midpoint, inc(depth), max);
+ Hashable rchild = initHelper(midpoint, right, inc(depth), max);
return new Inner(midpoint, lchild, rchild);
}