cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1036939 - in /cassandra/branches/cassandra-0.6: CHANGES.txt src/java/org/apache/cassandra/service/AntiEntropyService.java src/java/org/apache/cassandra/utils/FBUtilities.java
Date Fri, 19 Nov 2010 16:57:45 GMT
Author: jbellis
Date: Fri Nov 19 16:57:45 2010
New Revision: 1036939

URL: http://svn.apache.org/viewvc?rev=1036939&view=rev
Log:
Fix misuse of DataOutputBuffer.getData in AntiEntropyService
patch by Stu Hood; reviewed by jbellis for CASSANDRA-1729

Modified:
    cassandra/branches/cassandra-0.6/CHANGES.txt
    cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/AntiEntropyService.java
    cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/utils/FBUtilities.java

Modified: cassandra/branches/cassandra-0.6/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/CHANGES.txt?rev=1036939&r1=1036938&r2=1036939&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.6/CHANGES.txt Fri Nov 19 16:57:45 2010
@@ -4,7 +4,9 @@
  * reject range queries received during bootstrap (CASSANDRA-1739)
  * fix wrapping-range queries on non-minimum token (CASSANDRA-1700)
  * add nodetool cfhistogram (CASSANDRA-1698)
- * limit repaired ranges to what the nodes have in common (CASSAHDRA-1674)
+ * limit repaired ranges to what the nodes have in common (CASSANDRA-1674)
+ * Fix misuse of DataOutputBuffer.getData in AntiEntropyService
+   (CASSANDRA-1729)
 
 
 0.6.8

Modified: cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/AntiEntropyService.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/AntiEntropyService.java?rev=1036939&r1=1036938&r2=1036939&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/AntiEntropyService.java
(original)
+++ cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/AntiEntropyService.java
Fri Nov 19 16:57:45 2010
@@ -20,6 +20,7 @@ package org.apache.cassandra.service;
 
 import java.io.*;
 import java.net.InetAddress;
+import java.security.MessageDigest;
 import java.util.*;
 import java.util.concurrent.*;
 
@@ -361,8 +362,10 @@ public class AntiEntropyService
         {
             validated++;
             // MerkleTree uses XOR internally, so we want lots of output bits here
-            byte[] rowhash = FBUtilities.hash("SHA-256", row.key.key.getBytes(), row.buffer.getData());
-            return new MerkleTree.RowHash(row.key.token, rowhash);
+            MessageDigest messageDigest = FBUtilities.createDigest("SHA-256");
+            messageDigest.update(row.key.key.getBytes());
+            messageDigest.update(row.buffer.getData(), 0, row.buffer.getLength());
+            return new MerkleTree.RowHash(row.key.token, messageDigest.digest());
         }
 
         /**

Modified: cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/utils/FBUtilities.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/utils/FBUtilities.java?rev=1036939&r1=1036938&r2=1036939&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/utils/FBUtilities.java
(original)
+++ cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/utils/FBUtilities.java
Fri Nov 19 16:57:45 2010
@@ -233,22 +233,22 @@ public class FBUtilities
         return hash.abs();        
     }
 
-    public static byte[] hash(String type, byte[]... data)
+    public static byte[] hash(String type, byte[] data)
     {
-    	byte[] result = null;
-    	try
+        return createDigest(type).digest(data);
+    }
+
+    public static MessageDigest createDigest(String type)
+    {
+        try
         {
-            MessageDigest messageDigest = MessageDigest.getInstance(type);
-            for(byte[] block : data)
-                messageDigest.update(block);
-            result = messageDigest.digest();
-    	}
-    	catch (Exception e)
+            return MessageDigest.getInstance(type);
+        }
+        catch (Exception e)
         {
             throw new RuntimeException(e);
-    	}
-    	return result;
-	}
+        }
+    }
 
     // The given byte array is compressed onto the specified stream.
     // The method does not close the stream. The caller will have to do it.



Mime
View raw message