harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r470346 - in /incubator/harmony/enhanced/classlib/trunk/modules/archive/src: main/java/java/util/jar/Attributes.java test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesTest.java
Date Thu, 02 Nov 2006 12:12:55 GMT
Author: pyang
Date: Thu Nov  2 04:12:55 2006
New Revision: 470346

URL: http://svn.apache.org/viewvc?view=rev&rev=470346
Log:
Apply patch for HARMONY-1864 (classlib][archive] java.util.jar.Attributes.put(null,null) throws
unexpected ClassCastException)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Attributes.java
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Attributes.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Attributes.java?view=diff&rev=470346&r1=470345&r2=470346
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Attributes.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Attributes.java
Thu Nov  2 04:12:55 2006
@@ -232,13 +232,7 @@
      *                String
      */
     public Object put(Object key, Object value) {
-        if (!(key instanceof Name)) {
-            throw new ClassCastException();
-        }
-        if (!(value instanceof String)) {
-            throw new ClassCastException();
-        }
-        return map.put(key, value);
+        return map.put((Name)key, (String)value);
     }
 
     /**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesTest.java?view=diff&rev=470346&r1=470345&r2=470346
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesTest.java
Thu Nov  2 04:12:55 2006
@@ -262,4 +262,32 @@
             // Expected
         }
     }
+    
+    /**
+     * @tests java.util.jar.Attributes.put(java.lang.Object, java.lang.Object)
+     */
+    public void test_putLjava_lang_ObjectLjava_lang_Object_Null() {
+
+        Attributes attribute = new Attributes();
+
+        assertFalse(attribute.containsKey(null));
+        assertFalse(attribute.containsValue(null));
+        attribute.put(null, null);
+        attribute.put(null, null);
+        assertEquals(1, attribute.size());
+        assertTrue(attribute.containsKey(null));
+        assertTrue(attribute.containsValue(null));
+        assertNull(attribute.get(null));
+
+        String value = "It's null";
+        attribute.put(null, value);
+        assertEquals(1, attribute.size());
+        assertEquals(value, attribute.get(null));
+
+        Attributes.Name name = new Attributes.Name("null");
+        attribute.put(name, null);
+        assertEquals(2, attribute.size());
+        assertEquals(null, attribute.get(name));
+    }
+
 }



Mime
View raw message