harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r573165 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/util/HashMap.java test/api/common/tests/api/java/util/HashMapTest.java
Date Thu, 06 Sep 2007 07:01:37 GMT
Author: leoli
Date: Thu Sep  6 00:01:36 2007
New Revision: 573165

URL: http://svn.apache.org/viewvc?rev=573165&view=rev
Log:
Apply patch for HARMONY-4750([classlib][luni] HashMap.HashMapEntrySet.contains(Object) cannot
find custmized entry without override the equal method).

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/HashMapTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java?rev=573165&r1=573164&r2=573165&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java Thu
Sep  6 00:01:36 2007
@@ -194,7 +194,7 @@
                     int index = hash & (associatedMap.elementData.length - 1);
                     entry = associatedMap.findNonNullKeyEntry(key, index, hash);
                 }
-                return object.equals(entry);
+                return entry == null ? false : entry.equals(object);
             }
             return false;
         }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/HashMapTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/HashMapTest.java?rev=573165&r1=573164&r2=573165&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/HashMapTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/HashMapTest.java
Thu Sep  6 00:01:36 2007
@@ -501,6 +501,39 @@
             return new MockClonable(i);
         }
     }
+    
+    /*
+     * Regression test for HY-4750
+     */
+    public void test_EntrySet() {
+        HashMap map = new HashMap();
+        map.put(new Integer(1), "ONE");
+
+        Set entrySet = map.entrySet();
+        Iterator e = entrySet.iterator();
+        Object real = e.next();
+        Map.Entry copyEntry = new MockEntry();
+        assertEquals(real, copyEntry);
+        assertTrue(entrySet.contains(copyEntry));
+        
+        entrySet.remove(copyEntry);
+        assertFalse(entrySet.contains(copyEntry));
+    }
+
+    private static class MockEntry implements Map.Entry {
+
+        public Object getKey() {
+            return new Integer(1);
+        }
+
+        public Object getValue() {
+            return "ONE";
+        }
+
+        public Object setValue(Object object) {
+            return null;
+        }
+    }
 	
 	/**
 	 * Sets up the fixture, for example, open a network connection. This method



Mime
View raw message