harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r414542 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/net/ main/java/org/apache/harmony/luni/util/ test/java/org/apache/harmony/tests/java/net/
Date Thu, 15 Jun 2006 10:34:37 GMT
Author: smishura
Date: Thu Jun 15 03:34:37 2006
New Revision: 414542

URL: http://svn.apache.org/viewvc?rev=414542&view=rev
Log:
Fix for HARMONY-604 (java.net.URLConnection.addRequestProperty((String) null, String value)
doesn't throw NPE)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URLConnectionTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java?rev=414542&r1=414541&r2=414542&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java
Thu Jun 15 03:34:37 2006
@@ -450,6 +450,9 @@
 	 * @since 1.4
 	 */
 	public void addRequestProperty(String field, String newValue) {
+        if (field == null) {
+            throw new NullPointerException(Msg.getString("KA007"));
+        }
 	}
 
 	/**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties?rev=414542&r1=414541&r2=414542&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
Thu Jun 15 03:34:37 2006
@@ -292,5 +292,5 @@
 KA004=Enums may not be cloned
 KA005={0} is not an enum type
 KA006={0} is not a constant in the enum type {1}
-
+KA007=field is null
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URLConnectionTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URLConnectionTest.java?rev=414542&r1=414541&r2=414542&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URLConnectionTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URLConnectionTest.java
Thu Jun 15 03:34:37 2006
@@ -25,6 +25,23 @@
 public class URLConnectionTest extends TestCase {
 
     /**
+     * @tests java.net.URLConnection#addRequestProperty(String, String)
+     */
+    public void test_addRequestProperty() throws MalformedURLException,
+            IOException {
+
+        MockURLConnection u = new MockURLConnection(new URL(
+                "http://www.apache.org"));
+        try {
+            // Regression for HARMONY-604
+            u.addRequestProperty(null, "someValue");
+            fail("Expected NullPointerException");
+        } catch (NullPointerException e) {
+            // expected
+        }
+    }
+
+    /**
      * @tests java.net.URLConnection#setUseCaches(boolean)
      */
     public void test_setUseCachesZ() throws MalformedURLException, IOException {



Mime
View raw message