harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r451099 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/util/HashMap.java test/java/org/apache/harmony/luni/tests/java/util/HashMapTest.java
Date Fri, 29 Sep 2006 03:14:21 GMT
Author: pyang
Date: Thu Sep 28 20:14:21 2006
New Revision: 451099

URL: http://svn.apache.org/viewvc?view=rev&rev=451099
Log:
Apply patch for HARMONY-1583 ([classlib][luni] HashMap can not handle de-serialization of
object with null key correctly)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/HashMapTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java?view=diff&rev=451099&r1=451098&r2=451099
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java
Thu Sep 28 20:14:21 2006
@@ -700,7 +700,7 @@
         elementCount = stream.readInt();
         for (int i = elementCount; --i >= 0;) {
             K key = (K)stream.readObject();
-            int index = (key.hashCode() & 0x7FFFFFFF) % length;
+            int index = (null == key) ? 0 : (key.hashCode() & 0x7FFFFFFF) % length;
             createEntry(key, index, (V)stream.readObject());
         }
     }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/HashMapTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/HashMapTest.java?view=diff&rev=451099&r1=451098&r2=451099
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/HashMapTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/HashMapTest.java
Thu Sep 28 20:14:21 2006
@@ -30,6 +30,10 @@
         HashMap<String, String> hm = new HashMap<String, String>();
         hm.put("key", "value");
 
+        SerializationTest.verifySelf(hm);        
+
+        //  regression for HARMONY-1583
+        hm.put(null, "null");
         SerializationTest.verifySelf(hm);
     }
 



Mime
View raw message