harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r572657 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/net/InetAddress.java test/api/common/org/apache/harmony/luni/tests/java/net/InetAddressTest.java
Date Tue, 04 Sep 2007 13:04:28 GMT
Author: tellison
Date: Tue Sep  4 06:04:27 2007
New Revision: 572657

URL: http://svn.apache.org/viewvc?rev=572657&view=rev
Log:
Fix typo, InetAddress should be using the copy of incoming byte array.

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

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/InetAddress.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/InetAddress.java?rev=572657&r1=572656&r2=572657&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/InetAddress.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/InetAddress.java Tue
Sep  4 06:04:27 2007
@@ -972,7 +972,7 @@
             for (int i = 0; i < 4; i++) {
                 copy_address[i] = ipAddress[i];
             }
-            return new Inet4Address(ipAddress);
+            return new Inet4Address(copy_address);
         }
 
         if (ipAddress != null && ipAddress.length == 16) {
@@ -989,6 +989,8 @@
             copy_address = ipAddress.clone();
             return new Inet6Address(copy_address, scope_id);
         }
+
+        // K0339=Invalid IP Address is neither 4 or 16 bytes
         throw new UnknownHostException(Msg.getString("K0339")); //$NON-NLS-1$
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetAddressTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetAddressTest.java?rev=572657&r1=572656&r2=572657&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetAddressTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetAddressTest.java
Tue Sep  4 06:04:27 2007
@@ -150,7 +150,7 @@
     /**
      * @tests java.net.InetAddress#getAddress()
      */
-    public void test_getAddress() {
+    public void test_getAddress() throws UnknownHostException {
         // Test for method byte [] java.net.InetAddress.getAddress()
         try {
             InetAddress ia = InetAddress
@@ -161,6 +161,12 @@
                 assertTrue("Incorrect address returned", caddr[i] == addr[i]);
         } catch (java.net.UnknownHostException e) {
         }
+        
+        byte[] origBytes = new byte[] { 0, 1, 2, 3 };
+        InetAddress address = InetAddress.getByAddress(origBytes);
+        origBytes[0] = -1;
+        byte[] newBytes = address.getAddress();
+        assertSame((byte) 0, newBytes[0]);
     }
 
     /**



Mime
View raw message