You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2011/05/06 08:45:11 UTC

svn commit: r1100102 - in /commons/sandbox/runtime/trunk/src/main: java/org/apache/commons/runtime/net/ native/shared/ test/org/apache/commons/runtime/

Author: mturk
Date: Fri May  6 06:45:11 2011
New Revision: 1100102

URL: http://svn.apache.org/viewvc?rev=1100102&view=rev
Log:
Make sure the next works

Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/AbstractSocketAddress.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketAddress.java
    commons/sandbox/runtime/trunk/src/main/native/shared/netaddr.c
    commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestAddress.java

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/AbstractSocketAddress.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/AbstractSocketAddress.java?rev=1100102&r1=1100101&r2=1100102&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/AbstractSocketAddress.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/AbstractSocketAddress.java Fri May  6 06:45:11 2011
@@ -18,12 +18,6 @@
 
 package org.apache.commons.runtime.net;
 
-import java.io.File;
-import java.net.SocketException;
-import java.net.UnknownHostException;
-import org.apache.commons.runtime.Memory;
-import org.apache.commons.runtime.Status;
-import org.apache.commons.runtime.SystemException;
 import org.apache.commons.runtime.InvalidArgumentException;
 
 /**
@@ -43,7 +37,7 @@ final class AbstractSocketAddress extend
      * Create a new socket address with given family.
      */
     public AbstractSocketAddress(AddressFamily family)
-        throws SystemException, InvalidArgumentException
+        throws NetworkException, InvalidArgumentException
     {
         super(family);
     }

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketAddress.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketAddress.java?rev=1100102&r1=1100101&r2=1100102&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketAddress.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketAddress.java Fri May  6 06:45:11 2011
@@ -23,7 +23,6 @@ import java.net.SocketException;
 import java.net.UnknownHostException;
 import org.apache.commons.runtime.Errno;
 import org.apache.commons.runtime.Status;
-import org.apache.commons.runtime.SystemException;
 import org.apache.commons.runtime.InvalidArgumentException;
 
 /**
@@ -76,7 +75,7 @@ public abstract class SocketAddress exte
 
     protected SocketAddress(String host, AddressFamily family, int port, int flags)
         throws InvalidArgumentException,
-               SystemException
+               NetworkException
     {
         super(family);
         if (host == null && family == AddressFamily.LOCAL)
@@ -86,13 +85,13 @@ public abstract class SocketAddress exte
             if (rc == Errno.ENOMEM)
                 throw new OutOfMemoryError();
             else
-                throw new SystemException(Status.describe(rc));
+                throw new NetworkException(Status.describe(rc));
         }
     }
 
     protected SocketAddress(String host, AddressFamily family)
         throws InvalidArgumentException,
-               SystemException
+               NetworkException
     {
         super(family);
         if (host == null && family == AddressFamily.LOCAL)
@@ -102,34 +101,10 @@ public abstract class SocketAddress exte
             if (rc == Errno.ENOMEM)
                 throw new OutOfMemoryError();
             else
-                throw new SystemException(Status.describe(rc));
-        }
-    }
-/*
-    protected void sockaddr(String host, AddressFamily family, int port, int flags)
-        throws SystemException
-    {
-        int rc = sockaddr0(host, family.valueOf(), port, flags);
-        if (rc != 0) {
-            if (rc == Errno.ENOMEM)
-                throw new OutOfMemoryError();
-            else
-                throw new SystemException(Status.describe(rc));
+                throw new NetworkException(Status.describe(rc));
         }
     }
 
-    protected void sockaddr(String host, AddressFamily family)
-        throws SystemException
-    {
-        int rc = sockaddr0(host, family.valueOf(), 0, 0);
-        if (rc != 0) {
-            if (rc == Errno.ENOMEM)
-                throw new OutOfMemoryError();
-            else
-                throw new SystemException(Status.describe(rc));
-        }
-    }
-*/
     /**
      * Gets the hostname of this socket.
      *

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/netaddr.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/netaddr.c?rev=1100102&r1=1100101&r2=1100102&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/netaddr.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/netaddr.c Fri May  6 06:45:11 2011
@@ -931,9 +931,10 @@ ACR_NET_EXPORT(jboolean, SocketAddress, 
 ACR_NET_EXPORT(jint, SocketAddress, next0)(JNI_STDARGS)
 {
     acr_sockaddr_t *sa = AcrGetSockaddr(env, obj);
-    if (sa == 0)
+
+    if (sa == 0 || sa->next == 0)
         return -1;
-    switch (sa->family) {
+    switch (sa->next->family) {
         case AF_INET:
             return 1;
         case AF_INET6:

Modified: commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestAddress.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestAddress.java?rev=1100102&r1=1100101&r2=1100102&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestAddress.java (original)
+++ commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestAddress.java Fri May  6 06:45:11 2011
@@ -34,6 +34,7 @@ public class TestAddress extends Assert
         assertNotNull(la);
         assertEquals(la.getHostName(), "/var/run/foo_bar");
         assertEquals(la.getFamily(), AddressFamily.LOCAL);
+        assertNull(la.next());
         la = null;
         System.gc();
     }
@@ -45,6 +46,7 @@ public class TestAddress extends Assert
         LocalSocketAddress la = new LocalSocketAddress("foo/bar");
         assertNotNull(la);
         assertEquals(la.getHostName(), "\\\\.\\pipe\\foo_bar");
+        assertNull(la.next());
         la = null;
         System.gc();
     }