harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From regi...@apache.org
Subject svn commit: r907563 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/net/ main/java/org/apache/harmony/luni/util/ test/api/common/org/apache/harmony/luni/tests/java/net/
Date Mon, 08 Feb 2010 07:09:10 GMT
Author: regisxu
Date: Mon Feb  8 07:09:09 2010
New Revision: 907563

URL: http://svn.apache.org/viewvc?rev=907563&view=rev
Log:
Apply patch for HARMONY-6413: [java6][classlib][luni]DatagramSock do NOT throw IllegalArgumentException

Agreed with Ray, this patch could be also applied to Java5.

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

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramPacket.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramPacket.java?rev=907563&r1=907562&r2=907563&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramPacket.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramPacket.java
Mon Feb  8 07:09:09 2010
@@ -330,6 +330,9 @@
                     "K0316", sockAddr == null ? null : sockAddr.getClass())); //$NON-NLS-1$
         }
         InetSocketAddress inetAddr = (InetSocketAddress) sockAddr;
+        if(inetAddr.isUnresolved()){
+            throw new IllegalArgumentException(Msg.getString("K0353"));
+        }
         port = inetAddr.getPort();
         address = inetAddr.getAddress();
     }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties?rev=907563&r1=907562&r2=907563&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
Mon Feb  8 07:09:09 2010
@@ -327,3 +327,4 @@
 K0031=Length out of bounds \: {0}
 K0032=Source size {0} does not fit into destination
 K0033=Start index ({0}) is greater than end index ({1})
+K0353=Unresolved address

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/DatagramSocketTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/DatagramSocketTest.java?rev=907563&r1=907562&r2=907563&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/DatagramSocketTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/DatagramSocketTest.java
Mon Feb  8 07:09:09 2010
@@ -916,12 +916,6 @@
             }
         }
 
-        InetSocketAddress sa = InetSocketAddress.createUnresolved("localhost",
-                0);
-        // no exception expected for next line
-        new testDatagramSocket(new testDatagramSocketImpl())
-                .send(new DatagramPacket(new byte[272], 3, sa));
-
         // Regression test for Harmony-2938
         InetAddress i = InetAddress.getByName("127.0.0.1");
         DatagramSocket d = new DatagramSocket(0, i);
@@ -933,6 +927,16 @@
         } finally {
             d.close();
         }
+
+        // Regression test for Harmony-6413
+        InetSocketAddress addr = InetSocketAddress.createUnresolved(
+                "localhost", 0);
+        try {
+            DatagramPacket dp = new DatagramPacket(new byte[272], 3, addr);
+            fail("should throw IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
     }
     
     /**



Mime
View raw message