[infinispan-commits] Infinispan SVN: r1460 - in trunk/cachestore/cloud/src: test/java/org/infinispan/loaders/cloud and 1 other directory.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Fri Feb 5 17:15:15 EST 2010


Author: manik.surtani at jboss.com
Date: 2010-02-05 17:15:15 -0500 (Fri, 05 Feb 2010)
New Revision: 1460

Modified:
   trunk/cachestore/cloud/src/main/java/org/infinispan/loaders/cloud/CloudCacheStore.java
   trunk/cachestore/cloud/src/test/java/org/infinispan/loaders/cloud/CloudCacheStoreIntegrationTest.java
Log:
Fixed issue with negative hashcodes

Modified: trunk/cachestore/cloud/src/main/java/org/infinispan/loaders/cloud/CloudCacheStore.java
===================================================================
--- trunk/cachestore/cloud/src/main/java/org/infinispan/loaders/cloud/CloudCacheStore.java	2010-02-05 22:13:19 UTC (rev 1459)
+++ trunk/cachestore/cloud/src/main/java/org/infinispan/loaders/cloud/CloudCacheStore.java	2010-02-05 22:15:15 UTC (rev 1460)
@@ -165,7 +165,7 @@
 
    protected Bucket loadBucket(String hash) throws CacheLoaderException {
       try {
-         return readFromBlob(blobStore.getBlob(containerName, hash), hash);
+         return readFromBlob(blobStore.getBlob(containerName, getBucketName(hash)), hash);
       } catch (KeyNotFoundException e) {
          return null;
       }
@@ -266,7 +266,10 @@
    }
 
    private String getBucketName(Bucket bucket) {
-      String bucketName = bucket.getBucketName();
+      return getBucketName(bucket.getBucketName());
+   }
+
+   private String getBucketName(String bucketName) {
       if (bucketName.startsWith("-"))
          bucketName = bucketName.replace("-", "A");
       else if (bucketName.startsWith("A"))

Modified: trunk/cachestore/cloud/src/test/java/org/infinispan/loaders/cloud/CloudCacheStoreIntegrationTest.java
===================================================================
--- trunk/cachestore/cloud/src/test/java/org/infinispan/loaders/cloud/CloudCacheStoreIntegrationTest.java	2010-02-05 22:13:19 UTC (rev 1459)
+++ trunk/cachestore/cloud/src/test/java/org/infinispan/loaders/cloud/CloudCacheStoreIntegrationTest.java	2010-02-05 22:15:15 UTC (rev 1460)
@@ -29,7 +29,7 @@
 // TODO figure out why a disabled test is still run in Hudson!!
 public class CloudCacheStoreIntegrationTest{}
 
-//@Test(groups = "unit", sequential = true, testName = "loaders.cloud.CloudCacheStoreIntegrationTest", enabled = false)
+//@Test(groups = "unit", sequential = true, testName = "loaders.cloud.CloudCacheStoreIntegrationTest", enabled = true)
 //public class CloudCacheStoreIntegrationTest extends BaseCacheStoreTest {
 //
 //   private String proxyHost;
@@ -164,7 +164,32 @@
 //      assert expected.isEmpty();
 //   }
 //
+//   public void testNegativeHashCodes() throws CacheLoaderException {
+//      ObjectWithNegativeHashcode objectWithNegativeHashcode = new ObjectWithNegativeHashcode();
+//      cs.store(InternalEntryFactory.create(objectWithNegativeHashcode, "hello", -1, -1));
+//      InternalCacheEntry ice = cs.load(objectWithNegativeHashcode);
+//      assert ice.getKey().equals(objectWithNegativeHashcode);
+//      assert ice.getValue().equals("hello");
+//   }
 //
+//   private static class ObjectWithNegativeHashcode {
+//      String s = "hello";
+//
+//      @Override
+//      public boolean equals(Object o) {
+//         if (this == o) return true;
+//         if (o == null || getClass() != o.getClass()) return false;
+//
+//         ObjectWithNegativeHashcode blah = (ObjectWithNegativeHashcode) o;
+//         return !(s != null ? !s.equals(blah.s) : blah.s != null);
+//      }
+//
+//      @Override
+//      public int hashCode() {
+//         return -700;
+//      }
+//   }
+//
 //   @SuppressWarnings("unchecked")
 //   @Override
 //   public void testStreamingAPIReusingStreams() throws IOException, ClassNotFoundException, CacheLoaderException {



More information about the infinispan-commits mailing list