directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r158580 - in directory/network/trunk/src/java/org/apache/mina/io: datagram/DatagramAcceptor.java socket/SocketAcceptor.java
Date Tue, 22 Mar 2005 08:57:15 GMT
Author: trustin
Date: Tue Mar 22 00:57:04 2005
New Revision: 158580

URL: http://svn.apache.org/viewcvs?view=rev&rev=158580
Log:
Fixed: unbind() blocks when user tries to unbind unknown socket address.
Fixed: IOException thrown by bind() has incomprehensive stack trace.

Modified:
    directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java
    directory/network/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java

Modified: directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java?view=diff&r1=158579&r2=158580
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java Tue
Mar 22 00:57:04 2005
@@ -124,6 +124,7 @@
         
         if( request.exception != null )
         {
+            request.exception.fillInStackTrace();
             throw request.exception;
         }
     }
@@ -154,6 +155,12 @@
                 }
             }
         }
+        
+        if( request.exception == null )
+        {
+            request.exception.fillInStackTrace();
+            throw request.exception;
+        }
     }
 
     public void flushSession( DatagramSession session )
@@ -456,7 +463,15 @@
 
             DatagramChannel ch = ( DatagramChannel ) channels.get( request.address );
             if( ch == null )
+            {
+                synchronized( request )
+                {
+                    request.done = true;
+                    request.exception = new IllegalArgumentException(
+                            "Address not bound: " + request.address );
+                }
                 continue;
+            }
             
             SelectionKey key = ch.keyFor( selector );
             key.cancel();
@@ -522,8 +537,8 @@
     private static class CancellationRequest
     {
         private final SocketAddress address;
-        
         private boolean done;
+        private RuntimeException exception;
         
         private CancellationRequest( SocketAddress address )
         {

Modified: directory/network/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java?view=diff&r1=158579&r2=158580
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java Tue Mar
22 00:57:04 2005
@@ -134,6 +134,7 @@
         
         if( request.exception != null )
         {
+            request.exception.fillInStackTrace();
             throw request.exception;
         }
     }
@@ -164,6 +165,12 @@
                 }
             }
         }
+        
+        if( request.exception != null )
+        {
+            request.exception.fillInStackTrace();
+            throw request.exception;
+        }
     }
 
     private class Worker extends Thread
@@ -312,7 +319,15 @@
 
             ServerSocketChannel ssc = ( ServerSocketChannel ) channels.get( request.address
);
             if( ssc == null )
+            {
+                synchronized( request )
+                {
+                    request.done = true;
+                    request.exception = new IllegalArgumentException(
+                            "Address not bound: " + request.address );
+                }
                 continue;
+            }
             
             SelectionKey key = ssc.keyFor( selector );
             key.cancel();
@@ -382,8 +397,8 @@
     private static class CancellationRequest
     {
         private final SocketAddress address;
-        
         private boolean done;
+        private RuntimeException exception;
         
         private CancellationRequest( SocketAddress address )
         {



Mime
View raw message