directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r164306 - /directory/network/trunk/src/java/org/apache/mina/io/filter/SSLFilter.java
Date Sat, 23 Apr 2005 00:20:45 GMT
Author: trustin
Date: Fri Apr 22 17:20:45 2005
New Revision: 164306

URL: http://svn.apache.org/viewcvs?rev=164306&view=rev
Log:
I made a silly mistake on SSLFilter! :(

Modified:
    directory/network/trunk/src/java/org/apache/mina/io/filter/SSLFilter.java

Modified: directory/network/trunk/src/java/org/apache/mina/io/filter/SSLFilter.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/filter/SSLFilter.java?rev=164306&r1=164305&r2=164306&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/filter/SSLFilter.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/filter/SSLFilter.java Fri Apr 22 17:20:45
2005
@@ -240,8 +240,8 @@
                             debug.print( "encrypt: " + buf );
                         }
                         sslHandler.encrypt( buf.buf() );
-                        ByteBuffer encryptedBuffer =
-                            ByteBuffer.wrap( sslHandler.getOutNetBuffer() );
+                        ByteBuffer encryptedBuffer = copy( sslHandler
+                                .getOutNetBuffer() );
 
                         if( debug != null )
                         {
@@ -284,8 +284,7 @@
         if( sslHandler.getAppBuffer().hasRemaining() )
         {
             // forward read app data
-            ByteBuffer readBuffer =
-                ByteBuffer.wrap( sslHandler.getAppBuffer() );
+            ByteBuffer readBuffer = copy( sslHandler.getAppBuffer() );
             if( debug != null )
             {
                 debug.print( "app data read: " + readBuffer + " (" + readBuffer.getHexDump()
+ ')' );
@@ -320,8 +319,7 @@
                 debug.print( "write outNetBuffer: "
                         + sslHandler.getOutNetBuffer() );
             }
-            ByteBuffer writeBuffer =
-                ByteBuffer.wrap( sslHandler.getOutNetBuffer() );
+            ByteBuffer writeBuffer = copy( sslHandler.getOutNetBuffer() );
             if( debug != null )
             {
                 debug.print( "session write: " + writeBuffer );
@@ -350,8 +348,8 @@
                         debug.print( "write outNetBuffer2: "
                                 + sslHandler.getOutNetBuffer() );
                     }
-                    ByteBuffer writeBuffer2 =
-                        ByteBuffer.wrap ( sslHandler.getOutNetBuffer() );
+                    ByteBuffer writeBuffer2 = copy( sslHandler
+                            .getOutNetBuffer() );
                     session.write( writeBuffer2, null );
                 }
             }
@@ -363,6 +361,21 @@
                 sslHandler.setWritingEncryptedData( false );
             }
         }
+    }
+
+    /**
+     * Creates a new Mina byte buffer that is a deep copy of the remaining bytes
+     * in the given buffer (between index buf.position() and buf.limit())
+     *
+     * @param src the buffer to copy
+     * @return the new buffer, ready to read from
+     */
+    private static ByteBuffer copy( java.nio.ByteBuffer src )
+    {
+        ByteBuffer copy = ByteBuffer.allocate( src.remaining() );
+        copy.put( src );
+        copy.flip();
+        return copy;
     }
 
     // Utilities to mainpulate SSLHandler based on IoSession



Mime
View raw message