harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r438422 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/net/DatagramSocket.java test/java/tests/api/java/net/DatagramSocketTest.java
Date Wed, 30 Aug 2006 08:57:00 GMT
Author: hindessm
Date: Wed Aug 30 01:57:00 2006
New Revision: 438422

URL: http://svn.apache.org/viewvc?rev=438422&view=rev
Log:
pplied patches from "[#HARMONY-1118] [classlib][net] compatibility:
DatagramSocket().send() throws NPE on Harmony and works silently on RI".

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

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramSocket.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramSocket.java?rev=438422&r1=438421&r2=438422&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramSocket.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramSocket.java
Wed Aug 30 01:57:00 2006
@@ -405,7 +405,7 @@
 		} else {
 			// not connected so the target address cannot be null
 			if (packAddr == null) {
-				throw new NullPointerException(Msg.getString("K0331"));
+				return;
 			}
 			SecurityManager security = System.getSecurityManager();
 			if (security != null) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/DatagramSocketTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/DatagramSocketTest.java?rev=438422&r1=438421&r2=438422&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/DatagramSocketTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/DatagramSocketTest.java
Wed Aug 30 01:57:00 2006
@@ -25,6 +25,7 @@
 import java.net.Inet6Address;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
+import java.net.NetworkInterface;
 import java.net.PortUnreachableException;
 import java.net.SocketAddress;
 import java.net.SocketException;
@@ -865,7 +866,7 @@
 	/**
 	 * @tests java.net.DatagramSocket#send(java.net.DatagramPacket)
 	 */
-	public void test_sendLjava_net_DatagramPacket() {
+	public void test_sendLjava_net_DatagramPacket() throws Exception {
 		// Test for method void
 		// java.net.DatagramSocket.send(java.net.DatagramPacket)
 
@@ -920,6 +921,44 @@
 		} finally {
 			ds.close();
 		}
+		//Regression for HARMONY-1118
+		class testDatagramSocket extends DatagramSocket {
+		    public testDatagramSocket(DatagramSocketImpl impl){
+		       super(impl);
+		    }
+		}
+		class testDatagramSocketImpl extends DatagramSocketImpl { 
+		    protected void create() throws SocketException {} 
+		    protected void bind(int arg0, InetAddress arg1) throws SocketException {} 
+		    protected void send(DatagramPacket arg0) throws IOException {} 
+		    protected int peek(InetAddress arg0) throws IOException { 
+		        return 0; 
+		    } 
+		    protected int peekData(DatagramPacket arg0) throws IOException { 
+		        return 0; 
+		    } 
+		    protected void receive(DatagramPacket arg0) throws IOException {} 
+		    protected void setTTL(byte arg0) throws IOException {} 
+		    protected byte getTTL() throws IOException { 
+		        return 0; 
+		    } 
+		    protected void setTimeToLive(int arg0) throws IOException {} 
+		    protected int getTimeToLive() throws IOException { 
+		        return 0; 
+		    } 
+		    protected void join(InetAddress arg0) throws IOException {} 
+		    protected void leave(InetAddress arg0) throws IOException {} 
+		    protected void joinGroup(SocketAddress arg0, NetworkInterface arg1) throws IOException
{} 
+		    protected void leaveGroup(SocketAddress arg0, NetworkInterface arg1) throws IOException
{} 
+		    protected void close() {} 
+		    public void setOption(int arg0, Object arg1) throws SocketException {} 
+		    public Object getOption(int arg0) throws SocketException { 
+		        return null; 
+		    } 
+		} 
+        InetSocketAddress sa = InetSocketAddress.createUnresolved("localhost", 0); 
+        //no exception expected for next line
+        new testDatagramSocket(new testDatagramSocketImpl()).send(new DatagramPacket(new
byte[272], 3, sa)); 
 	}
 
 	/**



Mime
View raw message