harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r773884 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/util/Hashtable.java test/api/common/org/apache/harmony/luni/tests/java/util/HashtableTest.java
Date Tue, 12 May 2009 13:26:39 GMT
Author: tellison
Date: Tue May 12 13:26:39 2009
New Revision: 773884

URL: http://svn.apache.org/viewvc?rev=773884&view=rev
Log:
Apply patch for HARMONY-6203 ([classlib][luni] java.util.Hashtable.remove(.) throws StackOverflowError
while RI doesn't)

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Hashtable.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/HashtableTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Hashtable.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Hashtable.java?rev=773884&r1=773883&r2=773884&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Hashtable.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Hashtable.java Tue
May 12 13:26:39 2009
@@ -542,10 +542,15 @@
         while (it.hasNext()) {
             Map.Entry<K, V> entry = it.next();
             Object key = entry.getKey();
+            if (key == this) {
+                continue;
+            }
             Object value = entry.getValue();
-            int hash = (key != this ? key.hashCode() : 0)
-                    ^ (value != this ? (value != null ? value.hashCode() : 0)
-                            : 0);
+            if (value == this) {
+                continue;
+            }
+            int hash = (key != null ? key.hashCode() : 0)
+                    ^ (value != null ? value.hashCode() : 0);
             result += hash;
         }
         return result;

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/HashtableTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/HashtableTest.java?rev=773884&r1=773883&r2=773884&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/HashtableTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/HashtableTest.java
Tue May 12 13:26:39 2009
@@ -106,6 +106,12 @@
 				ht.get("Ooga") == secondVal);
 	}
 
+    public void test_HashTable_Constructor() {
+        Hashtable hashTable = new Hashtable();
+        hashTable.put(hashTable, hashTable.keySet());
+        new Hashtable(hashTable);
+    }
+
 	/**
 	 * @tests java.util.Hashtable#clear()
 	 */
@@ -579,6 +585,28 @@
 		assertTrue("Remove failed", !h.containsKey("FKey 0") || k == null);
 	}
 
+    public void test_HashTable_remove_scenario1() {
+        Hashtable hashTable = new Hashtable();
+        Set keySet = hashTable.keySet();
+        hashTable.put(hashTable, keySet);
+        hashTable.remove(hashTable);
+    }
+
+    public void test_HashTable_remove_scenario2() {
+        Hashtable hashTable = new Hashtable();
+        Set keySet = hashTable.keySet();
+        hashTable.put(hashTable, hashTable);
+        hashTable.remove(hashTable);
+    }
+
+    public void test_HashTable_remove_scenario3() {
+        Hashtable hashTable = new Hashtable();
+        Hashtable keyHashTable = new Hashtable();
+        keyHashTable.put(hashTable, keyHashTable);
+        hashTable.put(keyHashTable, hashTable);
+        hashTable.remove(keyHashTable);
+    }
+
 	/**
 	 * @tests java.util.Hashtable#size()
 	 */



Mime
View raw message