[jbosscache-commits] JBoss Cache SVN: r7377 - core/trunk/src/main/java/org/jboss/cache/util.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Mon Jan 5 12:29:33 EST 2009


Author: jason.greene at jboss.com
Date: 2009-01-05 12:29:33 -0500 (Mon, 05 Jan 2009)
New Revision: 7377

Modified:
   core/trunk/src/main/java/org/jboss/cache/util/FastCopyHashMap.java
Log:
Fix infinite loop condition on full table with get() and containsKey()

Modified: core/trunk/src/main/java/org/jboss/cache/util/FastCopyHashMap.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/FastCopyHashMap.java	2009-01-05 17:18:58 UTC (rev 7376)
+++ core/trunk/src/main/java/org/jboss/cache/util/FastCopyHashMap.java	2009-01-05 17:29:33 UTC (rev 7377)
@@ -203,7 +203,7 @@
       int length = table.length;
       int index = index(hash, length);
 
-      for (; ;)
+      for (int start = index; ;)
       {
          Entry<K, V> e = table[index];
          if (e == null)
@@ -213,6 +213,8 @@
             return e.value;
 
          index = nextIndex(index, length);
+         if (index == start) // Full table
+            return null;
       }
    }
 
@@ -224,7 +226,7 @@
       int length = table.length;
       int index = index(hash, length);
 
-      for (; ;)
+      for (int start = index; ;)
       {
          Entry<K, V> e = table[index];
          if (e == null)
@@ -234,6 +236,8 @@
             return true;
 
          index = nextIndex(index, length);
+         if (index == start) // Full table
+            return false;
       }
    }
 
@@ -253,11 +257,9 @@
       Entry<K, V>[] table = this.table;
       int hash = hash(key);
       int length = table.length;
-      int start = index(hash, length);
-      int index = start;
+      int index = index(hash, length);
 
-
-      for (; ;)
+      for (int start = index; ;)
       {
          Entry<K, V> e = table[index];
          if (e == null)




More information about the jbosscache-commits mailing list