[infinispan-commits] Infinispan SVN: r2444 - trunk/cachestore/cassandra/src/main/java/org/infinispan/loaders/cassandra.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Mon Sep 27 15:34:54 EDT 2010


Author: NadirX
Date: 2010-09-27 15:34:54 -0400 (Mon, 27 Sep 2010)
New Revision: 2444

Modified:
   trunk/cachestore/cassandra/src/main/java/org/infinispan/loaders/cassandra/CassandraCacheStore.java
Log:
If a key is found that doesn't match our entry pattern, ignore it
Make hash and unhash methods private

Modified: trunk/cachestore/cassandra/src/main/java/org/infinispan/loaders/cassandra/CassandraCacheStore.java
===================================================================
--- trunk/cachestore/cassandra/src/main/java/org/infinispan/loaders/cassandra/CassandraCacheStore.java	2010-09-27 16:39:21 UTC (rev 2443)
+++ trunk/cachestore/cassandra/src/main/java/org/infinispan/loaders/cassandra/CassandraCacheStore.java	2010-09-27 19:34:54 UTC (rev 2444)
@@ -147,6 +147,8 @@
 				// Cycle through all the keys
 				for (KeySlice keySlice : keySlices) {
 					String key = unhashKey(keySlice.getKey());
+					if(key==null) // Skip invalid keys
+						continue;
 					List<ColumnOrSuperColumn> columns = keySlice.getColumns();
 					if (columns.size() > 0) {
 						if (log.isDebugEnabled()) {
@@ -210,7 +212,7 @@
 				for (KeySlice keySlice : keySlices) {
 					if(keySlice.getColumnsSize()>0) {
 						String key = unhashKey(keySlice.getKey());
-						if (keysToExclude == null || !keysToExclude.contains(key))
+						if (key!=null && (keysToExclude == null || !keysToExclude.contains(key)))
 							s.add(key);
 					}
 				}
@@ -234,8 +236,6 @@
 
 	@Override
 	public void clear() throws CacheLoaderException {
-		if (trace)
-			log.trace("clear()");
 		Cassandra.Iface cassandraClient = null;
 		try {
 			cassandraClient = pool.getConnection();
@@ -458,12 +458,15 @@
 		return "CassandraCacheStore";
 	}
 
-	public static String hashKey(Object key) {
+	private static String hashKey(Object key) {
 		return ENTRY_KEY_PREFIX + key.toString();
 	}
 
-	public static String unhashKey(String key) {
-		return key.substring(ENTRY_KEY_PREFIX.length());
+	private static String unhashKey(String key) {
+		if(key.startsWith(ENTRY_KEY_PREFIX))
+			return key.substring(ENTRY_KEY_PREFIX.length());
+		else
+			return null;
 	}
 
 	private static void addMutation(Map<String, Map<String, List<Mutation>>> mutationMap, String key, String columnFamily, byte[] column, byte[] value) {



More information about the infinispan-commits mailing list