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);


Reply via email to