harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r930172 - in /harmony/enhanced/java/trunk/classlib/modules/luni/src: main/java/java/net/DatagramSocket.java test/api/common/org/apache/harmony/luni/tests/java/net/DatagramSocketTest.java
Date Fri, 02 Apr 2010 06:09:39 GMT
Author: hindessm
Date: Fri Apr  2 06:09:38 2010
New Revision: 930172

URL: http://svn.apache.org/viewvc?rev=930172&view=rev
Log:
Applying patches from "[#HARMONY-6492] [classlib][luni]
DatagramSocket.send(DatagramPacket) should throw NullPointerException if
the InetAdderess of DatagramPacket is null".

Modified:
    harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/java/net/DatagramSocket.java
    harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/DatagramSocketTest.java

Modified: harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/java/net/DatagramSocket.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/java/net/DatagramSocket.java?rev=930172&r1=930171&r2=930172&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/java/net/DatagramSocket.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/java/net/DatagramSocket.java
Fri Apr  2 06:09:38 2010
@@ -442,11 +442,8 @@ public class DatagramSocket {
         } else {
             // not connected so the target address is not allowed to be null
             if (packAddr == null) {
-                if (pack.getPort() == -1) {
                     // KA019 Destination address is null
                     throw new NullPointerException(Messages.getString("luni.59")); //$NON-NLS-1$
-                }
-                return;
             }
             SecurityManager security = System.getSecurityManager();
             if (security != null) {

Modified: harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/DatagramSocketTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/DatagramSocketTest.java?rev=930172&r1=930171&r2=930172&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/DatagramSocketTest.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/DatagramSocketTest.java
Fri Apr  2 06:09:38 2010
@@ -36,6 +36,7 @@ import java.net.UnknownHostException;
 import java.util.Date;
 
 import org.apache.harmony.luni.net.PlainDatagramSocketImpl;
+import org.junit.Test;
 
 import tests.support.Support_Configuration;
 import tests.support.Support_PortManager;
@@ -940,6 +941,29 @@ public class DatagramSocketTest extends 
     }
     
     /**
+     * If the InetAddress of DatagramPacket is null, DatagramSocket.send(DatagramPacket)
+     * should throw NullPointer Exception.
+     * @tests java.net.DatagramSocket#send(java.net.DatagramPacket)
+     */
+    @Test
+    public void test_sendLjava_net_DatagramPacket2() throws IOException {
+        int udp_port = 20000;
+        int send_port = 23000;
+        DatagramSocket udpSocket = new DatagramSocket(udp_port);
+        byte[] data = {65};
+        DatagramPacket sendPacket = new DatagramPacket(data, data.length, null, send_port);
+        try {
+            udpSocket.send(sendPacket);
+            fail("Should throw SocketException");
+        } catch (NullPointerException e) {
+          // Expected
+        } finally {
+            udpSocket.close();
+        }
+
+    }
+    
+    /**
      * @tests {@link java.net.DatagramSocket#setDatagramSocketImplFactory(DatagramSocketImplFactory)}
      */
     public void test_set_Datagram_SocketImpl_Factory() throws IOException {



Mime
View raw message