You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by tr...@apache.org on 2007/12/07 15:45:51 UTC

svn commit: r602110 - /mina/trunk/core/src/main/java/org/apache/mina/common/AbstractIoBuffer.java

Author: trustin
Date: Fri Dec  7 06:45:50 2007
New Revision: 602110

URL: http://svn.apache.org/viewvc?rev=602110&view=rev
Log:
Fixed a unexpected IndexOutOfBoundsException while adjusting position and limit temporarily in getSlice(idx, len)

Modified:
    mina/trunk/core/src/main/java/org/apache/mina/common/AbstractIoBuffer.java

Modified: mina/trunk/core/src/main/java/org/apache/mina/common/AbstractIoBuffer.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/AbstractIoBuffer.java?rev=602110&r1=602109&r2=602110&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/AbstractIoBuffer.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/AbstractIoBuffer.java Fri Dec  7 06:45:50 2007
@@ -693,8 +693,18 @@
         }
         int pos = position();
         int limit = limit();
+        int endIndex = pos + length;
+
+        if (capacity() < endIndex) {
+            throw new IndexOutOfBoundsException(
+                    "index + length (" + endIndex + ") is greater " +
+                    "than capacity (" + capacity() + ").");
+        }
+
+        clear();
         position(index);
-        limit(index + length);
+        limit(endIndex);
+
         IoBuffer slice = slice();
         position(pos);
         limit(limit);