commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1128993 - in /commons/sandbox/runtime/trunk/src/main: java/org/apache/commons/runtime/net/ native/include/acr/ native/shared/
Date Mon, 30 May 2011 04:52:56 GMT
Author: mturk
Date: Mon May 30 04:52:56 2011
New Revision: 1128993

URL: http://svn.apache.org/viewvc?rev=1128993&view=rev
Log:
Add api for throwing oveflows

Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/InetSocketAddress.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalSocketSelectorFactory.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketSelectorFactory.java
    commons/sandbox/runtime/trunk/src/main/native/include/acr/error.h
    commons/sandbox/runtime/trunk/src/main/native/shared/error.c

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/InetSocketAddress.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/InetSocketAddress.java?rev=1128993&r1=1128992&r2=1128993&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/InetSocketAddress.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/InetSocketAddress.java
Mon May 30 04:52:56 2011
@@ -23,7 +23,7 @@ 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;
+import org.apache.commons.runtime.InvalidRangeException;
 
 /**
  * This class represents a Internet Protocol (IP) socket endpoint
@@ -48,11 +48,11 @@ public class InetSocketAddress extends S
     }
 
     public InetSocketAddress(String hostname, int port)
-        throws OutOfMemoryError, NetworkException, InvalidArgumentException
+        throws OutOfMemoryError, NetworkException, InvalidRangeException
     {
         super();
         if (port < 0 || port > 65535)
-            throw new InvalidArgumentException(Local.sm.get("port.ERANGE"));
+            throw new InvalidRangeException(Local.sm.get("port.ERANGE"));
         byte[] sa = SocketAddressImpl.getnameinfo(AddressFamily.UNSPEC, hostname, null, port);
         SocketAddressImpl.sockaddr(this, sa);
     }
@@ -64,10 +64,10 @@ public class InetSocketAddress extends S
     }
 
     public static final SocketAddress[] getAll(String hostname, int port)
-        throws OutOfMemoryError, NetworkException, InvalidArgumentException
+        throws OutOfMemoryError, NetworkException, InvalidRangeException
     {        
         if (port < 0 || port > 65535)
-            throw new InvalidArgumentException(Local.sm.get("port.ERANGE"));
+            throw new InvalidRangeException(Local.sm.get("port.ERANGE"));
         byte[] sa = SocketAddressImpl.getnameinfo(AddressFamily.UNSPEC, hostname, null, port);
         int n = sa.length / sasize;
         SocketAddress[] a = new SocketAddress[n];

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalSocketSelectorFactory.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalSocketSelectorFactory.java?rev=1128993&r1=1128992&r2=1128993&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalSocketSelectorFactory.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalSocketSelectorFactory.java
Mon May 30 04:52:56 2011
@@ -18,7 +18,7 @@
 
 package org.apache.commons.runtime.net;
 
-import org.apache.commons.runtime.InvalidArgumentException;
+import org.apache.commons.runtime.InvalidRangeException;
 
 /**
  * Creates a new local socket selector instance.
@@ -47,15 +47,15 @@ public final class LocalSocketSelectorFa
      *
      * @return the new socket selector.
      *
-     * @throws InvalidArgumentException if {@code size} is outside the
+     * @throws InvalidRangeException if {@code size} is outside the
      *          valid range.
      * @throws OutOfMemoryError if the memory allocation fails.
      */
     public static Selector newInstance(int size)
-        throws InvalidArgumentException, OutOfMemoryError
+        throws InvalidRangeException, OutOfMemoryError
     {
         if (size < 1 || size > MAX_CAPACITY)
-            throw new InvalidArgumentException();
+            throw new InvalidRangeException();
         return new0(size);
     }
 
@@ -64,15 +64,15 @@ public final class LocalSocketSelectorFa
      *
      * @return the new local socket selector.
      *
-     * @throws InvalidArgumentException if the selector capacity cannot be
+     * @throws RuntimeException if the selector capacity cannot be
      *          determined.
      * @throws OutOfMemoryError if the memory allocation fails.
      */
     public static Selector newInstance()
-        throws InvalidArgumentException, OutOfMemoryError
+        throws RuntimeException, OutOfMemoryError
     {
         if (MAX_CAPACITY < 1)
-            throw new InvalidArgumentException();
+            throw new RuntimeException();
         return newInstance(MAX_CAPACITY);
     }
 

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketSelectorFactory.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketSelectorFactory.java?rev=1128993&r1=1128992&r2=1128993&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketSelectorFactory.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketSelectorFactory.java
Mon May 30 04:52:56 2011
@@ -18,7 +18,7 @@
 
 package org.apache.commons.runtime.net;
 
-import org.apache.commons.runtime.InvalidArgumentException;
+import org.apache.commons.runtime.InvalidRangeException;
 
 /**
  * Creates a new socket selector instance.
@@ -47,15 +47,15 @@ public final class SocketSelectorFactory
      *
      * @return the new socket selector.
      *
-     * @throws InvalidArgumentException if {@code size} is outside the
+     * @throws InvalidRangeException if {@code size} is outside the
      *          valid range.
      * @throws OutOfMemoryError if the memory allocation fails.
      */
     public static Selector newInstance(int size)
-        throws InvalidArgumentException, OutOfMemoryError
+        throws InvalidRangeException, OutOfMemoryError
     {
         if (size < 1 || size > MAX_CAPACITY)
-            throw new InvalidArgumentException();        
+            throw new InvalidRangeException();
         return new0(size);
     }
 
@@ -64,15 +64,15 @@ public final class SocketSelectorFactory
      *
      * @return the new socket selector.
      *
-     * @throws InvalidArgumentException if the selector capacity cannot be
+     * @throws RuntimeException if the selector capacity cannot be
      *          determined.
      * @throws OutOfMemoryError if the memory allocation fails.
      */
     public static Selector newInstance()
-        throws InvalidArgumentException, OutOfMemoryError
+        throws RuntimeException, OutOfMemoryError
     {
         if (MAX_CAPACITY < 1)
-            throw new InvalidArgumentException();
+            throw new RuntimeException();
         return newInstance(MAX_CAPACITY);
     }
 

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr/error.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr/error.h?rev=1128993&r1=1128992&r2=1128993&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr/error.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr/error.h Mon May 30 04:52:56
2011
@@ -57,6 +57,7 @@ enum {
     ACR_EX_TIMEOUT,         /* TimeoutException */
     ACR_EX_ESYS,            /* SystemException */
     ACR_EX_ENET,            /* NetworkException */
+    ACR_EX_EOVERFLOW,       /* OverflowException */
     ACR_EX_LEN
 };
 

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/error.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/error.c?rev=1128993&r1=1128992&r2=1128993&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/error.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/error.c Mon May 30 04:52:56 2011
@@ -50,7 +50,8 @@ static struct {
     { 0, ACR_CLASS_PATH "OperationNotPermittedException"        }, /* EPERM     */
     { 0, ACR_CLASS_PATH "TimeoutException"                      }, /* ETIMEOUT  */
     { 0, ACR_CLASS_PATH "SystemException"                       },
-    { 0, ACR_NET_CP     "NetworkException"                      }
+    { 0, ACR_NET_CP     "NetworkException"                      },
+    { 0, ACR_CLASS_PATH "OverflowException"                     }  /* EOVERFLOW */
 };
 
 static const char *const _canon_errors[] = {
@@ -773,6 +774,8 @@ AcrThrowByError(JNI_STDENV, int def, int
         cls = ACR_EX_ERANGE;
     else if (err == ACR_EBADF)
         cls = ACR_EX_EBADF;
+    else if (err == ACR_EOVERFLOW)
+        cls = ACR_EX_EOVERFLOW;
     AcrThrow(env, cls, msg);
 }
 



Mime
View raw message