gora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rher...@apache.org
Subject svn commit: r1455955 - in /gora/trunk: CHANGES.txt gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraClient.java gora-cassandra/src/main/java/org/apache/gora/cassandra/store/HectorUtils.java
Date Wed, 13 Mar 2013 14:28:35 GMT
Author: rherget
Date: Wed Mar 13 14:28:35 2013
New Revision: 1455955

URL: http://svn.apache.org/r1455955
Log:
GORA-211 thread safety: fix java.lang.NullPointerException - synchronize on mutator

Modified:
    gora/trunk/CHANGES.txt
    gora/trunk/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraClient.java
    gora/trunk/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/HectorUtils.java

Modified: gora/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/gora/trunk/CHANGES.txt?rev=1455955&r1=1455954&r2=1455955&view=diff
==============================================================================
--- gora/trunk/CHANGES.txt (original)
+++ gora/trunk/CHANGES.txt Wed Mar 13 14:28:35 2013
@@ -6,6 +6,8 @@ Gora Change Log
 
 trunk (current development)
 
+* GORA-211 thread safety: fix java.lang.NullPointerException - synchronize on mutator (rherget)
+
 * GORA-210 thread safety: fix java.util.ConcurrentModificationException (rherget)
 
 * GORA-190 Add "version" switch to bin/gora script (lewismc)

Modified: gora/trunk/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraClient.java
URL: http://svn.apache.org/viewvc/gora/trunk/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraClient.java?rev=1455955&r1=1455954&r2=1455955&view=diff
==============================================================================
--- gora/trunk/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraClient.java
(original)
+++ gora/trunk/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraClient.java
Wed Mar 13 14:28:35 2013
@@ -193,7 +193,9 @@ public class CassandraClient<K, T extend
       return;
     }
     
-    HectorUtils.insertColumn(mutator, key, columnFamily, columnName, byteBuffer);
+    synchronized(mutator) {
+      HectorUtils.insertColumn(mutator, key, columnFamily, columnName, byteBuffer);
+    }
   }
 
   /**
@@ -214,7 +216,9 @@ public class CassandraClient<K, T extend
     String columnFamily = this.cassandraMapping.getFamily(fieldName);
     String superColumnName = this.cassandraMapping.getColumn(fieldName);
     
-    HectorUtils.insertSubColumn(mutator, key, columnFamily, superColumnName, columnName,
byteBuffer);
+    synchronized(mutator) {
+      HectorUtils.insertSubColumn(mutator, key, columnFamily, superColumnName, columnName,
byteBuffer);
+    }
   }
 
   public void addSubColumn(K key, String fieldName, String columnName, Object value) {
@@ -238,7 +242,9 @@ public class CassandraClient<K, T extend
     String columnFamily = this.cassandraMapping.getFamily(fieldName);
     String superColumnName = this.cassandraMapping.getColumn(fieldName);
     
-    HectorUtils.deleteSubColumn(mutator, key, columnFamily, superColumnName, columnName);
+    synchronized(mutator) {
+      HectorUtils.deleteSubColumn(mutator, key, columnFamily, superColumnName, columnName);
+    }
   }
 
   public void deleteSubColumn(K key, String fieldName, String columnName) {

Modified: gora/trunk/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/HectorUtils.java
URL: http://svn.apache.org/viewvc/gora/trunk/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/HectorUtils.java?rev=1455955&r1=1455954&r2=1455955&view=diff
==============================================================================
--- gora/trunk/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/HectorUtils.java
(original)
+++ gora/trunk/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/HectorUtils.java
Wed Mar 13 14:28:35 2013
@@ -35,6 +35,11 @@ import org.apache.gora.persistency.Persi
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+/**
+ * This class it not thread safe.
+ * According to Hector's JavaDoc a Mutator isn't thread safe, too.
+ * Take a look at {@CassandraClient} for safe usage.
+ */
 public class HectorUtils<K,T extends Persistent> {
 
   public static final Logger LOG = LoggerFactory.getLogger(HectorUtils.class);



Mime
View raw message