Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 36176 invoked from network); 12 May 2009 13:27:04 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 12 May 2009 13:27:04 -0000 Received: (qmail 79171 invoked by uid 500); 12 May 2009 13:27:04 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 79150 invoked by uid 500); 12 May 2009 13:27:04 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 79141 invoked by uid 99); 12 May 2009 13:27:04 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 May 2009 13:27:04 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 May 2009 13:27:01 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 18726238896D; Tue, 12 May 2009 13:26:40 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@harmony.apache.org From: tellison@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090512132640.18726238896D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 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() */