harmony-commits mailing list archives

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

URL: http://svn.apache.org/viewvc?rev=414554&view=rev
Log:
Throw IllegalStateException if connection already established

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java
    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=414554&r1=414553&r2=414554&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:59:48 2006
@@ -447,9 +447,15 @@
 	 * @param newValue
 	 *            the property value
 	 * 
+	 * @throws IllegalStateException - if connection already established
+	 * @throws NullPointerException - if field is null
+	 * 
 	 * @since 1.4
 	 */
 	public void addRequestProperty(String field, String newValue) {
+        if (connected) {
+            throw new IllegalStateException(Msg.getString("K0037"));
+        }
         if (field == null) {
             throw new NullPointerException(Msg.getString("KA007"));
         }

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=414554&r1=414553&r2=414554&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:59:48 2006
@@ -39,6 +39,16 @@
         } catch (NullPointerException e) {
             // expected
         }
+        
+        u.connect();
+        try {
+            // state of connection is checked first
+            // so no NPE in case of null 'field' param
+            u.addRequestProperty(null, "someValue");
+            fail("Expected IllegalStateException");
+        } catch (IllegalStateException e) {
+            // expected
+        }
     }
 
     /**



Mime
View raw message