directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r161435 - in directory/network/trunk/src/java/org/apache/mina: io/filter/SSLFilter.java protocol/codec/Asn1CodecEncoder.java
Date Fri, 15 Apr 2005 10:38:44 GMT
Author: trustin
Date: Fri Apr 15 03:38:41 2005
New Revision: 161435

URL: http://svn.apache.org/viewcvs?view=rev&rev=161435
Log:
SSLFilter and Asn1CodecEncoder doesn't copy ByteBuffers thanks to ByteBuffer.wrap()

Modified:
    directory/network/trunk/src/java/org/apache/mina/io/filter/SSLFilter.java
    directory/network/trunk/src/java/org/apache/mina/protocol/codec/Asn1CodecEncoder.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?view=diff&r1=161434&r2=161435
==============================================================================
--- 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 15 03:38:41
2005
@@ -240,8 +240,8 @@
                             debug.print( "encrypt: " + buf );
                         }
                         sslHandler.encrypt( buf.buf() );
-                        ByteBuffer encryptedBuffer = copy( sslHandler
-                                .getOutNetBuffer() );
+                        ByteBuffer encryptedBuffer =
+                            ByteBuffer.wrap( sslHandler.getOutNetBuffer() );
 
                         if( debug != null )
                         {
@@ -284,7 +284,8 @@
         if( sslHandler.getAppBuffer().hasRemaining() )
         {
             // forward read app data
-            ByteBuffer readBuffer = copy( sslHandler.getAppBuffer() );
+            ByteBuffer readBuffer =
+                ByteBuffer.wrap( sslHandler.getAppBuffer() );
             if( debug != null )
             {
                 debug.print( "app data read: " + readBuffer + " (" + readBuffer.getHexDump()
+ ')' );
@@ -319,7 +320,8 @@
                 debug.print( "write outNetBuffer: "
                         + sslHandler.getOutNetBuffer() );
             }
-            ByteBuffer writeBuffer = copy( sslHandler.getOutNetBuffer() );
+            ByteBuffer writeBuffer =
+                ByteBuffer.wrap( sslHandler.getOutNetBuffer() );
             if( debug != null )
             {
                 debug.print( "session write: " + writeBuffer );
@@ -348,8 +350,8 @@
                         debug.print( "write outNetBuffer2: "
                                 + sslHandler.getOutNetBuffer() );
                     }
-                    ByteBuffer writeBuffer2 = copy( sslHandler
-                            .getOutNetBuffer() );
+                    ByteBuffer writeBuffer2 =
+                        ByteBuffer.wrap ( sslHandler.getOutNetBuffer() );
                     session.write( writeBuffer2, null );
                 }
             }
@@ -361,21 +363,6 @@
                 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 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

Modified: directory/network/trunk/src/java/org/apache/mina/protocol/codec/Asn1CodecEncoder.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/protocol/codec/Asn1CodecEncoder.java?view=diff&r1=161434&r2=161435
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/protocol/codec/Asn1CodecEncoder.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/protocol/codec/Asn1CodecEncoder.java
Fri Apr 15 03:38:41 2005
@@ -59,10 +59,7 @@
             if( encoded instanceof java.nio.ByteBuffer )
             {
                 java.nio.ByteBuffer buf = ( java.nio.ByteBuffer ) encoded;
-                ByteBuffer outBuf = ByteBuffer.allocate( buf.remaining() );
-                outBuf.put( buf );
-                outBuf.flip();
-                encOut.write( outBuf );
+                encOut.write( ByteBuffer.wrap( buf ) );
             }
             else if( encoded instanceof Object[] )
             {



Mime
View raw message