Author: trustin
Date: Wed Jul 30 04:58:19 2008
New Revision: 680990

URL: http://svn.apache.org/viewvc?rev=680990&view=rev
Log:
Fixed issue: DIRMINA-613 (Calling IoBuffer.slice() in 
CumulativeProtocolDecoder.doDecode() can cause data corruption.)
* Made sure if the internal buffer is still auto-expandable before calling 
compact().

Modified:
    
mina/trunk/core/src/main/java/org/apache/mina/filter/codec/CumulativeProtocolDecoder.java

Modified: 
mina/trunk/core/src/main/java/org/apache/mina/filter/codec/CumulativeProtocolDecoder.java
URL: 
http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/filter/codec/CumulativeProtocolDecoder.java?rev=680990&r1=680989&r2=680990&view=diff
==============================================================================
--- 
mina/trunk/core/src/main/java/org/apache/mina/filter/codec/CumulativeProtocolDecoder.java
 (original)
+++ 
mina/trunk/core/src/main/java/org/apache/mina/filter/codec/CumulativeProtocolDecoder.java
 Wed Jul 30 04:58:19 2008
@@ -95,9 +95,9 @@
  * Please note that this decoder simply forward the call to
  * [EMAIL PROTECTED] #doDecode(IoSession, IoBuffer, ProtocolDecoderOutput)} if 
the
  * underlying transport doesn't have a packet fragmentation.  Whether the
- * transport has fragmentation or not is determined by querying 
+ * transport has fragmentation or not is determined by querying
  * [EMAIL PROTECTED] TransportMetadata}.
- * 
+ *
  * @author The Apache MINA Project ([EMAIL PROTECTED])
  * @version $Rev$, $Date$
  */
@@ -159,7 +159,7 @@
                 newBuf.put(in);
                 newBuf.flip();
                 buf = newBuf;
-                
+
                 // Update the session attribute.
                 session.setAttribute(BUFFER, buf);
             }
@@ -189,7 +189,7 @@
         // it in a buffer in the session and next time this decoder is
         // invoked the session buffer gets appended to
         if (buf.hasRemaining()) {
-            if (usingSessionBuffer) {
+            if (usingSessionBuffer && buf.isAutoExpand()) {
                 buf.compact();
             } else {
                 storeRemainingInSession(buf, session);
@@ -231,10 +231,10 @@
 
     private void storeRemainingInSession(IoBuffer buf, IoSession session) {
         final IoBuffer remainingBuf = 
IoBuffer.allocate(buf.capacity()).setAutoExpand(true);
-        
+
         remainingBuf.order(buf.order());
         remainingBuf.put(buf);
-        
+
         session.setAttribute(BUFFER, remainingBuf);
     }
 }


Reply via email to