directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r188654 - in /directory/network: branches/0.7/src/java/org/apache/mina/io/datagram/ branches/0.7/src/java/org/apache/mina/io/socket/ branches/0.7/src/java/org/apache/mina/protocol/io/ trunk/src/java/org/apache/mina/transport/socket/nio/ trunk/src/test/org/apache/mina/transport/socket/nio/
Date Tue, 07 Jun 2005 01:31:14 GMT
Author: trustin
Date: Mon Jun  6 18:31:11 2005
New Revision: 188654

URL: http://svn.apache.org/viewcvs?rev=188654&view=rev
Log:
Fixed: DIRMINA-49
Fixed compilation error for DIRMINA-54


Modified:
    directory/network/branches/0.7/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java
    directory/network/branches/0.7/src/java/org/apache/mina/io/datagram/DatagramConnector.java
    directory/network/branches/0.7/src/java/org/apache/mina/io/socket/SocketAcceptor.java
    directory/network/branches/0.7/src/java/org/apache/mina/io/socket/SocketConnector.java
    directory/network/branches/0.7/src/java/org/apache/mina/protocol/io/IoAdapter.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramAcceptor.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramConnector.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketConnector.java
    directory/network/trunk/src/test/org/apache/mina/transport/socket/nio/DatagramBindTest.java
    directory/network/trunk/src/test/org/apache/mina/transport/socket/nio/SocketBindTest.java

Modified: directory/network/branches/0.7/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.7/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java?rev=188654&r1=188653&r2=188654&view=diff
==============================================================================
--- directory/network/branches/0.7/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java
(original)
+++ directory/network/branches/0.7/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java
Mon Jun  6 18:31:11 2005
@@ -52,7 +52,7 @@
 
     private final int id = nextId ++ ;
 
-    private final Selector selector;
+    private Selector selector;
 
     private final Map channels = new HashMap();
 
@@ -66,12 +66,9 @@
 
     /**
      * Creates a new instance.
-     * 
-     * @throws IOException if failed to open a selector.
      */
-    public DatagramAcceptor() throws IOException
+    public DatagramAcceptor()
     {
-        selector = Selector.open();
     }
 
     public void bind( SocketAddress address, IoHandler handler )
@@ -127,11 +124,23 @@
         CancellationRequest request = new CancellationRequest( address );
         synchronized( this )
         {
+            try
+            {
+                startupWorker();
+            }
+            catch( IOException e )
+            {
+                // IOException is thrown only when Worker thread is not
+                // running and failed to open a selector.  We simply throw
+                // IllegalArgumentException here because we can simply
+                // conclude that nothing is bound to the selector.
+                throw new IllegalArgumentException( "Address not bound: " + address );
+            }
+
             synchronized( cancelQueue )
             {
                 cancelQueue.push( request );
             }
-            startupWorker();
         }
         selector.wakeup();
         
@@ -156,10 +165,11 @@
         }
     }
     
-    private synchronized void startupWorker()
+    private synchronized void startupWorker() throws IOException
     {
         if( worker == null )
         {
+            selector = Selector.open();
             worker = new Worker();
             worker.start();
         }
@@ -217,6 +227,18 @@
                                 cancelQueue.isEmpty() )
                             {
                                 worker = null;
+                                try
+                                {
+                                    selector.close();
+                                }
+                                catch( IOException e )
+                                {
+                                    exceptionMonitor.exceptionCaught( DatagramAcceptor.this,
e );
+                                }
+                                finally
+                                {
+                                    selector = null;
+                                }
                                 break;
                             }
                         }

Modified: directory/network/branches/0.7/src/java/org/apache/mina/io/datagram/DatagramConnector.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.7/src/java/org/apache/mina/io/datagram/DatagramConnector.java?rev=188654&r1=188653&r2=188654&view=diff
==============================================================================
--- directory/network/branches/0.7/src/java/org/apache/mina/io/datagram/DatagramConnector.java
(original)
+++ directory/network/branches/0.7/src/java/org/apache/mina/io/datagram/DatagramConnector.java
Mon Jun  6 18:31:11 2005
@@ -51,7 +51,7 @@
 
     private final int id = nextId ++ ;
 
-    private final Selector selector;
+    private Selector selector;
 
     private final Queue registerQueue = new Queue();
 
@@ -63,12 +63,9 @@
 
     /**
      * Creates a new instance.
-     * 
-     * @throws IOException if failed to open a selector
      */
-    public DatagramConnector() throws IOException
+    public DatagramConnector()
     {
-        selector = Selector.open();
     }
 
     public IoSession connect( SocketAddress address, IoHandler handler ) throws IOException
@@ -159,10 +156,11 @@
         return request.session;
     }
     
-    private synchronized void startupWorker()
+    private synchronized void startupWorker() throws IOException
     {
         if( worker == null )
         {
+            selector = Selector.open();
             worker = new Worker();
             worker.start();
         }
@@ -172,12 +170,25 @@
     {
         synchronized( this )
         {
+            try
+            {
+                startupWorker();
+            }
+            catch( IOException e )
+            {
+                // IOException is thrown only when Worker thread is not
+                // running and failed to open a selector.  We simply return
+                // silently here because it we can simply conclude that
+                // this session is not managed by this connector or
+                // already closed.
+                return;
+            }
+
             SelectionKey key = session.getSelectionKey();
             synchronized( cancelQueue )
             {
                 cancelQueue.push( key );
             }
-            startupWorker();
         }
 
         selector.wakeup();
@@ -231,6 +242,18 @@
                                 cancelQueue.isEmpty() )
                             {
                                 worker = null;
+                                try
+                                {
+                                    selector.close();
+                                }
+                                catch( IOException e )
+                                {
+                                    exceptionMonitor.exceptionCaught( DatagramConnector.this,
e );
+                                }
+                                finally
+                                {
+                                    selector = null;
+                                }
                                 break;
                             }
                         }

Modified: directory/network/branches/0.7/src/java/org/apache/mina/io/socket/SocketAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.7/src/java/org/apache/mina/io/socket/SocketAcceptor.java?rev=188654&r1=188653&r2=188654&view=diff
==============================================================================
--- directory/network/branches/0.7/src/java/org/apache/mina/io/socket/SocketAcceptor.java
(original)
+++ directory/network/branches/0.7/src/java/org/apache/mina/io/socket/SocketAcceptor.java
Mon Jun  6 18:31:11 2005
@@ -51,7 +51,7 @@
 
     private final int id = nextId ++ ;
 
-    private final Selector selector;
+    private Selector selector;
 
     private final Map channels = new HashMap();
 
@@ -66,12 +66,9 @@
 
     /**
      * Creates a new instance.
-     * 
-     * @throws IOException
      */
-    public SocketAcceptor() throws IOException
+    public SocketAcceptor()
     {
-        selector = Selector.open();
     }
 
     /**
@@ -137,10 +134,11 @@
     }
 
 
-    private synchronized void startupWorker()
+    private synchronized void startupWorker() throws IOException
     {
         if( worker == null )
         {
+            selector = Selector.open();
             worker = new Worker();
 
             worker.start();
@@ -158,11 +156,23 @@
         CancellationRequest request = new CancellationRequest( address );
         synchronized( this )
         {
+            try
+            {
+                startupWorker();
+            }
+            catch( IOException e )
+            {
+                // IOException is thrown only when Worker thread is not
+                // running and failed to open a selector.  We simply throw
+                // IllegalArgumentException here because we can simply
+                // conclude that nothing is bound to the selector.
+                throw new IllegalArgumentException( "Address not bound: " + address );
+            }
+
             synchronized( cancelQueue )
             {
                 cancelQueue.push( request );
             }
-            startupWorker();
         }
         
         selector.wakeup();
@@ -242,7 +252,18 @@
                                 cancelQueue.isEmpty() )
                             {
                                 worker = null;
-
+                                try
+                                {
+                                    selector.close();
+                                }
+                                catch( IOException e )
+                                {
+                                    exceptionMonitor.exceptionCaught( SocketAcceptor.this,
e );
+                                }
+                                finally
+                                {
+                                    selector = null;
+                                }
                                 break;
                             }
                         }

Modified: directory/network/branches/0.7/src/java/org/apache/mina/io/socket/SocketConnector.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.7/src/java/org/apache/mina/io/socket/SocketConnector.java?rev=188654&r1=188653&r2=188654&view=diff
==============================================================================
--- directory/network/branches/0.7/src/java/org/apache/mina/io/socket/SocketConnector.java
(original)
+++ directory/network/branches/0.7/src/java/org/apache/mina/io/socket/SocketConnector.java
Mon Jun  6 18:31:11 2005
@@ -51,7 +51,7 @@
 
     private final IoSessionManagerFilterChain filters = new SocketSessionManagerFilterChain(
this );
 
-    private final Selector selector;
+    private Selector selector;
 
     private final Queue connectQueue = new Queue();
 
@@ -59,12 +59,9 @@
 
     /**
      * Creates a new instance.
-     * 
-     * @throws IOException
      */
-    public SocketConnector() throws IOException
+    public SocketConnector()
     {
-        selector = Selector.open();
     }
 
     public IoSession connect( SocketAddress address, IoHandler handler ) throws IOException
@@ -163,10 +160,11 @@
         return request.session;
     }
     
-    private synchronized void startupWorker()
+    private synchronized void startupWorker() throws IOException
     {
         if( worker == null )
         {
+            selector = Selector.open();
             worker = new Worker();
             worker.start();
         }
@@ -331,6 +329,18 @@
                                 connectQueue.isEmpty() )
                             {
                                 worker = null;
+                                try
+                                {
+                                    selector.close();
+                                }
+                                catch( IOException e )
+                                {
+                                    exceptionMonitor.exceptionCaught( SocketConnector.this,
e );
+                                }
+                                finally
+                                {
+                                    selector = null;
+                                }
                                 break;
                             }
                         }

Modified: directory/network/branches/0.7/src/java/org/apache/mina/protocol/io/IoAdapter.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.7/src/java/org/apache/mina/protocol/io/IoAdapter.java?rev=188654&r1=188653&r2=188654&view=diff
==============================================================================
--- directory/network/branches/0.7/src/java/org/apache/mina/protocol/io/IoAdapter.java (original)
+++ directory/network/branches/0.7/src/java/org/apache/mina/protocol/io/IoAdapter.java Mon
Jun  6 18:31:11 2005
@@ -100,7 +100,7 @@
             this.handler = protocolProvider.getHandler();
         }
         
-        public void sessionCreated( IoSession session )
+        public void sessionCreated( IoSession session ) throws Exception
         {
             handler.sessionCreated( getProtocolSession( session ) );
         }

Modified: directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramAcceptor.java?rev=188654&r1=188653&r2=188654&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramAcceptor.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramAcceptor.java
Mon Jun  6 18:31:11 2005
@@ -52,7 +52,7 @@
 
     private final int id = nextId ++ ;
 
-    private final Selector selector;
+    private Selector selector;
 
     private final Map channels = new HashMap();
 
@@ -66,12 +66,9 @@
 
     /**
      * Creates a new instance.
-     * 
-     * @throws IOException if failed to open a selector.
      */
-    public DatagramAcceptor() throws IOException
+    public DatagramAcceptor()
     {
-        selector = Selector.open();
     }
 
     public void bind( SocketAddress address, IoHandler handler )
@@ -127,11 +124,23 @@
         CancellationRequest request = new CancellationRequest( address );
         synchronized( this )
         {
+            try
+            {
+                startupWorker();
+            }
+            catch( IOException e )
+            {
+                // IOException is thrown only when Worker thread is not
+                // running and failed to open a selector.  We simply throw
+                // IllegalArgumentException here because we can simply
+                // conclude that nothing is bound to the selector.
+                throw new IllegalArgumentException( "Address not bound: " + address );
+            }
+
             synchronized( cancelQueue )
             {
                 cancelQueue.push( request );
             }
-            startupWorker();
         }
         selector.wakeup();
         
@@ -156,10 +165,11 @@
         }
     }
     
-    private synchronized void startupWorker()
+    private synchronized void startupWorker() throws IOException
     {
         if( worker == null )
         {
+            selector = Selector.open();
             worker = new Worker();
             worker.start();
         }
@@ -217,6 +227,18 @@
                                 cancelQueue.isEmpty() )
                             {
                                 worker = null;
+                                try
+                                {
+                                    selector.close();
+                                }
+                                catch( IOException e )
+                                {
+                                    exceptionMonitor.exceptionCaught( DatagramAcceptor.this,
e );
+                                }
+                                finally
+                                {
+                                    selector = null;
+                                }
                                 break;
                             }
                         }

Modified: directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramConnector.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramConnector.java?rev=188654&r1=188653&r2=188654&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramConnector.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramConnector.java
Mon Jun  6 18:31:11 2005
@@ -51,7 +51,7 @@
 
     private final int id = nextId ++ ;
 
-    private final Selector selector;
+    private Selector selector;
 
     private final Queue registerQueue = new Queue();
 
@@ -63,12 +63,9 @@
 
     /**
      * Creates a new instance.
-     * 
-     * @throws IOException if failed to open a selector
      */
-    public DatagramConnector() throws IOException
+    public DatagramConnector()
     {
-        selector = Selector.open();
     }
 
     public IoSession connect( SocketAddress address, IoHandler handler ) throws IOException
@@ -159,10 +156,11 @@
         return request.session;
     }
     
-    private synchronized void startupWorker()
+    private synchronized void startupWorker() throws IOException
     {
         if( worker == null )
         {
+            selector = Selector.open();
             worker = new Worker();
             worker.start();
         }
@@ -172,12 +170,25 @@
     {
         synchronized( this )
         {
+            try
+            {
+                startupWorker();
+            }
+            catch( IOException e )
+            {
+                // IOException is thrown only when Worker thread is not
+                // running and failed to open a selector.  We simply return
+                // silently here because it we can simply conclude that
+                // this session is not managed by this connector or
+                // already closed.
+                return;
+            }
+
             SelectionKey key = session.getSelectionKey();
             synchronized( cancelQueue )
             {
                 cancelQueue.push( key );
             }
-            startupWorker();
         }
 
         selector.wakeup();
@@ -231,6 +242,18 @@
                                 cancelQueue.isEmpty() )
                             {
                                 worker = null;
+                                try
+                                {
+                                    selector.close();
+                                }
+                                catch( IOException e )
+                                {
+                                    exceptionMonitor.exceptionCaught( DatagramConnector.this,
e );
+                                }
+                                finally
+                                {
+                                    selector = null;
+                                }
                                 break;
                             }
                         }

Modified: directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java?rev=188654&r1=188653&r2=188654&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java
Mon Jun  6 18:31:11 2005
@@ -51,7 +51,7 @@
 
     private final int id = nextId ++ ;
 
-    private final Selector selector;
+    private Selector selector;
 
     private final Map channels = new HashMap();
 
@@ -66,12 +66,9 @@
 
     /**
      * Creates a new instance.
-     * 
-     * @throws IOException
      */
-    public SocketAcceptor() throws IOException
+    public SocketAcceptor()
     {
-        selector = Selector.open();
     }
 
     /**
@@ -137,10 +134,11 @@
     }
 
 
-    private synchronized void startupWorker()
+    private synchronized void startupWorker() throws IOException
     {
         if( worker == null )
         {
+            selector = Selector.open();
             worker = new Worker();
 
             worker.start();
@@ -158,11 +156,23 @@
         CancellationRequest request = new CancellationRequest( address );
         synchronized( this )
         {
+            try
+            {
+                startupWorker();
+            }
+            catch( IOException e )
+            {
+                // IOException is thrown only when Worker thread is not
+                // running and failed to open a selector.  We simply throw
+                // IllegalArgumentException here because we can simply
+                // conclude that nothing is bound to the selector.
+                throw new IllegalArgumentException( "Address not bound: " + address );
+            }
+
             synchronized( cancelQueue )
             {
                 cancelQueue.push( request );
             }
-            startupWorker();
         }
         
         selector.wakeup();
@@ -242,7 +252,18 @@
                                 cancelQueue.isEmpty() )
                             {
                                 worker = null;
-
+                                try
+                                {
+                                    selector.close();
+                                }
+                                catch( IOException e )
+                                {
+                                    exceptionMonitor.exceptionCaught( SocketAcceptor.this,
e );
+                                }
+                                finally
+                                {
+                                    selector = null;
+                                }
                                 break;
                             }
                         }

Modified: directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketConnector.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketConnector.java?rev=188654&r1=188653&r2=188654&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketConnector.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketConnector.java
Mon Jun  6 18:31:11 2005
@@ -51,7 +51,7 @@
 
     private final IoSessionManagerFilterChain filters = new SocketSessionManagerFilterChain(
this );
 
-    private final Selector selector;
+    private Selector selector;
 
     private final Queue connectQueue = new Queue();
 
@@ -59,12 +59,9 @@
 
     /**
      * Creates a new instance.
-     * 
-     * @throws IOException
      */
-    public SocketConnector() throws IOException
+    public SocketConnector()
     {
-        selector = Selector.open();
     }
 
     public IoSession connect( SocketAddress address, IoHandler handler ) throws IOException
@@ -163,10 +160,11 @@
         return request.session;
     }
     
-    private synchronized void startupWorker()
+    private synchronized void startupWorker() throws IOException
     {
         if( worker == null )
         {
+            selector = Selector.open();
             worker = new Worker();
             worker.start();
         }
@@ -331,6 +329,18 @@
                                 connectQueue.isEmpty() )
                             {
                                 worker = null;
+                                try
+                                {
+                                    selector.close();
+                                }
+                                catch( IOException e )
+                                {
+                                    exceptionMonitor.exceptionCaught( SocketConnector.this,
e );
+                                }
+                                finally
+                                {
+                                    selector = null;
+                                }
                                 break;
                             }
                         }

Modified: directory/network/trunk/src/test/org/apache/mina/transport/socket/nio/DatagramBindTest.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/test/org/apache/mina/transport/socket/nio/DatagramBindTest.java?rev=188654&r1=188653&r2=188654&view=diff
==============================================================================
--- directory/network/trunk/src/test/org/apache/mina/transport/socket/nio/DatagramBindTest.java
(original)
+++ directory/network/trunk/src/test/org/apache/mina/transport/socket/nio/DatagramBindTest.java
Mon Jun  6 18:31:11 2005
@@ -18,7 +18,6 @@
  */
 package org.apache.mina.transport.socket.nio;
 
-import java.io.IOException;
 
 /**
  * Tests {@link DatagramAcceptor} resource leakage.
@@ -29,7 +28,7 @@
 public class DatagramBindTest extends AbstractBindTest
 {
 
-    public DatagramBindTest() throws IOException
+    public DatagramBindTest()
     {
         super( new DatagramAcceptor() );
     }

Modified: directory/network/trunk/src/test/org/apache/mina/transport/socket/nio/SocketBindTest.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/test/org/apache/mina/transport/socket/nio/SocketBindTest.java?rev=188654&r1=188653&r2=188654&view=diff
==============================================================================
--- directory/network/trunk/src/test/org/apache/mina/transport/socket/nio/SocketBindTest.java
(original)
+++ directory/network/trunk/src/test/org/apache/mina/transport/socket/nio/SocketBindTest.java
Mon Jun  6 18:31:11 2005
@@ -18,7 +18,6 @@
  */
 package org.apache.mina.transport.socket.nio;
 
-import java.io.IOException;
 
 /**
  * Tests {@link SocketAcceptor} resource leakage.
@@ -29,7 +28,7 @@
 public class SocketBindTest extends AbstractBindTest
 {
 
-    public SocketBindTest() throws IOException
+    public SocketBindTest()
     {
         super( new SocketAcceptor() );
     }



Mime
View raw message