directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r406515 - in /directory/trunks/mina/core/src/main/java/org/apache/mina/handler: StreamIoHandler.java support/IoSessionOutputStream.java
Date Mon, 15 May 2006 03:22:03 GMT
Author: trustin
Date: Sun May 14 20:22:03 2006
New Revision: 406515

URL: http://svn.apache.org/viewcvs?rev=406515&view=rev
Log:
Fixed issue: DIRMINA-214 (The InputStream that StreamIoHandler provides is closed too early.)
* StreamIoHandler doesn't close Input/OutputStream.  A user has to close them explicitly.
* Optimized memory usage of IoSessionOutputStream

Modified:
    directory/trunks/mina/core/src/main/java/org/apache/mina/handler/StreamIoHandler.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/handler/support/IoSessionOutputStream.java

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/handler/StreamIoHandler.java
URL: http://svn.apache.org/viewcvs/directory/trunks/mina/core/src/main/java/org/apache/mina/handler/StreamIoHandler.java?rev=406515&r1=406514&r2=406515&view=diff
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/handler/StreamIoHandler.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/handler/StreamIoHandler.java
Sun May 14 20:22:03 2006
@@ -117,17 +117,6 @@
     }
     
     /**
-     * Closes input stream.
-     */
-    public void sessionClosed( IoSession session )
-    {
-        IoSessionInputStream in = ( IoSessionInputStream ) session.getAttribute( KEY_IN );
-        IoSessionOutputStream out = ( IoSessionOutputStream ) session.getAttribute( KEY_OUT
);
-        in.close();
-        out.close();
-    }
-
-    /**
      * Forwards read data to input stream.
      */
     public void messageReceived( IoSession session, Object buf )

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/handler/support/IoSessionOutputStream.java
URL: http://svn.apache.org/viewcvs/directory/trunks/mina/core/src/main/java/org/apache/mina/handler/support/IoSessionOutputStream.java?rev=406515&r1=406514&r2=406515&view=diff
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/handler/support/IoSessionOutputStream.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/handler/support/IoSessionOutputStream.java
Sun May 14 20:22:03 2006
@@ -42,7 +42,7 @@
 
     public void close()
     {
-        session.close().join();
+        session.close();
     }
 
     public void flush()
@@ -51,23 +51,32 @@
 
     public void write( byte[] b, int off, int len )
     {
-        ByteBuffer buf = ByteBuffer.wrap( b, off, len );
-        buf.acquire(); // prevent from being pooled.
-        session.write( buf );
+        if( session.isConnected() )
+        {
+            ByteBuffer buf = ByteBuffer.wrap( b, off, len );
+            buf.acquire(); // prevent from being pooled.
+            session.write( buf );
+        }
     }
 
     public void write( byte[] b )
     {
-        ByteBuffer buf = ByteBuffer.wrap( b );
-        buf.acquire(); // prevent from being pooled.
-        session.write( buf );
+        if( session.isConnected() )
+        {
+            ByteBuffer buf = ByteBuffer.wrap( b );
+            buf.acquire(); // prevent from being pooled.
+            session.write( buf );
+        }
     }
 
     public void write( int b )
     {
-        ByteBuffer buf = ByteBuffer.allocate( 1 );
-        buf.put( ( byte ) b );
-        buf.flip();
-        session.write( buf );
+        if( session.isConnected() )
+        {
+            ByteBuffer buf = ByteBuffer.allocate( 1 );
+            buf.put( ( byte ) b );
+            buf.flip();
+            session.write( buf );
+        }
     }
 }



Mime
View raw message