harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r407780 - 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 Fri, 19 May 2006 12:17:23 GMT
Author: mloenko
Date: Fri May 19 05:17:23 2006
New Revision: 407780

URL: http://svn.apache.org/viewvc?rev=407780&view=rev
Log:
fixes for HARMONY-464
[classlib][archive] Instead of ClassCastException java.util.jar.Attributes.putAll(Map attr)
throws NullPointerException

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?rev=407780&r1=407779&r2=407780&view=diff
==============================================================================
--- 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
Fri May 19 05:17:23 2006
@@ -239,6 +239,9 @@
 	 *            the associations to store (must be of type Attributes).
 	 */
 	public void putAll(Map attrib) {
+        if( attrib == null ) {
+            throw new ClassCastException();
+        }
 		this.map.putAll((Attributes) attrib);
 	}
 

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?rev=407780&r1=407779&r2=407780&view=diff
==============================================================================
--- 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
Fri May 19 05:17:23 2006
@@ -196,6 +196,29 @@
         }
 	}
 
+    /**
+     * @tests java.util.jar.Attributes#putAll(java.util.Map)
+     */
+    public void test_putAllLjava_util_Map2() {
+        //Regression for HARMONY-464 
+        try {
+            new Attributes().putAll((Map) null);
+            fail("ClassCastException expected");
+        } catch (ClassCastException e) {
+        }
+
+        //verify that special care for null is done in the Attributes.putAll() method
+        try {
+            new Attributes() {
+                public void putAll(Map attrib) {
+                    map.putAll((Attributes) attrib);
+                }
+            }.putAll((Map) null);
+            fail("NullPointerException expected");
+        } catch (NullPointerException e) {
+        }
+    }
+
 	/**
 	 * @tests java.util.jar.Attributes#remove(java.lang.Object)
 	 */



Mime
View raw message