directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r155923 - in incubator/directory/network/mina/trunk/src: java/org/apache/mina/io/datagram/DatagramAcceptor.java java/org/apache/mina/io/socket/SocketAcceptor.java java/org/apache/mina/util/AvailablePortFinder.java test/org/apache/mina/examples/echoserver/Test.java
Date Wed, 02 Mar 2005 14:23:44 GMT
Author: trustin
Date: Wed Mar  2 06:23:42 2005
New Revision: 155923

URL: http://svn.apache.org/viewcvs?view=rev&rev=155923
Log:
Fixed DIRMINA-9: Add AvaliablePortFinder from apseda to scan for ports.
Fixed: SocketAcceptor and DatagramAcceptor cannot bind to port 0.  It seems that open server
socket channel is closed just before it is registered to the selector.  So I made acceptors
to throw IllegalArgumentException if the port number is 0.

Modified:
    incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java
    incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java
    incubator/directory/network/mina/trunk/src/java/org/apache/mina/util/AvailablePortFinder.java
    incubator/directory/network/mina/trunk/src/test/org/apache/mina/examples/echoserver/Test.java

Modified: incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java?view=diff&r1=155922&r2=155923
==============================================================================
--- incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java
(original)
+++ incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java
Wed Mar  2 06:23:42 2005
@@ -89,6 +89,8 @@
         if( !( address instanceof InetSocketAddress ) )
             throw new IllegalArgumentException( "Unexpected address type: "
                                                 + address.getClass() );
+        if( ( ( InetSocketAddress ) address ).getPort() == 0 )
+            throw new IllegalArgumentException( "Unsupported port number: 0" );
 
         DatagramChannel ch = DatagramChannel.open();
         boolean bound = false;

Modified: incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java?view=diff&r1=155922&r2=155923
==============================================================================
--- incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java
(original)
+++ incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java
Wed Mar  2 06:23:42 2005
@@ -99,6 +99,8 @@
         if( !( address instanceof InetSocketAddress ) )
             throw new IllegalArgumentException( "Unexpected address type: "
                                                 + address.getClass() );
+        if( ( ( InetSocketAddress ) address ).getPort() == 0 )
+            throw new IllegalArgumentException( "Unsupported port number: 0" );
 
         ServerSocketChannel ssc = ServerSocketChannel.open();
         boolean bound = false;

Modified: incubator/directory/network/mina/trunk/src/java/org/apache/mina/util/AvailablePortFinder.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/java/org/apache/mina/util/AvailablePortFinder.java?view=diff&r1=155922&r2=155923
==============================================================================
--- incubator/directory/network/mina/trunk/src/java/org/apache/mina/util/AvailablePortFinder.java
(original)
+++ incubator/directory/network/mina/trunk/src/java/org/apache/mina/util/AvailablePortFinder.java
Wed Mar  2 06:23:42 2005
@@ -39,7 +39,7 @@
     /**
      * The minimum number of server port number.
      */
-    public static final int MIN_PORT_NUMBER = 0;
+    public static final int MIN_PORT_NUMBER = 1;
 
     /**
      * The maximum number of server port number.

Modified: incubator/directory/network/mina/trunk/src/test/org/apache/mina/examples/echoserver/Test.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/test/org/apache/mina/examples/echoserver/Test.java?view=diff&r1=155922&r2=155923
==============================================================================
--- incubator/directory/network/mina/trunk/src/test/org/apache/mina/examples/echoserver/Test.java
(original)
+++ incubator/directory/network/mina/trunk/src/test/org/apache/mina/examples/echoserver/Test.java
Wed Mar  2 06:23:42 2005
@@ -57,7 +57,11 @@
         // Find an availble test port and bind to it.
         boolean socketBound = false;
         boolean datagramBound = false;
-        for( port = 1024; port <= 65535; port ++ )
+        
+        // Let's start from port #1 to detect possible resource leak
+        // because test will fail in port 1-1023 if user run this test
+        // as a normal user.
+        for( port = 1; port <= 65535; port ++ )
         {
             socketBound = false;
             datagramBound = false;



Mime
View raw message